List of usage examples for com.amazonaws.services.ecr AmazonECRClient AmazonECRClient
AmazonECRClient(AwsSyncClientParams clientParams, boolean endpointDiscoveryEnabled)
From source file:com.cloudbees.jenkins.plugins.amazonecr.AmazonECSRegistryCredential.java
License:Open Source License
@NonNull @Override/*from w w w. j av a 2 s. co m*/ public Secret getPassword() { final AmazonWebServicesCredentials credentials = getCredentials(); if (credentials == null) throw new IllegalStateException("Invalid credentials"); final AmazonECRClient client = new AmazonECRClient(credentials.getCredentials(), new ClientConfiguration()); final GetAuthorizationTokenResult authorizationToken = client .getAuthorizationToken(new GetAuthorizationTokenRequest()); final List<AuthorizationData> authorizationData = authorizationToken.getAuthorizationData(); if (authorizationData == null || authorizationData.isEmpty()) { throw new IllegalStateException("Failed to retreive authorization token for Amazon ECR"); } return Secret.fromString(authorizationData.get(0).getAuthorizationToken()); }