RMS SDK for C++  0.2.1
A client library for using Microsoft RMS from Linux.
AuthenticationCallbackImpl.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 _RMS_LIB_AUTHENTICATIONCALLBACKIMPL_H_
10 #define _RMS_LIB_AUTHENTICATIONCALLBACKIMPL_H_
11 
12 #include "IAuthenticationCallbackImpl.h"
13 #include "IAuthenticationCallback.h"
14 #include "ModernAPIExport.h"
15 
16 namespace rmscore {
17 namespace modernapi {
22 public:
23 
32  const std::string & userId)
33  : m_callback(callback)
34  , m_userId(userId)
35  {}
36 
42  virtual bool NeedsChallenge() const override {
43  return true;
44  }
45 
52  virtual std::string GetAccessToken(const AuthenticationChallenge& challenge)
53  override
54  {
55  auto parameters = std::make_shared<AuthenticationParameters>(
56  challenge.authority,
57  challenge.resource,
58  challenge.scope,
59  m_userId);
60 
61  return m_callback.GetToken(parameters);
62  }
63 
64 private:
65 
66  IAuthenticationCallback& m_callback;
67  std::string m_userId;
68 };
69 } // namespace modernapi
70 } // namespace rmscore
71 
72 #endif // _RMS_LIB_AUTHENTICATIONCALLBACKIMPL_H_
Authentication callback implementation.
Definition: IAuthenticationCallbackImpl.h:41
std::string scope
Scope of the authentication request.
Definition: IAuthenticationCallbackImpl.h:35
std::string authority
Authority with which the request is made.
Definition: IAuthenticationCallbackImpl.h:25
virtual bool NeedsChallenge() const override
False if OAuth coordinates (authority, resource, scope) are already known, True if these should be re...
Definition: AuthenticationCallbackImpl.h:42
Definition: AuthenticationCallbackImpl.h:16
Implementation class for authentication callback.
Definition: AuthenticationCallbackImpl.h:21
Structure for authentication information.
Definition: IAuthenticationCallbackImpl.h:20
Implement this interface to provide an approach for getting an OAuth access token.
Definition: IAuthenticationCallback.h:25
AuthenticationCallbackImpl(IAuthenticationCallback &callback, const std::string &userId)
This class wraps an IAuthenticationCallback implementation to provide OAuth coordinates.
Definition: AuthenticationCallbackImpl.h:31
std::string resource
Resource being requested.
Definition: IAuthenticationCallbackImpl.h:30
virtual std::string GetAccessToken(const AuthenticationChallenge &challenge) override
Prepares AuthenticationParameters from AuthenticationChallenge response, and passes these parameters ...
Definition: AuthenticationCallbackImpl.h:52