Commit 878ab8f8 authored by Andrew den Exter's avatar Andrew den Exter

[devicelock] Coordinate new authentication requests arriving during an...

[devicelock] Coordinate new authentication requests arriving during an uninterruptable operation. JB#45370
parent 78f499c8
...@@ -146,37 +146,70 @@ public: ...@@ -146,37 +146,70 @@ public:
void availabilityChanged(); void availabilityChanged();
private: private:
enum StateFlag {
ErrorFlag = 0x1000,
EvaluatingFlag = 0x2000,
CanceledFlag = 0x4000,
CompletedFlag = 0x8000
};
enum State { enum State {
Idle, Idle,
Authenticating, Authenticating,
AuthenticationError,
AuthenticatingForChange, AuthenticatingForChange,
RequestingPermission, RequestingPermission,
EnteringNewSecurityCode, EnteringNewSecurityCode,
RepeatingNewSecurityCode, RepeatingNewSecurityCode,
ExpectingGeneratedSecurityCode, ExpectingGeneratedSecurityCode,
Changing, Changing,
ChangeError,
ChangeCanceled, ChangeCanceled,
AuthenticatingForClear, AuthenticatingForClear,
ClearError,
WaitingAuthentication, AuthenticationError = Authenticating | ErrorFlag,
WaitingPermission, AuthenticationEvaluating = Authenticating | EvaluatingFlag,
WaitingAuthenticationForChange, AuthenticationCanceled = Authenticating | CanceledFlag,
WaitingAuthenticationForClear, AuthenticationCompleted = Authenticating | CompletedFlag,
PermissionEvaluating = RequestingPermission | EvaluatingFlag, // The error and cancel states are shared with authenticating.
ChangeError = AuthenticatingForChange | ErrorFlag,
AuthenticationForChangeEvaluating = AuthenticatingForChange | EvaluatingFlag,
AuthenticationForChangeCanceled = AuthenticatingForChange | CanceledFlag,
ClearError = AuthenticatingForClear | ErrorFlag,
AuthenticationForClearEvaluating = AuthenticatingForClear | EvaluatingFlag,
AuthenticationForClearCanceled = AuthenticatingForClear | CanceledFlag,
};
enum Request {
NoRequest,
AuthenticateRequest,
PermissionRequest,
ChangeRequest,
ClearRequest
}; };
inline bool isSecurityCodeSet() const; inline bool isSecurityCodeSet() const;
inline void authenticate( inline void authenticate(
const QString &authenticator, const QVariant &challengeCode, Authenticator::Methods methods); const QString &authenticator, const QVariant &challengeCode, Authenticator::Methods methods);
inline void beginAuthenticate(uint pid, const QVariant &challengeCode, Authenticator::Methods methods);
inline void requestPermission( inline void requestPermission(
const QString &client, const QString &client,
const QString &message, const QString &message,
const QVariantMap &properties, const QVariantMap &properties,
Authenticator::Methods methods); Authenticator::Methods methods);
inline void beginRequestPermission(
uint pid,
const QString &message,
const QVariantMap &properties,
Authenticator::Methods methods);
inline void handleChangeSecurityCode(const QString &client, const QVariant &challengeCode); inline void handleChangeSecurityCode(const QString &client, const QVariant &challengeCode);
inline void beginChangeSecurityCode(uint pid, const QVariant &challengeCode);
inline void handleClearSecurityCode(const QString &client); inline void handleClearSecurityCode(const QString &client);
inline void beginClearSecurityCode(uint pid);
inline void handleCancel(const QString &client); inline void handleCancel(const QString &client);
inline void cancelPending();
inline void beginPending();
inline QVariantMap generatedCodeData(); inline QVariantMap generatedCodeData();
inline void enterCodeChangeState( inline void enterCodeChangeState(
FeedbackFunction feedback, Authenticator::Methods methods = Authenticator::Methods()); FeedbackFunction feedback, Authenticator::Methods methods = Authenticator::Methods());
...@@ -186,6 +219,19 @@ private: ...@@ -186,6 +219,19 @@ private:
HostAuthenticatorAdaptor m_adaptor; HostAuthenticatorAdaptor m_adaptor;
HostSecurityCodeSettingsAdaptor m_securityCodeAdaptor; HostSecurityCodeSettingsAdaptor m_securityCodeAdaptor;
struct Pending {
QVariant challengeCode;
QVariantMap properties;
QString connection;
QString client;
QString message;
uint pid = 0;
Authenticator::Methods methods;
Request request = NoRequest;
void clear();
} m_pending;
QVariant m_challengeCode; QVariant m_challengeCode;
QString m_currentCode; QString m_currentCode;
QString m_newCode; QString m_newCode;
......
...@@ -146,17 +146,27 @@ bool HostObject::authorizeConnection(const QDBusConnection &connection) ...@@ -146,17 +146,27 @@ bool HostObject::authorizeConnection(const QDBusConnection &connection)
return true; return true;
} }
bool HostObject::isActiveClient(const QString &connection, const QString &client) const
{
return m_activeConnection == connection && m_activeClient == client;
}
bool HostObject::isActiveClient(const QString &client) const bool HostObject::isActiveClient(const QString &client) const
{ {
return m_activeConnection == QDBusContext::connection().name() && m_activeClient == client; return isActiveClient(QDBusContext::connection().name(), client);
} }
void HostObject::setActiveClient(const QString &client) void HostObject::setActiveClient(const QString &connection, const QString &client)
{ {
m_activeConnection = QDBusContext::connection().name(); m_activeConnection = connection;
m_activeClient = client; m_activeClient = client;
} }
void HostObject::setActiveClient(const QString &client)
{
setActiveClient(QDBusContext::connection().name(), client);
}
void HostObject::clearActiveClient() void HostObject::clearActiveClient()
{ {
m_activeConnection.clear(); m_activeConnection.clear();
......
...@@ -64,8 +64,10 @@ public: ...@@ -64,8 +64,10 @@ public:
virtual bool authorizeConnection(const QDBusConnection &connection); virtual bool authorizeConnection(const QDBusConnection &connection);
bool isActiveClient(const QString &connection, const QString &client) const;
bool isActiveClient(const QString &client) const; bool isActiveClient(const QString &client) const;
void setActiveClient(const QString &client); void setActiveClient(const QString &client);
void setActiveClient(const QString &connection, const QString &client);
void clearActiveClient(); void clearActiveClient();
protected: protected:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment