Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2015 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.
  */
 package com.amazonaws.services.securitytoken.model;
 
 
Container for the parameters to the AssumeRoleWithSAML operation.

Returns a set of temporary security credentials for users who have been authenticated via a SAML authentication response. This operation provides a mechanism for tying an enterprise identity store or directory to role-based AWS access without user-specific credentials or configuration.

The temporary security credentials returned by this operation consist of an access key ID, a secret access key, and a security token. Applications can use these temporary security credentials to sign calls to AWS services. The credentials are valid for the duration that you specified when calling AssumeRoleWithSAML , which can be up to 3600 seconds (1 hour) or until the time specified in the SAML authentication response's SessionNotOnOrAfter value, whichever is shorter.

NOTE:The maximum duration for a session is 1 hour, and the minimum duration is 15 minutes, even if values outside this range are specified.

Optionally, you can pass an IAM access policy to this operation. If you choose not to pass a policy, the temporary security credentials that are returned by the operation have the permissions that are defined in the access policy of the role that is being assumed. If you pass a policy to this operation, the temporary security credentials that are returned by the operation have the permissions that are allowed by both the access policy of the role that is being assumed, and the policy that you pass. This gives you a way to further restrict the permissions for the resulting temporary security credentials. You cannot use the passed policy to grant permissions that are in excess of those allowed by the access policy of the role that is being assumed. For more information, see Permissions for AssumeRoleWithSAML in Using Temporary Security Credentials .

Before your application can call AssumeRoleWithSAML , you must configure your SAML identity provider (IdP) to issue the claims required by AWS. Additionally, you must use AWS Identity and Access Management (IAM) to create a SAML provider entity in your AWS account that represents your identity provider, and create an IAM role that specifies this SAML provider in its trust policy.

Calling AssumeRoleWithSAML does not require the use of AWS security credentials. The identity of the caller is validated by using keys in the metadata document that is uploaded for the SAML provider entity for your identity provider.

For more information, see the following resources:

  • Creating Temporary Security Credentials for SAML Federation in Using Temporary Security Credentials .
  • SAML Providers in Using IAM .
  • Configuring a Relying Party and Claims in Using IAM .
  • Creating a Role for SAML-Based Federation in Using IAM .

public class AssumeRoleWithSAMLRequest extends AmazonWebServiceRequest implements SerializableCloneable {

    
The Amazon Resource Name (ARN) of the role that the caller is assuming.

Constraints:
Length: 20 - 2048

    private String roleArn;

    
The Amazon Resource Name (ARN) of the SAML provider in IAM that describes the IdP.

Constraints:
Length: 20 - 2048

    private String principalArn;

    
The base-64 encoded SAML authentication response provided by the IdP.

For more information, see Configuring a Relying Party and Adding Claims in the Using IAM guide.

Constraints:
Length: 4 - 50000

    private String sAMLAssertion;

    
An IAM policy in JSON format.

The policy parameter is optional. If you pass a policy, the temporary security credentials that are returned by the operation have the permissions that are allowed by both the access policy of the role that is being assumed, and the policy that you pass. This gives you a way to further restrict the permissions for the resulting temporary security credentials. You cannot use the passed policy to grant permissions that are in excess of those allowed by the access policy of the role that is being assumed. For more information, see Permissions for AssumeRoleWithSAML in Using Temporary Security Credentials. <note>The policy must be 2048 bytes or shorter, and its packed size must be less than 450 bytes.</note>

Constraints:
Length: 1 - 2048
Pattern: [\u0009\u000A\u000D\u0020-\u00FF]+

    private String policy;

    
The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) to 3600 seconds (1 hour). By default, the value is set to 3600 seconds. An expiration can also be specified in the SAML authentication response's SessionNotOnOrAfter value. The actual expiration time is whichever value is shorter. <note>The maximum duration for a session is 1 hour, and the minimum duration is 15 minutes, even if values outside this range are specified. </note>

Constraints:
Range: 900 - 129600

    private Integer durationSeconds;

    
The Amazon Resource Name (ARN) of the role that the caller is assuming.

Constraints:
Length: 20 - 2048

Returns:
The Amazon Resource Name (ARN) of the role that the caller is assuming.
    public String getRoleArn() {
        return ;
    }
    
    
The Amazon Resource Name (ARN) of the role that the caller is assuming.

Constraints:
Length: 20 - 2048

Parameters:
roleArn The Amazon Resource Name (ARN) of the role that the caller is assuming.
    public void setRoleArn(String roleArn) {
        this. = roleArn;
    }
    
    
The Amazon Resource Name (ARN) of the role that the caller is assuming.

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

Constraints:
Length: 20 - 2048

Parameters:
roleArn The Amazon Resource Name (ARN) of the role that the caller is assuming.
Returns:
A reference to this updated object so that method calls can be chained together.
    public AssumeRoleWithSAMLRequest withRoleArn(String roleArn) {
        this. = roleArn;
        return this;
    }

    
The Amazon Resource Name (ARN) of the SAML provider in IAM that describes the IdP.

Constraints:
Length: 20 - 2048

Returns:
The Amazon Resource Name (ARN) of the SAML provider in IAM that describes the IdP.
    public String getPrincipalArn() {
        return ;
    }
    
    
The Amazon Resource Name (ARN) of the SAML provider in IAM that describes the IdP.

Constraints:
Length: 20 - 2048

Parameters:
principalArn The Amazon Resource Name (ARN) of the SAML provider in IAM that describes the IdP.
    public void setPrincipalArn(String principalArn) {
        this. = principalArn;
    }
    
    
The Amazon Resource Name (ARN) of the SAML provider in IAM that describes the IdP.

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

Constraints:
Length: 20 - 2048

Parameters:
principalArn The Amazon Resource Name (ARN) of the SAML provider in IAM that describes the IdP.
Returns:
A reference to this updated object so that method calls can be chained together.
    public AssumeRoleWithSAMLRequest withPrincipalArn(String principalArn) {
        this. = principalArn;
        return this;
    }

    
The base-64 encoded SAML authentication response provided by the IdP.

For more information, see Configuring a Relying Party and Adding Claims in the Using IAM guide.

Constraints:
Length: 4 - 50000

Returns:
The base-64 encoded SAML authentication response provided by the IdP.

For more information, see Configuring a Relying Party and Adding Claims in the Using IAM guide.

    public String getSAMLAssertion() {
        return ;
    }
    
    
The base-64 encoded SAML authentication response provided by the IdP.

For more information, see Configuring a Relying Party and Adding Claims in the Using IAM guide.

Constraints:
Length: 4 - 50000

Parameters:
sAMLAssertion The base-64 encoded SAML authentication response provided by the IdP.

For more information, see Configuring a Relying Party and Adding Claims in the Using IAM guide.

    public void setSAMLAssertion(String sAMLAssertion) {
        this. = sAMLAssertion;
    }
    
    
The base-64 encoded SAML authentication response provided by the IdP.

For more information, see Configuring a Relying Party and Adding Claims in the Using IAM guide.

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

Constraints:
Length: 4 - 50000

Parameters:
sAMLAssertion The base-64 encoded SAML authentication response provided by the IdP.

For more information, see Configuring a Relying Party and Adding Claims in the Using IAM guide.

Returns:
A reference to this updated object so that method calls can be chained together.
    public AssumeRoleWithSAMLRequest withSAMLAssertion(String sAMLAssertion) {
        this. = sAMLAssertion;
        return this;
    }

    
An IAM policy in JSON format.

The policy parameter is optional. If you pass a policy, the temporary security credentials that are returned by the operation have the permissions that are allowed by both the access policy of the role that is being assumed, and the policy that you pass. This gives you a way to further restrict the permissions for the resulting temporary security credentials. You cannot use the passed policy to grant permissions that are in excess of those allowed by the access policy of the role that is being assumed. For more information, see Permissions for AssumeRoleWithSAML in Using Temporary Security Credentials. <note>The policy must be 2048 bytes or shorter, and its packed size must be less than 450 bytes.</note>

Constraints:
Length: 1 - 2048
Pattern: [\u0009\u000A\u000D\u0020-\u00FF]+

Returns:
An IAM policy in JSON format.

The policy parameter is optional. If you pass a policy, the temporary security credentials that are returned by the operation have the permissions that are allowed by both the access policy of the role that is being assumed, and the policy that you pass. This gives you a way to further restrict the permissions for the resulting temporary security credentials. You cannot use the passed policy to grant permissions that are in excess of those allowed by the access policy of the role that is being assumed. For more information, see Permissions for AssumeRoleWithSAML in Using Temporary Security Credentials. <note>The policy must be 2048 bytes or shorter, and its packed size must be less than 450 bytes.</note>

    public String getPolicy() {
        return ;
    }
    
    
An IAM policy in JSON format.

The policy parameter is optional. If you pass a policy, the temporary security credentials that are returned by the operation have the permissions that are allowed by both the access policy of the role that is being assumed, and the policy that you pass. This gives you a way to further restrict the permissions for the resulting temporary security credentials. You cannot use the passed policy to grant permissions that are in excess of those allowed by the access policy of the role that is being assumed. For more information, see Permissions for AssumeRoleWithSAML in Using Temporary Security Credentials. <note>The policy must be 2048 bytes or shorter, and its packed size must be less than 450 bytes.</note>

Constraints:
Length: 1 - 2048
Pattern: [\u0009\u000A\u000D\u0020-\u00FF]+

Parameters:
policy An IAM policy in JSON format.

The policy parameter is optional. If you pass a policy, the temporary security credentials that are returned by the operation have the permissions that are allowed by both the access policy of the role that is being assumed, and the policy that you pass. This gives you a way to further restrict the permissions for the resulting temporary security credentials. You cannot use the passed policy to grant permissions that are in excess of those allowed by the access policy of the role that is being assumed. For more information, see Permissions for AssumeRoleWithSAML in Using Temporary Security Credentials. <note>The policy must be 2048 bytes or shorter, and its packed size must be less than 450 bytes.</note>

    public void setPolicy(String policy) {
        this. = policy;
    }
    
    
An IAM policy in JSON format.

The policy parameter is optional. If you pass a policy, the temporary security credentials that are returned by the operation have the permissions that are allowed by both the access policy of the role that is being assumed, and the policy that you pass. This gives you a way to further restrict the permissions for the resulting temporary security credentials. You cannot use the passed policy to grant permissions that are in excess of those allowed by the access policy of the role that is being assumed. For more information, see Permissions for AssumeRoleWithSAML in Using Temporary Security Credentials. <note>The policy must be 2048 bytes or shorter, and its packed size must be less than 450 bytes.</note>

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

Constraints:
Length: 1 - 2048
Pattern: [\u0009\u000A\u000D\u0020-\u00FF]+

Parameters:
policy An IAM policy in JSON format.

The policy parameter is optional. If you pass a policy, the temporary security credentials that are returned by the operation have the permissions that are allowed by both the access policy of the role that is being assumed, and the policy that you pass. This gives you a way to further restrict the permissions for the resulting temporary security credentials. You cannot use the passed policy to grant permissions that are in excess of those allowed by the access policy of the role that is being assumed. For more information, see Permissions for AssumeRoleWithSAML in Using Temporary Security Credentials. <note>The policy must be 2048 bytes or shorter, and its packed size must be less than 450 bytes.</note>

Returns:
A reference to this updated object so that method calls can be chained together.
    public AssumeRoleWithSAMLRequest withPolicy(String policy) {
        this. = policy;
        return this;
    }

    
The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) to 3600 seconds (1 hour). By default, the value is set to 3600 seconds. An expiration can also be specified in the SAML authentication response's SessionNotOnOrAfter value. The actual expiration time is whichever value is shorter. <note>The maximum duration for a session is 1 hour, and the minimum duration is 15 minutes, even if values outside this range are specified. </note>

Constraints:
Range: 900 - 129600

Returns:
The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) to 3600 seconds (1 hour). By default, the value is set to 3600 seconds. An expiration can also be specified in the SAML authentication response's SessionNotOnOrAfter value. The actual expiration time is whichever value is shorter. <note>The maximum duration for a session is 1 hour, and the minimum duration is 15 minutes, even if values outside this range are specified. </note>
    public Integer getDurationSeconds() {
        return ;
    }
    
    
The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) to 3600 seconds (1 hour). By default, the value is set to 3600 seconds. An expiration can also be specified in the SAML authentication response's SessionNotOnOrAfter value. The actual expiration time is whichever value is shorter. <note>The maximum duration for a session is 1 hour, and the minimum duration is 15 minutes, even if values outside this range are specified. </note>

Constraints:
Range: 900 - 129600

Parameters:
durationSeconds The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) to 3600 seconds (1 hour). By default, the value is set to 3600 seconds. An expiration can also be specified in the SAML authentication response's SessionNotOnOrAfter value. The actual expiration time is whichever value is shorter. <note>The maximum duration for a session is 1 hour, and the minimum duration is 15 minutes, even if values outside this range are specified. </note>
    public void setDurationSeconds(Integer durationSeconds) {
        this. = durationSeconds;
    }
    
    
The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) to 3600 seconds (1 hour). By default, the value is set to 3600 seconds. An expiration can also be specified in the SAML authentication response's SessionNotOnOrAfter value. The actual expiration time is whichever value is shorter. <note>The maximum duration for a session is 1 hour, and the minimum duration is 15 minutes, even if values outside this range are specified. </note>

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

Constraints:
Range: 900 - 129600

Parameters:
durationSeconds The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) to 3600 seconds (1 hour). By default, the value is set to 3600 seconds. An expiration can also be specified in the SAML authentication response's SessionNotOnOrAfter value. The actual expiration time is whichever value is shorter. <note>The maximum duration for a session is 1 hour, and the minimum duration is 15 minutes, even if values outside this range are specified. </note>
Returns:
A reference to this updated object so that method calls can be chained together.
    public AssumeRoleWithSAMLRequest withDurationSeconds(Integer durationSeconds) {
        this. = durationSeconds;
        return this;
    }

    
Returns a string representation of this object; useful for testing and debugging.

Returns:
A string representation of this object.
See also:
java.lang.Object.toString()
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getRoleArn() != nullsb.append("RoleArn: " + getRoleArn() + ",");
        if (getPrincipalArn() != nullsb.append("PrincipalArn: " + getPrincipalArn() + ",");
        if (getSAMLAssertion() != nullsb.append("SAMLAssertion: " + getSAMLAssertion() + ",");
        if (getPolicy() != nullsb.append("Policy: " + getPolicy() + ",");
        if (getDurationSeconds() != nullsb.append("DurationSeconds: " + getDurationSeconds() );
        sb.append("}");
        return sb.toString();
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;
        
        hashCode = prime * hashCode + ((getRoleArn() == null) ? 0 : getRoleArn().hashCode()); 
        hashCode = prime * hashCode + ((getPrincipalArn() == null) ? 0 : getPrincipalArn().hashCode()); 
        hashCode = prime * hashCode + ((getSAMLAssertion() == null) ? 0 : getSAMLAssertion().hashCode()); 
        hashCode = prime * hashCode + ((getPolicy() == null) ? 0 : getPolicy().hashCode()); 
        hashCode = prime * hashCode + ((getDurationSeconds() == null) ? 0 : getDurationSeconds().hashCode()); 
        return hashCode;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof AssumeRoleWithSAMLRequest == falsereturn false;
        
        if (other.getRoleArn() == null ^ this.getRoleArn() == nullreturn false;
        if (other.getRoleArn() != null && other.getRoleArn().equals(this.getRoleArn()) == falsereturn false
        if (other.getPrincipalArn() == null ^ this.getPrincipalArn() == nullreturn false;
        if (other.getPrincipalArn() != null && other.getPrincipalArn().equals(this.getPrincipalArn()) == falsereturn false
        if (other.getSAMLAssertion() == null ^ this.getSAMLAssertion() == nullreturn false;
        if (other.getSAMLAssertion() != null && other.getSAMLAssertion().equals(this.getSAMLAssertion()) == falsereturn false
        if (other.getPolicy() == null ^ this.getPolicy() == nullreturn false;
        if (other.getPolicy() != null && other.getPolicy().equals(this.getPolicy()) == falsereturn false
        if (other.getDurationSeconds() == null ^ this.getDurationSeconds() == nullreturn false;
        if (other.getDurationSeconds() != null && other.getDurationSeconds().equals(this.getDurationSeconds()) == falsereturn false
        return true;
    }
    
    @Override
    public AssumeRoleWithSAMLRequest clone() {
        
            return (AssumeRoleWithSAMLRequestsuper.clone();
    }
}
    
New to GrepCode? Check out our FAQ X