Search in sources :

Example 1 with CodeGrantFlowAttributes

use of com.sequenceiq.environment.credential.attributes.azure.CodeGrantFlowAttributes in project cloudbreak by hortonworks.

the class CredentialService method updateAuthorizationCodeOfAzureCredential.

private void updateAuthorizationCodeOfAzureCredential(Credential credential, String authorizationCode) {
    try {
        CredentialAttributes credentialAttributes = new Json(credential.getAttributes()).get(CredentialAttributes.class);
        if (credentialAttributes.getAzure() != null && credentialAttributes.getAzure().getCodeGrantFlowBased() != null) {
            CodeGrantFlowAttributes codeGrantFlowAttributes = credentialAttributes.getAzure().getCodeGrantFlowBased();
            codeGrantFlowAttributes.setAuthorizationCode(authorizationCode);
            credential.setAttributes(new Json(credentialAttributes).getValue());
        }
    } catch (IOException e) {
        LOGGER.info("Attributes of credential '{}' could not get from JSON attributes", credential.getName());
    }
}
Also used : CredentialAttributes(com.sequenceiq.environment.credential.attributes.CredentialAttributes) CodeGrantFlowAttributes(com.sequenceiq.environment.credential.attributes.azure.CodeGrantFlowAttributes) Json(com.sequenceiq.cloudbreak.common.json.Json) IOException(java.io.IOException)

Example 2 with CodeGrantFlowAttributes

use of com.sequenceiq.environment.credential.attributes.azure.CodeGrantFlowAttributes in project cloudbreak by hortonworks.

the class CredentialServiceTest method getTestAttributes.

private String getTestAttributes(String state, String deploymentAddress, String url) {
    CodeGrantFlowAttributes codeGrantFlowBased = new CodeGrantFlowAttributes();
    codeGrantFlowBased.setDeploymentAddress(deploymentAddress);
    codeGrantFlowBased.setAppLoginUrl(url);
    codeGrantFlowBased.setCodeGrantFlowState(state);
    codeGrantFlowBased.setAuthorizationCode(CODE);
    return getTestAttributesWithCodeGrantFlow(codeGrantFlowBased);
}
Also used : CodeGrantFlowAttributes(com.sequenceiq.environment.credential.attributes.azure.CodeGrantFlowAttributes)

Example 3 with CodeGrantFlowAttributes

use of com.sequenceiq.environment.credential.attributes.azure.CodeGrantFlowAttributes in project cloudbreak by hortonworks.

the class AzureCredentialV1ParametersToAzureCredentialAttributesConverter method getRoleBased.

private CodeGrantFlowAttributes getRoleBased(RoleBasedRequest roleBased) {
    CodeGrantFlowAttributes response = new CodeGrantFlowAttributes();
    response.setDeploymentAddress(roleBased.getDeploymentAddress());
    return response;
}
Also used : CodeGrantFlowAttributes(com.sequenceiq.environment.credential.attributes.azure.CodeGrantFlowAttributes)

Example 4 with CodeGrantFlowAttributes

use of com.sequenceiq.environment.credential.attributes.azure.CodeGrantFlowAttributes 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

CodeGrantFlowAttributes (com.sequenceiq.environment.credential.attributes.azure.CodeGrantFlowAttributes)4 Json (com.sequenceiq.cloudbreak.common.json.Json)1 CredentialAttributes (com.sequenceiq.environment.credential.attributes.CredentialAttributes)1 CredentialOperationException (com.sequenceiq.environment.credential.exception.CredentialOperationException)1 IOException (java.io.IOException)1