Search in sources :

Example 36 with Credential

use of com.sequenceiq.cloudbreak.domain.Credential in project cloudbreak by hortonworks.

the class CredentialService method get.

public Credential get(Long id, String account) {
    Credential credential = credentialRepository.findByIdInAccount(id, account);
    if (credential == null) {
        throw new AccessDeniedException(String.format("Access is denied: Credential '%d' in %s account.", id, account));
    }
    authorizationService.hasReadPermission(credential);
    return credential;
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential) AccessDeniedException(org.springframework.security.access.AccessDeniedException)

Example 37 with Credential

use of com.sequenceiq.cloudbreak.domain.Credential in project cloudbreak by hortonworks.

the class CredentialService method get.

public Credential get(Long id) {
    Credential credential = credentialRepository.findOne(id);
    if (credential == null) {
        throw new AccessDeniedException(String.format("Access is denied: Credential '%d'.", id));
    }
    authorizationService.hasReadPermission(credential);
    return credential;
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential) AccessDeniedException(org.springframework.security.access.AccessDeniedException)

Example 38 with Credential

use of com.sequenceiq.cloudbreak.domain.Credential in project cloudbreak by hortonworks.

the class CredentialService method get.

public Credential get(String name, String account) {
    Credential credential = credentialRepository.findOneByName(name, account);
    if (credential == null) {
        throw new AccessDeniedException(String.format("Access is denied: Credential '%s' in %s account.", name, account));
    }
    authorizationService.hasReadPermission(credential);
    return credential;
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential) AccessDeniedException(org.springframework.security.access.AccessDeniedException)

Example 39 with Credential

use of com.sequenceiq.cloudbreak.domain.Credential in project cloudbreak by hortonworks.

the class CredentialService method saveCredentialAndNotify.

private Credential saveCredentialAndNotify(Credential credential, ResourceEvent resourceEvent) {
    credential = credentialAdapter.init(credential);
    Credential savedCredential;
    try {
        savedCredential = credentialRepository.save(credential);
        userProfileCredentialHandler.createProfilePreparation(credential);
        sendCredentialNotification(credential, resourceEvent);
    } catch (DataIntegrityViolationException ex) {
        String msg = String.format("Error with resource [%s], error: [%s]", APIResourceType.CREDENTIAL, getProperSqlErrorMessage(ex));
        throw new BadRequestException(msg);
    }
    return savedCredential;
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException)

Example 40 with Credential

use of com.sequenceiq.cloudbreak.domain.Credential in project cloudbreak by hortonworks.

the class TestUtil method awsCredential.

public static Credential awsCredential() {
    Credential awsCredential = new Credential();
    awsCredential.setPublicInAccount(false);
    awsCredential.setArchived(false);
    awsCredential.setCloudPlatform(AWS);
    awsCredential.setDescription(DUMMY_DESCRIPTION);
    awsCredential.setId(1L);
    awsCredential.setName(DUMMY_NAME);
    return awsCredential;
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential)

Aggregations

Credential (com.sequenceiq.cloudbreak.domain.Credential)44 Test (org.junit.Test)14 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)8 AccessDeniedException (org.springframework.security.access.AccessDeniedException)8 Json (com.sequenceiq.cloudbreak.domain.json.Json)7 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)6 Template (com.sequenceiq.cloudbreak.domain.Template)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 FileSystemConfiguration (com.sequenceiq.cloudbreak.api.model.FileSystemConfiguration)3 FileSystemScriptConfig (com.sequenceiq.cloudbreak.blueprint.filesystem.FileSystemScriptConfig)3 CloudVmTypes (com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes)3 Transactional (javax.transaction.Transactional)3 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)2 GcsFileSystemConfiguration (com.sequenceiq.cloudbreak.api.model.GcsFileSystemConfiguration)2 ExtendedCloudCredential (com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential)2 Platform (com.sequenceiq.cloudbreak.cloud.model.Platform)2 PlatformDisks (com.sequenceiq.cloudbreak.cloud.model.PlatformDisks)2 VmTypeMeta (com.sequenceiq.cloudbreak.cloud.model.VmTypeMeta)2 VolumeParameterConfig (com.sequenceiq.cloudbreak.cloud.model.VolumeParameterConfig)2 RecipeScript (com.sequenceiq.cloudbreak.common.model.recipe.RecipeScript)2