/** * Method will return valid session credentials or throw an AmazonClientException due to STS * service time-out or thread interruption. The first call will block until valid session * credentials are fetched. Subsequent calls will re-use fetched credentials that are still * valid. Expiring credentials are automatically refreshed via a background thread. Multiple * threads may call this method concurrently without causing simultaneous network calls to the * STS service. Care has been taken to resist Throttling exceptions. */ @Override public AWSSessionCredentials getCredentials() { return refreshableTask.getValue().getSessionCredentials(); }
@Override public boolean test(SessionCredentialsHolder sessionCredentialsHolder) { Date expiryTime = sessionCredentialsHolder.getSessionCredentialsExpiration(); if (expiryTime != null) { long timeRemaining = expiryTime.getTime() - System.currentTimeMillis(); return timeRemaining < ASYNC_REFRESH_EXPIRATION_IN_MILLIS; } return false; } }
private SessionCredentialsHolder newSession() { GetSessionTokenResult sessionTokenResult = securityTokenService.getSessionToken( new GetSessionTokenRequest().withDurationSeconds(DEFAULT_DURATION_SECONDS)); return new SessionCredentialsHolder(sessionTokenResult.getCredentials()); }
/** * Starts a new session by sending a request to the AWS Security Token Service (STS) to assume a * Role using the long lived AWS credentials. This class then vends the short lived session * credentials for the assumed Role sent back from STS. */ private SessionCredentialsHolder newSession() { AssumeRoleRequest assumeRoleRequest = new AssumeRoleRequest().withRoleArn(roleArn) .withDurationSeconds(roleSessionDurationSeconds) .withRoleSessionName(roleSessionName) .withPolicy(scopeDownPolicy); if (roleExternalId != null) { assumeRoleRequest = assumeRoleRequest.withExternalId(roleExternalId); } AssumeRoleResult assumeRoleResult = securityTokenService.assumeRole(assumeRoleRequest); return new SessionCredentialsHolder(assumeRoleResult.getCredentials()); }
@Override public boolean test(SessionCredentialsHolder sessionCredentialsHolder) { return sessionCredentialsHolder == null || expiring(sessionCredentialsHolder.getSessionCredentialsExpiration()); }
@Override public AWSSessionCredentials getCredentials() { return refreshableTask.getValue().getSessionCredentials(); }
private SessionCredentialsHolder newSession() { GetSessionTokenResult sessionTokenResult = securityTokenService.getSessionToken( new GetSessionTokenRequest().withDurationSeconds(DEFAULT_DURATION_SECONDS)); return new SessionCredentialsHolder(sessionTokenResult.getCredentials()); }
@Override public boolean test(SessionCredentialsHolder sessionCredentialsHolder) { Date expiryTime = sessionCredentialsHolder.getSessionCredentialsExpiration(); if (expiryTime != null) { long timeRemaining = expiryTime.getTime() - System.currentTimeMillis(); return timeRemaining < ASYNC_REFRESH_EXPIRATION_IN_MILLIS; } return false; } }
/** * Method will return valid session credentials or throw an AmazonClientException due to STS * service time-out or thread interruption. The first call will block until valid session * credentials are fetched. Subsequent calls will re-use fetched credentials that are still * valid. Expiring credentials are automatically refreshed via a background thread. Multiple * threads may call this method concurrently without causing simultaneous network calls to the * STS service. Care has been taken to resist Throttling exceptions. */ @Override public AWSSessionCredentials getCredentials() { return refreshableTask.getValue().getSessionCredentials(); }
/** * Starts a new session by sending a request to the AWS Security Token Service (STS) to assume a * Role using the long lived AWS credentials. This class then vends the short lived session * credentials for the assumed Role sent back from STS. */ private SessionCredentialsHolder newSession() { AssumeRoleRequest assumeRoleRequest = new AssumeRoleRequest().withRoleArn(roleArn) .withDurationSeconds(roleSessionDurationSeconds) .withRoleSessionName(roleSessionName) .withPolicy(scopeDownPolicy); if (roleExternalId != null) { assumeRoleRequest = assumeRoleRequest.withExternalId(roleExternalId); } AssumeRoleResult assumeRoleResult = securityTokenService.assumeRole(assumeRoleRequest); return new SessionCredentialsHolder(assumeRoleResult.getCredentials()); }
@Override public boolean test(SessionCredentialsHolder sessionCredentialsHolder) { return sessionCredentialsHolder == null || expiring(sessionCredentialsHolder.getSessionCredentialsExpiration()); }
@Override public AWSSessionCredentials getCredentials() { return refreshableTask.getValue().getSessionCredentials(); }