![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Base/AuthorizationProvider.h>
Interface for providing the Authorization header for WebRequests. More...
Interface for providing the Authorization header for WebRequests.
All provided URLs should be the full URL of the desired requests. Implementations can use extractServerUrl for caching an authorization for a specific server.
Public Member Functions | |
virtual std::string | authorization (const Filesystem::Url &url) const =0 |
Get the Authorization header for the given url. | |
virtual bool | refreshAuthorization (const Filesystem::Url &url, int numFailedRequests)=0 |
Try to refresh the authorization without user interaction. | |
virtual bool | acquireAuthorization (const Filesystem::Url &url, const std::string &message)=0 |
Acquire authorization by e.g. | |
virtual void | removeAuthorization (const Filesystem::Url &url)=0 |
Remove any cached authorization for the given server. | |
Filesystem::Url | extractServerUrl (const Filesystem::Url &url) const |
Extract the server part of the URL. | |
|
pure virtual |
Get the Authorization header for the given url.
The url is the complete url for the request that is going to be performed. Implementation should cache the value according to the server URL (see extractServerUrl). When an empty string is returned, no Authorization header should be send. This method will be called from multiple threads.
Implemented in StaticAuthorizationProvider, and QtAuthorizationProvider.
|
pure virtual |
Try to refresh the authorization without user interaction.
Implementations should stop retrying after a certain number of failed attempts. This method will be called from multiple threads. If an auth scheme does not support refreshing without user interaction, implementations should return false after the first failed attempt.
Implementations that cache authorization according to the url, should remove entries from the cache that cannot be refreshed after one failed request.
This method can also be called without a previously failed request (numFailedRequests == 0) in case the token should be refreshed before it expires.
E.g. if this method fails, the authorization method should return an empty string until acquireAuthorization was called again.
Implemented in StaticAuthorizationProvider, and QtAuthorizationProvider.
|
pure virtual |
Acquire authorization by e.g.
asking the user.
This method might get called from another thread. In this case, implementations that require the main thread to show a GUI should just return false.
An optional message can be provided (e.g. to display an error from a previous login attempt).
Should return true if authorization could be acquired or false otherwise.
This method is not expected to check whether the acquired authorization actually works, because this is simply not possible with some auth schemes.
Code that requires authorization should call this method from the main thread before performing requests. If those requests fail with 401, this method should be called again from the main thread before retrying the requests. If multiple requests are run in parallel, it must be avoided to call this method multiple times simultaneous, because this might popup multiple dialogs.
Implemented in StaticAuthorizationProvider, and QtAuthorizationProvider.
|
pure virtual |
Remove any cached authorization for the given server.
This should essentially log out the user and let the user re-authenticate with the next acquireAuthorization call.
Implemented in StaticAuthorizationProvider, and QtAuthorizationProvider.
Filesystem::Url extractServerUrl | ( | const Filesystem::Url & | url | ) | const |
Extract the server part of the URL.
E.g. http://example.com:8080/dicomweb/studies becomes http://example.com:8080