RMS SDK for C++  0.2.1
A client library for using Microsoft RMS from Linux.
AcquireTokenHandlerBase.h
1 /*
2  * ======================================================================
3  * Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
4  * Licensed under the MIT License.
5  * See LICENSE.md in the project root for license information.
6  * ======================================================================
7 */
8 
9 #ifndef ACQUIRETOKENHANDLERBASE_H
10 #define ACQUIRETOKENHANDLERBASE_H
11 
12 #include "types.h"
13 #include "Authenticator.h"
14 #include "ClientKey.h"
15 #include "TokenCache.h"
16 #include "TokenSubjectType.h"
17 #include "Exceptions.h"
18 #include "AuthenticationResult.h"
19 #include "RequestParameters.h"
20 #include "Entities.h"
21 #include "OAuthConstants.h"
22 #include "Constants.h"
23 #include "TokenSubjectType.h"
24 #include "HttpHelper.h"
25 #include "UserIdentifier.h"
26 
27 namespace rmsauth {
28 
30 {
31  static const String& Tag() {static const String tag="AcquireTokenHandlerBase"; return tag;}
32 
33 protected:
34  AuthenticatorPtr authenticator_ = nullptr;
35  TokenCachePtr tokenCache_ = nullptr;
36  String resource_;
37  ClientKeyPtr clientKey_ = nullptr;
38  TokenSubjectType tokenSubjectType_;
39  bool loadFromCache_;
40  bool storeToCache_;
41  bool supportADFS_;
42  CallStatePtr callState_ = nullptr;
43 
44  UserIdentifierType userIdentifierType_;
45 
46  String uniqueId_;
47  String displayableId_;
48 
49 public:
50  AuthenticationResultPtr runAsync();
51  static CallStatePtr createCallState(const Guid& correlationId, bool callSync);
52 
53 protected:
54  AcquireTokenHandlerBase(AuthenticatorPtr authenticator, TokenCachePtr tokenCache, const String& resource, ClientKeyPtr clientKey, TokenSubjectType subjectType, bool callSync);
55  virtual void preRunAsync();
56  virtual void postRunAsync(AuthenticationResultPtr result);
57  virtual void preTokenRequest();
58  virtual void postTokenRequest(AuthenticationResultPtr result);
59  virtual void addAditionalRequestParameters(RequestParameters& requestParameters) = 0;
60  virtual AuthenticationResultPtr sendTokenRequestAsync();
61  AuthenticationResultPtr sendTokenRequestByRefreshTokenAsync(const String& refreshToken);
62 
63 private:
64  AuthenticationResultPtr refreshAccessTokenAsync(AuthenticationResultPtr result);
65  AuthenticationResultPtr sendHttpMessageAsync(const RequestParameters& requestParameters);
66  void notifyBeforeAccessCache();
67  void notifyAfterAccessCache();
68  void logReturnedToken(AuthenticationResultPtr result);
69  void validateAuthorityType();
70 };
71 
72 } // namespace rmsauth {
73 
74 #endif // ACQUIRETOKENHANDLERBASE_H
Definition: RequestParameters.h:18
Definition: AcquireTokenHandlerBase.h:29
Definition: AcquireTokenForClientHandler.h:14
Definition: Guid.h:23