Java 类com.amazonaws.services.securitytoken.model.GetFederationTokenRequest 实例源码

项目:tdl-auth    文件:FederatedUserCredentialsProvider.java   
public FederatedUserCredentials getFederatedTokenFor(String username) {
    Policy policy = DefaultS3FolderPolicy.getForUser(bucket, username);
    GetFederationTokenRequest getFederationTokenRequest = new GetFederationTokenRequest()
            .withName(username)
            .withDurationSeconds(TEMPORARY_CREDENTIALS_VALIDITY)
            .withPolicy(policy.toJson());
    GetFederationTokenResult federationTokenResult = tokenService.getFederationToken(getFederationTokenRequest);
    return new FederatedUserCredentials(region, bucket, username, federationTokenResult.getCredentials());
}
项目:reinvent2013-mobile-photo-share    文件:TemporaryCredentialManagement.java   
/**
 * Retrieves temporary credentials for the given user.
 * 
 * @param username
 *            a given user name
 * @return temporary AWS credentials
 * @throws DataAccessException
 *             When it fails to get federation token from STS
 */
public Credentials getTemporaryCredentials(String username) throws DataAccessException {
    GetFederationTokenRequest getFederationTokenRequest = new GetFederationTokenRequest();
    getFederationTokenRequest.setName(username);
    getFederationTokenRequest.setPolicy(getPolicyObject());
    getFederationTokenRequest.setDurationSeconds(new Integer(Configuration.SESSION_DURATION));

    try {
        return sts.getFederationToken(getFederationTokenRequest).getCredentials();
    } catch (AmazonClientException e) {
        throw new DataAccessException("Failed to get federation token for user: " + username, e);
    }
}
项目:reinvent2013-mobile-photo-share    文件:TemporaryCredentialManagement.java   
/**
 * Retrieves temporary credentials for the given user.
 * 
 * @param username
 *            a given user name
 * @return temporary AWS credentials
 * @throws DataAccessException
 *             When it fails to get federation token from STS
 */
public Credentials getTemporaryCredentials(String username) throws DataAccessException {
    GetFederationTokenRequest getFederationTokenRequest = new GetFederationTokenRequest();
    getFederationTokenRequest.setName(username);
    getFederationTokenRequest.setPolicy(getPolicyObject(username));
    getFederationTokenRequest.setDurationSeconds(new Integer(Configuration.SESSION_DURATION));

    try {
        return sts.getFederationToken(getFederationTokenRequest).getCredentials();
    } catch (AmazonClientException e) {
        throw new DataAccessException("Failed to get federation token for user: " + username, e);
    }
}