@Override
    public AWSCredentials getCredentials() throws SdkBaseException {
        Credentials credentials = AbstractS3DelegationTokenReceiver.getCredentials();
        if (credentials == null) {
            throw new NoAwsCredentialsException(COMPONENT);
        }
        LOG.debug("Providing session credentials");
        return new BasicSessionCredentials(
                credentials.getAccessKeyId(),
                credentials.getSecretAccessKey(),
                credentials.getSessionToken());
    }
@Test
    public void getCredentialsShouldStoreCredentialsWhenCredentialsProvided() throws Exception {
        DynamicTemporaryAWSCredentialsProvider provider =
                new DynamicTemporaryAWSCredentialsProvider();
        Credentials credentials =
                new Credentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY, SESSION_TOKEN, null);
        AbstractS3DelegationTokenReceiver receiver =
                new AbstractS3DelegationTokenReceiver() {
                    @Override
                    public String serviceName() {
                        return "s3";
                    }
                };

        receiver.onNewTokensObtained(InstantiationUtil.serializeObject(credentials));
        BasicSessionCredentials returnedCredentials =
                (BasicSessionCredentials) provider.getCredentials();
        assertEquals(returnedCredentials.getAWSAccessKeyId(), credentials.getAccessKeyId());
        assertEquals(returnedCredentials.getAWSSecretKey(), credentials.getSecretAccessKey());
        assertEquals(returnedCredentials.getSessionToken(), credentials.getSessionToken());
    }