-
Notifications
You must be signed in to change notification settings - Fork 816
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
addd a cmake option to enable single account desktop client
Signed-off-by: Matthieu Gallien <[email protected]>
- Loading branch information
Showing
13 changed files
with
247 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright © 2023, Matthieu Gallien <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* for more details. | ||
*/ | ||
|
||
#define OPENSSL_SUPPRESS_DEPRECATED | ||
|
||
#include "clientsidetokenselector.h" | ||
|
||
#include <QLoggingCategory> | ||
|
||
#include <libp11.h> | ||
|
||
namespace OCC | ||
{ | ||
|
||
Q_LOGGING_CATEGORY(lcCseSelector, "nextcloud.sync.clientsideencryption.selector", QtInfoMsg) | ||
|
||
ClientSideTokenSelector::ClientSideTokenSelector(QObject *parent) | ||
: QObject{parent} | ||
{ | ||
|
||
} | ||
|
||
bool ClientSideTokenSelector::isSetup() const | ||
{ | ||
return false; | ||
} | ||
|
||
QVariantList ClientSideTokenSelector::discoveredTokens() const | ||
{ | ||
return _discoveredTokens; | ||
} | ||
|
||
void failedToInitialize(std::nullptr_t) | ||
{ | ||
} | ||
|
||
void ClientSideTokenSelector::searchForToken() | ||
{ | ||
auto account = nullptr; | ||
auto ctx = PKCS11_CTX_new(); | ||
|
||
auto rc = PKCS11_CTX_load(ctx, "opensc-pkcs11.so"); | ||
if (rc) { | ||
qCWarning(lcCseSelector()) << "loading pkcs11 engine failed:" << ERR_reason_error_string(ERR_get_error()); | ||
|
||
failedToInitialize(account); | ||
return; | ||
} | ||
|
||
auto tokensCount = 0u; | ||
PKCS11_SLOT *tokenSlots = nullptr; | ||
/* get information on all slots */ | ||
if (PKCS11_enumerate_slots(ctx, &tokenSlots, &tokensCount) < 0) { | ||
qCWarning(lcCseSelector()) << "no slots available" << ERR_reason_error_string(ERR_get_error()); | ||
|
||
failedToInitialize(account); | ||
return; | ||
} | ||
|
||
_discoveredTokens.clear(); | ||
auto currentSlot = static_cast<PKCS11_SLOT*>(nullptr); | ||
for(auto i = 0u; i < tokensCount; ++i) { | ||
currentSlot = PKCS11_find_next_token(ctx, tokenSlots, tokensCount, currentSlot); | ||
if (currentSlot == nullptr || currentSlot->token == nullptr) { | ||
qCWarning(lcCseSelector()) << "no token available" << ERR_reason_error_string(ERR_get_error()); | ||
|
||
failedToInitialize(account); | ||
return; | ||
} | ||
qCInfo(lcCseSelector()) << "Slot manufacturer......:" << currentSlot->manufacturer; | ||
qCInfo(lcCseSelector()) << "Slot description.......:" << currentSlot->description; | ||
qCInfo(lcCseSelector()) << "Slot token label.......:" << currentSlot->token->label; | ||
qCInfo(lcCseSelector()) << "Slot token manufacturer:" << currentSlot->token->manufacturer; | ||
qCInfo(lcCseSelector()) << "Slot token model.......:" << currentSlot->token->model; | ||
qCInfo(lcCseSelector()) << "Slot token serialnr....:" << currentSlot->token->serialnr; | ||
|
||
_discoveredTokens.push_back(QVariantMap{{QStringLiteral("manufacturer"), QString::fromLatin1(currentSlot->manufacturer)}, | ||
{QStringLiteral("description"), QString::fromLatin1(currentSlot->description)}, | ||
{QStringLiteral("label"), QString::fromLatin1(currentSlot->token->label)},}); | ||
} | ||
emit discoveredTokensChanged(); | ||
} | ||
|
||
} |
Oops, something went wrong.