Search in sources :

Example 1 with CredentialOperationException

use of com.sequenceiq.environment.credential.exception.CredentialOperationException in project cloudbreak by hortonworks.

the class CredentialPrerequisiteService method getExperiencePrerequisites.

public Map<String, String> getExperiencePrerequisites(String cloudPlatform) {
    CloudContext cloudContext = CloudContext.Builder.builder().withPlatform(cloudPlatform).withWorkspaceId(TEMP_WORKSPACE_ID).build();
    CredentialExperiencePolicyRequest request = new CredentialExperiencePolicyRequest(cloudContext);
    LOGGER.debug("Triggering event: {}", request);
    eventBus.notify(request.selector(), eventFactory.createEvent(request));
    String message = String.format("Failed to get experience policies for platform '%s': ", cloudPlatform);
    try {
        CredentialExperiencePolicyResult res = request.await();
        LOGGER.debug("Result: {}", res);
        if (res.getStatus() != EventStatus.OK) {
            LOGGER.warn(message, res.getErrorDetails());
            throw new BadRequestException(message + res.getErrorDetails(), res.getErrorDetails());
        }
        return res.getPolicies();
    } catch (InterruptedException e) {
        LOGGER.error(message, e);
        throw new CredentialOperationException(e);
    }
}
Also used : CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) CredentialExperiencePolicyRequest(com.sequenceiq.cloudbreak.cloud.event.credential.CredentialExperiencePolicyRequest) CredentialOperationException(com.sequenceiq.environment.credential.exception.CredentialOperationException) BadRequestException(javax.ws.rs.BadRequestException) CredentialExperiencePolicyResult(com.sequenceiq.cloudbreak.cloud.event.credential.CredentialExperiencePolicyResult)

Example 2 with CredentialOperationException

use of com.sequenceiq.environment.credential.exception.CredentialOperationException in project cloudbreak by hortonworks.

the class CredentialService method getCodeGrantFlowAppLoginUrl.

private String getCodeGrantFlowAppLoginUrl(Credential credential) {
    CodeGrantFlowAttributes azureCodeGrantFlowAttributes = getAzureCodeGrantFlowAttributes(credential);
    Object appLoginUrl = Optional.ofNullable(azureCodeGrantFlowAttributes.getAppLoginUrl()).orElseThrow(() -> new CredentialOperationException("Unable to obtain App login url!"));
    return String.valueOf(appLoginUrl);
}
Also used : CodeGrantFlowAttributes(com.sequenceiq.environment.credential.attributes.azure.CodeGrantFlowAttributes) CredentialOperationException(com.sequenceiq.environment.credential.exception.CredentialOperationException)

Aggregations

CredentialOperationException (com.sequenceiq.environment.credential.exception.CredentialOperationException)2 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)1 CredentialExperiencePolicyRequest (com.sequenceiq.cloudbreak.cloud.event.credential.CredentialExperiencePolicyRequest)1 CredentialExperiencePolicyResult (com.sequenceiq.cloudbreak.cloud.event.credential.CredentialExperiencePolicyResult)1 CodeGrantFlowAttributes (com.sequenceiq.environment.credential.attributes.azure.CodeGrantFlowAttributes)1 BadRequestException (javax.ws.rs.BadRequestException)1