use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateAccessKeyResponse in project cloudbreak by hortonworks.
the class GrpcUmsClient method generateAccessSecretKeyPair.
/**
* Generate access / private keypair
*
* @param actorCrn actor that executes the key generation
* @param machineUserCrn machine user (owner of the access key)
* @param requestId id for the request
* @param accessKeyType algorithm type used for the access key
* @return access / private key holder object
*/
@Retryable(value = UmsOperationException.class, maxAttempts = 10, backoff = @Backoff(delay = 5000))
public AltusCredential generateAccessSecretKeyPair(String actorCrn, String accountId, String machineUserCrn, Optional<String> requestId, AccessKeyType.Value accessKeyType, RegionAwareInternalCrnGeneratorFactory regionAwareInternalCrnGeneratorFactory) {
try {
UmsClient client = makeClient(channelWrapper.getChannel(), regionAwareInternalCrnGeneratorFactory);
LOGGER.info("Generating new access / secret key pair for {}", machineUserCrn);
CreateAccessKeyResponse accessKeyResponse = client.createAccessPrivateKeyPair(RequestIdUtil.getOrGenerate(requestId), actorCrn, accountId, machineUserCrn, accessKeyType);
return new AltusCredential(accessKeyResponse.getAccessKey().getAccessKeyId(), accessKeyResponse.getPrivateKey().toCharArray());
} catch (StatusRuntimeException ex) {
if (Status.UNAVAILABLE.getCode().equals(ex.getStatus().getCode())) {
String errMessage = String.format("Cannot generate access key pair for machine user '%s' as " + "UMS API is UNAVAILABLE at the moment", machineUserCrn);
LOGGER.debug(errMessage, ex);
throw new UmsOperationException(errMessage, ex);
} else {
throw ex;
}
}
}
use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.CreateAccessKeyResponse in project cloudbreak by hortonworks.
the class GrpcUmsClient method generateAccessSecretKeyPair.
/**
* Generate access / private keypair
*
* @param actorCrn actor that executes the key generation
* @param machineUserCrn machine user (owner of the access key)
* @param requestId id for the request
* @param accessKeyType algorithm type used for the access key
* @return access / private key holder object
*/
@Retryable(value = UmsOperationException.class, maxAttempts = 10, backoff = @Backoff(delay = 5000))
public AltusCredential generateAccessSecretKeyPair(String actorCrn, String accountId, String machineUserCrn, Optional<String> requestId, AccessKeyType.Value accessKeyType) {
try {
UmsClient client = makeClient(channelWrapper.getChannel());
LOGGER.info("Generating new access / secret key pair for {}", machineUserCrn);
CreateAccessKeyResponse accessKeyResponse = client.createAccessPrivateKeyPair(RequestIdUtil.getOrGenerate(requestId), actorCrn, accountId, machineUserCrn, accessKeyType);
return new AltusCredential(accessKeyResponse.getAccessKey().getAccessKeyId(), accessKeyResponse.getPrivateKey().toCharArray());
} catch (StatusRuntimeException ex) {
if (Status.UNAVAILABLE.getCode().equals(ex.getStatus().getCode())) {
String errMessage = String.format("Cannot generate access key pair for machine user '%s' as " + "UMS API is UNAVAILABLE at the moment", machineUserCrn);
LOGGER.debug(errMessage, ex);
throw new UmsOperationException(errMessage, ex);
} else {
throw ex;
}
}
}
Aggregations