コード例 #1
0
 private static Expression <Func <GetRoleCredentialsRequest, bool> > MatchesRequest(
     GetRoleCredentialsRequest expectedRequest)
 {
     return
         (request => request.AccountId == expectedRequest.AccountId &&
          request.AccessToken == expectedRequest.AccessToken &&
          request.RoleName == expectedRequest.RoleName);
 }
コード例 #2
0
 public void AssertGetRoleCredentialsAsyncRequest(GetRoleCredentialsRequest expectedRequest)
 {
     SsoClient.Verify(
         mock => mock.GetRoleCredentialsAsync(
             It.Is <GetRoleCredentialsRequest>(MatchesRequest(expectedRequest)),
             It.IsAny <CancellationToken>()),
         Times.Once);
 }
コード例 #3
0
        /// <summary>
        /// Returns the STS short-term credentials for a given role name that is assigned to the
        /// user.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the GetRoleCredentials service method.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        ///
        /// <returns>The response from the GetRoleCredentials service method, as returned by SSO.</returns>
        /// <exception cref="Amazon.SSO.Model.InvalidRequestException">
        /// Indicates that a problem occurred with the input to the request. For example, a required
        /// parameter might be missing or out of range.
        /// </exception>
        /// <exception cref="Amazon.SSO.Model.ResourceNotFoundException">
        /// The specified resource doesn't exist.
        /// </exception>
        /// <exception cref="Amazon.SSO.Model.TooManyRequestsException">
        /// Indicates that the request is being made too frequently and is more than what the
        /// server can handle.
        /// </exception>
        /// <exception cref="Amazon.SSO.Model.UnauthorizedException">
        /// Indicates that the request is not authorized. This can happen due to an invalid access
        /// token in the request.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/sso-2019-06-10/GetRoleCredentials">REST API Reference for GetRoleCredentials Operation</seealso>
        public virtual Task <GetRoleCredentialsResponse> GetRoleCredentialsAsync(GetRoleCredentialsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = GetRoleCredentialsRequestMarshaller.Instance;
            options.ResponseUnmarshaller = GetRoleCredentialsResponseUnmarshaller.Instance;

            return(InvokeAsync <GetRoleCredentialsResponse>(request, options, cancellationToken));
        }
コード例 #4
0
        internal virtual GetRoleCredentialsResponse GetRoleCredentials(GetRoleCredentialsRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = GetRoleCredentialsRequestMarshaller.Instance;
            options.ResponseUnmarshaller = GetRoleCredentialsResponseUnmarshaller.Instance;

            return(Invoke <GetRoleCredentialsResponse>(request, options));
        }
コード例 #5
0
        /// <summary>
        /// Initiates the asynchronous execution of the GetRoleCredentials operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the GetRoleCredentials operation on AmazonSSOClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        ///
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetRoleCredentials
        ///         operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/sso-2019-06-10/GetRoleCredentials">REST API Reference for GetRoleCredentials Operation</seealso>
        public virtual IAsyncResult BeginGetRoleCredentials(GetRoleCredentialsRequest request, AsyncCallback callback, object state)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = GetRoleCredentialsRequestMarshaller.Instance;
            options.ResponseUnmarshaller = GetRoleCredentialsResponseUnmarshaller.Instance;

            return(BeginInvoke(request, options, callback, state));
        }
コード例 #6
0
        public static async Task <ImmutableCredentials> CredentialsFromSsoAccessTokenAsync(IAmazonSSO client, string accountId,
                                                                                           string roleName, string accessToken,
                                                                                           IDictionary <string, object> additionalProperties)
        {
            var request = new GetRoleCredentialsRequest()
            {
                AccessToken = accessToken,
                AccountId   = accountId,
                RoleName    = roleName,
            };

            InternalSDKUtils.ApplyValues(request, additionalProperties);

            var response = await client.GetRoleCredentialsAsync(request).ConfigureAwait(false);

            DateTime credentialsExpiration =
                AWSSDKUtils.ConvertFromUnixEpochMilliseconds(response.RoleCredentials.Expiration);

            return(new SSOImmutableCredentials(
                       response.RoleCredentials.AccessKeyId,
                       response.RoleCredentials.SecretAccessKey,
                       response.RoleCredentials.SessionToken,
                       credentialsExpiration));
        }
コード例 #7
0
 public void AssertGetRoleCredentialsRequest(GetRoleCredentialsRequest expectedRequest)
 {
     SsoClient.Verify(mock => mock.GetRoleCredentials(It.Is <GetRoleCredentialsRequest>(MatchesRequest(expectedRequest))), Times.Once);
 }