com.amazonaws.services.securitytoken.model
Class GetSessionTokenRequest

java.lang.Object
  extended by com.amazonaws.AmazonWebServiceRequest
      extended by com.amazonaws.services.securitytoken.model.GetSessionTokenRequest
All Implemented Interfaces:
java.io.Serializable

public class GetSessionTokenRequest
extends AmazonWebServiceRequest
implements java.io.Serializable

Container for the parameters to the GetSessionToken operation.

Returns a set of temporary credentials for an AWS account or IAM user. The credentials consist of an access key ID, a secret access key, and a security token. Typically, you use GetSessionToken if you want to use MFA to protect programmatic calls to specific AWS APIs like Amazon EC2 StopInstances . MFA-enabled IAM users would need to call GetSessionToken and submit an MFA code that is associated with their MFA device. Using the temporary security credentials that are returned from the call, IAM users can then make programmatic calls to APIs that require MFA authentication.

The GetSessionToken action must be called by using the long-term AWS security credentials of the AWS account or an IAM user. Credentials that are created by IAM users are valid for the duration that you specify, between 900 seconds (15 minutes) and 129600 seconds (36 hours); credentials that are created by using account credentials have a maximum duration of 3600 seconds (1 hour).

NOTE: We recommend that you do not call GetSessionToken with root account credentials. Instead, follow our best practices by creating one or more IAM users, giving them the necessary permissions, and using IAM users for everyday interaction with AWS.

The permissions associated with the temporary security credentials returned by GetSessionToken are based on the permissions associated with account or IAM user whose credentials are used to call the action. If GetSessionToken is called using root account credentials, the temporary credentials have root account permissions. Similarly, if GetSessionToken is called using the credentials of an IAM user, the temporary credentials have the same permissions as the IAM user.

For more information about using GetSessionToken to create temporary credentials, go to Creating Temporary Credentials to Enable Access for IAM Users in Using Temporary Security Credentials .

See Also:
AWSSecurityTokenService.getSessionToken(GetSessionTokenRequest), Serialized Form

Constructor Summary
GetSessionTokenRequest()
          Default constructor for a new GetSessionTokenRequest object.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.lang.Integer getDurationSeconds()
          The duration, in seconds, that the credentials should remain valid.
 java.lang.String getSerialNumber()
          The identification number of the MFA device that is associated with the IAM user who is making the GetSessionToken call.
 java.lang.String getTokenCode()
          The value provided by the MFA device, if MFA is required.
 int hashCode()
           
 void setDurationSeconds(java.lang.Integer durationSeconds)
          The duration, in seconds, that the credentials should remain valid.
 void setSerialNumber(java.lang.String serialNumber)
          The identification number of the MFA device that is associated with the IAM user who is making the GetSessionToken call.
 void setTokenCode(java.lang.String tokenCode)
          The value provided by the MFA device, if MFA is required.
 java.lang.String toString()
          Returns a string representation of this object; useful for testing and debugging.
 GetSessionTokenRequest withDurationSeconds(java.lang.Integer durationSeconds)
          The duration, in seconds, that the credentials should remain valid.
 GetSessionTokenRequest withSerialNumber(java.lang.String serialNumber)
          The identification number of the MFA device that is associated with the IAM user who is making the GetSessionToken call.
 GetSessionTokenRequest withTokenCode(java.lang.String tokenCode)
          The value provided by the MFA device, if MFA is required.
 
Methods inherited from class com.amazonaws.AmazonWebServiceRequest
copyPrivateRequestParameters, getDelegationToken, getRequestClientOptions, getRequestCredentials, getRequestMetricCollector, setDelegationToken, setRequestCredentials, setRequestMetricCollector, withRequestMetricCollector
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GetSessionTokenRequest

public GetSessionTokenRequest()
Default constructor for a new GetSessionTokenRequest object. Callers should use the setter or fluent setter (with...) methods to initialize this object after creating it.

Method Detail

getDurationSeconds

public java.lang.Integer getDurationSeconds()
The duration, in seconds, that the credentials should remain valid. Acceptable durations for IAM user sessions range from 900 seconds (15 minutes) to 129600 seconds (36 hours), with 43200 seconds (12 hours) as the default. Sessions for AWS account owners are restricted to a maximum of 3600 seconds (one hour). If the duration is longer than one hour, the session for AWS account owners defaults to one hour.

Constraints:
Range: 900 - 129600

Returns:
The duration, in seconds, that the credentials should remain valid. Acceptable durations for IAM user sessions range from 900 seconds (15 minutes) to 129600 seconds (36 hours), with 43200 seconds (12 hours) as the default. Sessions for AWS account owners are restricted to a maximum of 3600 seconds (one hour). If the duration is longer than one hour, the session for AWS account owners defaults to one hour.

setDurationSeconds

public void setDurationSeconds(java.lang.Integer durationSeconds)
The duration, in seconds, that the credentials should remain valid. Acceptable durations for IAM user sessions range from 900 seconds (15 minutes) to 129600 seconds (36 hours), with 43200 seconds (12 hours) as the default. Sessions for AWS account owners are restricted to a maximum of 3600 seconds (one hour). If the duration is longer than one hour, the session for AWS account owners defaults to one hour.

Constraints:
Range: 900 - 129600

Parameters:
durationSeconds - The duration, in seconds, that the credentials should remain valid. Acceptable durations for IAM user sessions range from 900 seconds (15 minutes) to 129600 seconds (36 hours), with 43200 seconds (12 hours) as the default. Sessions for AWS account owners are restricted to a maximum of 3600 seconds (one hour). If the duration is longer than one hour, the session for AWS account owners defaults to one hour.

withDurationSeconds

public GetSessionTokenRequest withDurationSeconds(java.lang.Integer durationSeconds)
The duration, in seconds, that the credentials should remain valid. Acceptable durations for IAM user sessions range from 900 seconds (15 minutes) to 129600 seconds (36 hours), with 43200 seconds (12 hours) as the default. Sessions for AWS account owners are restricted to a maximum of 3600 seconds (one hour). If the duration is longer than one hour, the session for AWS account owners defaults to one hour.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Range: 900 - 129600

Parameters:
durationSeconds - The duration, in seconds, that the credentials should remain valid. Acceptable durations for IAM user sessions range from 900 seconds (15 minutes) to 129600 seconds (36 hours), with 43200 seconds (12 hours) as the default. Sessions for AWS account owners are restricted to a maximum of 3600 seconds (one hour). If the duration is longer than one hour, the session for AWS account owners defaults to one hour.
Returns:
A reference to this updated object so that method calls can be chained together.

getSerialNumber

public java.lang.String getSerialNumber()
The identification number of the MFA device that is associated with the IAM user who is making the GetSessionToken call. Specify this value if the IAM user has a policy that requires MFA authentication. The value is either the serial number for a hardware device (such as GAHT12345678) or an Amazon Resource Name (ARN) for a virtual device (such as arn:aws:iam::123456789012:mfa/user). You can find the device for an IAM user by going to the AWS Management Console and viewing the user's security credentials.

Constraints:
Length: 9 - 256
Pattern: [\w+=/:,.@-]*

Returns:
The identification number of the MFA device that is associated with the IAM user who is making the GetSessionToken call. Specify this value if the IAM user has a policy that requires MFA authentication. The value is either the serial number for a hardware device (such as GAHT12345678) or an Amazon Resource Name (ARN) for a virtual device (such as arn:aws:iam::123456789012:mfa/user). You can find the device for an IAM user by going to the AWS Management Console and viewing the user's security credentials.

setSerialNumber

public void setSerialNumber(java.lang.String serialNumber)
The identification number of the MFA device that is associated with the IAM user who is making the GetSessionToken call. Specify this value if the IAM user has a policy that requires MFA authentication. The value is either the serial number for a hardware device (such as GAHT12345678) or an Amazon Resource Name (ARN) for a virtual device (such as arn:aws:iam::123456789012:mfa/user). You can find the device for an IAM user by going to the AWS Management Console and viewing the user's security credentials.

Constraints:
Length: 9 - 256
Pattern: [\w+=/:,.@-]*

Parameters:
serialNumber - The identification number of the MFA device that is associated with the IAM user who is making the GetSessionToken call. Specify this value if the IAM user has a policy that requires MFA authentication. The value is either the serial number for a hardware device (such as GAHT12345678) or an Amazon Resource Name (ARN) for a virtual device (such as arn:aws:iam::123456789012:mfa/user). You can find the device for an IAM user by going to the AWS Management Console and viewing the user's security credentials.

withSerialNumber

public GetSessionTokenRequest withSerialNumber(java.lang.String serialNumber)
The identification number of the MFA device that is associated with the IAM user who is making the GetSessionToken call. Specify this value if the IAM user has a policy that requires MFA authentication. The value is either the serial number for a hardware device (such as GAHT12345678) or an Amazon Resource Name (ARN) for a virtual device (such as arn:aws:iam::123456789012:mfa/user). You can find the device for an IAM user by going to the AWS Management Console and viewing the user's security credentials.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 9 - 256
Pattern: [\w+=/:,.@-]*

Parameters:
serialNumber - The identification number of the MFA device that is associated with the IAM user who is making the GetSessionToken call. Specify this value if the IAM user has a policy that requires MFA authentication. The value is either the serial number for a hardware device (such as GAHT12345678) or an Amazon Resource Name (ARN) for a virtual device (such as arn:aws:iam::123456789012:mfa/user). You can find the device for an IAM user by going to the AWS Management Console and viewing the user's security credentials.
Returns:
A reference to this updated object so that method calls can be chained together.

getTokenCode

public java.lang.String getTokenCode()
The value provided by the MFA device, if MFA is required. If any policy requires the IAM user to submit an MFA code, specify this value. If MFA authentication is required, and the user does not provide a code when requesting a set of temporary security credentials, the user will receive an "access denied" response when requesting resources that require MFA authentication.

Constraints:
Length: 6 - 6
Pattern: [\d]*

Returns:
The value provided by the MFA device, if MFA is required. If any policy requires the IAM user to submit an MFA code, specify this value. If MFA authentication is required, and the user does not provide a code when requesting a set of temporary security credentials, the user will receive an "access denied" response when requesting resources that require MFA authentication.

setTokenCode

public void setTokenCode(java.lang.String tokenCode)
The value provided by the MFA device, if MFA is required. If any policy requires the IAM user to submit an MFA code, specify this value. If MFA authentication is required, and the user does not provide a code when requesting a set of temporary security credentials, the user will receive an "access denied" response when requesting resources that require MFA authentication.

Constraints:
Length: 6 - 6
Pattern: [\d]*

Parameters:
tokenCode - The value provided by the MFA device, if MFA is required. If any policy requires the IAM user to submit an MFA code, specify this value. If MFA authentication is required, and the user does not provide a code when requesting a set of temporary security credentials, the user will receive an "access denied" response when requesting resources that require MFA authentication.

withTokenCode

public GetSessionTokenRequest withTokenCode(java.lang.String tokenCode)
The value provided by the MFA device, if MFA is required. If any policy requires the IAM user to submit an MFA code, specify this value. If MFA authentication is required, and the user does not provide a code when requesting a set of temporary security credentials, the user will receive an "access denied" response when requesting resources that require MFA authentication.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 6 - 6
Pattern: [\d]*

Parameters:
tokenCode - The value provided by the MFA device, if MFA is required. If any policy requires the IAM user to submit an MFA code, specify this value. If MFA authentication is required, and the user does not provide a code when requesting a set of temporary security credentials, the user will receive an "access denied" response when requesting resources that require MFA authentication.
Returns:
A reference to this updated object so that method calls can be chained together.

toString

public java.lang.String toString()
Returns a string representation of this object; useful for testing and debugging.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this object.
See Also:
Object.toString()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


Copyright © 2010 Amazon Web Services, Inc. All Rights Reserved.