![]() |
AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
#include <AuthorizationManager.h>
Static Public Member Functions | |
static std::shared_ptr< acsdkAuthorization::AuthorizationManager > | create (const std::shared_ptr< avsCommon::sdkInterfaces::storage::MiscStorageInterface > &storage, const std::shared_ptr< registrationManager::CustomerDataManagerInterface > &customerDataManager) |
Additional Inherited Members |
This class allows for runtime switching between different authorization mechanisms. It implements the following interfaces:
AuthorizationManagerInterface
, which is used for communication and operation with the adapter.AuthorizationAuthorityInterface
, which contains APIs that that can be used to understand general authorization state.To integrate an AuthorizationAdapterInterface
with this class, first it must be added via the AuthorizationManagerInterface::add
method. Then, adapters can report state changes via AuthorizationManagerInterface::reportStateChange
. When reporting state, the unique identifer for the adapter must be sent. Additionally, it is advised to attach a userId that represents the customer. This is currently optional, but allows for strong protection of customer data. AuthorizationManager will initiate a logout in cases where ids mismatch.
Logout:
AuthorizationAdapterInterface
instances should not extend CustomerDataHandler
. Instead, expect an AuthorizationAdapterInterface::reset
for when persisted user data should be cleared.
States:
AuthObserverInterface::State::UNINITIALIZED
This is an uninitialized state.
AuthObserverInterface::State::AUTHORIZING
Upon first authorization, the state must be reported. This tells AuthorizationManager
that a new authorization is occuring, and will be used for future token requests once AuthObserverInterface::State::REFRESHED
is reported.
Implicit Logout: For convenience, when switching between authorizations, a non-active adapter can force logout by sending a reportStateChange with AuthObserverInterface::State::AUTHORIZING. This will signal to the AuthorizationManager
that a new adapter wishes to authorize, and implicitly log the system out.
AuthObserverInterface::State::REFRESHED
This state indicates a successful authorization, and indicates the AuthorizationManager
will respond to getAuthToken() requests by querying the adapter. Sending this with a non-active authorization will cause a logout. This restriction is to ensure authorization state consistency is maintained and that customer data is protected. The active adapter's id and user id is persisted and will be used to validate future reportStateChange calls.
AuthObserverInterface::State::EXPIRED
This state indicates the token has expired.
AuthObserverItnerface::State::UNRECOVERABLE_ERROR
This should be reserved for unrecoverable errors, and will cause AuthorizationManager to force a logout.
AuthorizationManager currently implements CustomDataHandler and subscribes itself to RegistrationManager. This is because RegistrationManager still acts as the main implementation of RegistrationManagerInterface in the AVS SDK.
|
override |
|
override |
|
overridevirtual |
Reset any internal state that may be associated with a particular user.
Implements alexaClientSDK::registrationManager::CustomerDataHandlerInterface.
|
static |
Creates an instance of AuthorizationManager
.
storage | The storage interface. |
customerDataManager | A CustomerDataManagerInterface instance to initiate logout. |
|
overridevirtual |
Prepares/enables this object to be deleted. This should be the last function called on this object prior to deleting (or resetting) its shared_ptr.
Implements alexaClientSDK::avsCommon::utils::RequiresShutdown.
|
overridevirtual |
Returns the string identifying the current active AuthorizationInterface
. An active adapter can be in the process of obtaining authorization tokens.
Implements alexaClientSDK::acsdkAuthorizationInterfaces::AuthorizationAuthorityInterface.
|
overridevirtual |
Get the current LWA authorization token.
Implements alexaClientSDK::avsCommon::sdkInterfaces::AuthDelegateInterface.
|
overridevirtual |
Returns the current authorization state.
Implements alexaClientSDK::acsdkAuthorizationInterfaces::AuthorizationAuthorityInterface.
|
overridevirtual |
Log out current customer. This will clear any persistent data.
Implements alexaClientSDK::registrationManager::RegistrationManagerInterface.
|
overridevirtual |
Receive notification that an operation using the specified auth token experienced an authorization failure.
token | The token used to authorize the forbidden operation. |
Implements alexaClientSDK::avsCommon::sdkInterfaces::AuthDelegateInterface.
|
override |
|
overridevirtual |
Reports the state change. This should be called in accordance with state transitions documented in AuthObserverInterface::State
. UserId may not initially be available in the AUTHORIZING state. The values obtained in REFRESHED will be carried forward for future callbacks for validation purposes.
state | The state. |
authId | The unique auth id. |
userId | The user id associated with this. |
Implements alexaClientSDK::acsdkAuthorizationInterfaces::AuthorizationManagerInterface.
void alexaClientSDK::acsdkAuthorization::AuthorizationManager::setRegistrationManager | ( | const std::shared_ptr< registrationManager::RegistrationManagerInterface > | registrationManager | ) |
Set the RegistrationManagerInterface
instance.
registrationManager | The object used to logout. |
AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0