/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using Amazon.Runtime.Internal;
using Amazon.Runtime.Internal.Util;
using Amazon.Runtime.SharedInterfaces;
using System;
using System.Globalization;
using System.Net;
namespace Amazon.Runtime
{
public class AssumeRoleAWSCredentialsOptions
{
///
/// A unique identifier that is used by third parties when assuming roles in their customers' accounts.
///
public string ExternalId { get; set; }
///
/// An IAM policy in JSON format.
///
public string Policy { get; set; }
///
/// The length of time in seconds before the credentials will expire.
///
public int? DurationSeconds { get; set; }
///
/// The proxy settings to use when calling AssumeRole.
///
#if BCL
public WebProxy ProxySettings { get; set; }
#elif NETSTANDARD
public IWebProxy ProxySettings { get; set; }
#endif
///
/// The identification number of the MFA device that is associated with the user who is making the assume-role call.
///
public string MfaSerialNumber { get; set; }
///
/// The value provided by the MFA device, if the trust policy of the role being assumed requires MFA.
///
public string MfaTokenCode
{
get
{
if (String.IsNullOrEmpty(MfaSerialNumber))
{
return null;
}
else if (MfaTokenCodeCallback == null)
{
throw new InvalidOperationException("The MfaSerialNumber has been set but the MfaTokenCodeCallback hasn't. " +
"MfaTokenCodeCallback is required in order to determine the MfaTokenCode when MfaSerialNumber is set.");
}
else
{
return MfaTokenCodeCallback();
}
}
}
///
/// A callback that's used to obtain the MFA token code when the AssumeRoleAWSCredentials are refreshed.
///
public Func MfaTokenCodeCallback { get; set; }
///
/// The source identity specified by the principal that is calling the AssumeRole
/// operation.
///
public string SourceIdentity { get; set; }
}
}