RMS SDK for C++  0.2.1
A client library for using Microsoft RMS from Linux.
AuthenticationResult.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 AUTHENTICATIONRESULT_H
10 #define AUTHENTICATIONRESULT_H
11 
12 #include "types.h"
13 #include "UserInfo.h"
14 #include "rmsauthExport.h"
15 
16 namespace rmsauth {
17 
18 class AuthenticationResult;
19 using AuthenticationResultPtr = ptr<AuthenticationResult>;
20 
21 class RMSAUTH_EXPORT AuthenticationResult
22 {
23  static const String& Tag() {static const String tag="AuthenticationResult"; return tag;}
24 
25  const String oAuth2AuthorizationHeader_ = "Bearer ";
26 
27  String accessTokenType_;
28  String accessToken_;
29  String resource_;
30  String refreshToken_;
31  DateTimeOffset expiresOn_;
32  String tenantId_;
33  UserInfoPtr userInfo_;
34  String idToken_;
35  bool isMultipleResourceRefreshToken_;
36 
37 public:
38  AuthenticationResult(const String& accessTokenType, const String& accessToken, const String& refreshToken, DateTimeOffset expiresOn);
39 
40  const String& accessTokenType() const { return accessTokenType_; }
41 
42  const String& accessToken() const { return accessToken_; }
43  void accessToken(const String& val){ accessToken_ = val; }
44 
45  const String& resource() const { return resource_; }
46  void resource(const String& val){ resource_ = val; }
47 
48  const String& refreshToken() const { return refreshToken_; }
49  void refreshToken(const String& val){ refreshToken_ = val; }
50 
51  DateTimeOffset expiresOn() const { return expiresOn_; }
52 
53  const String& tenantId() const { return tenantId_; }
54 
55  const UserInfoPtr userInfo() const { return userInfo_; }
56 
57  const String& idToken() const { return idToken_; }
58 
59  bool isMultipleResourceRefreshToken() const { return isMultipleResourceRefreshToken_; }
60  void isMultipleResourceRefreshToken(const bool val) { isMultipleResourceRefreshToken_ = val; }
61 
62 
63  String createAuthorizationHeader();
64  static AuthenticationResultPtr deserialize(const String& /*serializedObject*/);
65  String serialize();
66 
67  void updateTenantAndUserInfo(const String& tenantId, const String& idToken, UserInfoPtr userInfo);
68 
69 private:
70  friend class OAuth2Response;
71  AuthenticationResult() = default;
72 
73 private:
74  static struct _JsonNames {
75  const String accessTokenType = "accessTokenType";
76  const String accessToken = "accessToken";
77  const String resource = "resource";
78  const String refreshToken = "refreshToken";
79  const String expiresOn = "expiresOn";
80  const String tenantId = "tenantId_";
81  const String userInfo = "userInfo";
82  const String idToken = "idToken";
83  const String isMultipleResourceRefreshToken = "isMultipleResourceRefreshToken";
84  } JsonNames;
85 
86 };
87 
88 } // namespace rmsauth {
89 
90 #endif // AUTHENTICATIONRESULT_H
Definition: AuthenticationResult.h:21
Definition: OAuth2Response.h:20
Definition: AcquireTokenForClientHandler.h:14