Search in sources :

Example 6 with Credential

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

the class StackSensitiveDataPropagator method propagate.

public Stack propagate(CredentialSourceRequest credentialSourceRequest, Stack stack, IdentityUser user) {
    if (credentialSourceRequest != null) {
        Credential decorate = credentialSourceDecorator.decorate(stack.getCredential(), credentialSourceRequest, user);
        stack.setCredential(decorate);
    }
    return stack;
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential)

Example 7 with Credential

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

the class ExtendedCloudCredentialToCredentialConverter method convert.

public Credential convert(ExtendedCloudCredential extendedCloudCredential) {
    Credential credential = new Credential();
    credential.setId(extendedCloudCredential.getId());
    credential.setName(extendedCloudCredential.getName());
    credential.setDescription(extendedCloudCredential.getDescription());
    credential.setAccount(extendedCloudCredential.getAccount());
    credential.setOwner(extendedCloudCredential.getOwner());
    credential.setCloudPlatform(extendedCloudCredential.getCloudPlatform());
    try {
        Json json = new Json(extendedCloudCredential.getParameters());
        credential.setAttributes(json);
    } catch (JsonProcessingException e) {
        throw new IllegalStateException(e);
    }
    return credential;
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential) ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) Json(com.sequenceiq.cloudbreak.domain.json.Json) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 8 with Credential

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

the class StackDecorator method prepareCredential.

private void prepareCredential(Stack subject, StackRequest request, IdentityUser user) {
    if (subject.getCredential() == null) {
        if (request.getCredentialId() != null) {
            Credential credential = credentialService.get(request.getCredentialId());
            subject.setCredential(credential);
        }
        if (request.getCredentialName() != null) {
            Credential credential = credentialService.getPublicCredential(request.getCredentialName(), user);
            subject.setCredential(credential);
        }
    }
    subject.setParameters(getValidParameters(subject, request));
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential)

Example 9 with Credential

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

the class CredentialService method getPrivateCredential.

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

Example 10 with Credential

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

the class CredentialService method modify.

@Transactional(TxType.NEVER)
public Credential modify(IdentityUser user, Credential credential) {
    LOGGER.debug("Modifying credential: [User: '{}', Account: '{}']", user.getUsername(), user.getAccount());
    Credential credentialToModify = credential.isPublicInAccount() ? getPublicCredential(credential.getName(), user) : getPrivateCredential(credential.getName(), user);
    authorizationService.hasWritePermission(credentialToModify);
    if (!credentialToModify.cloudPlatform().equals(credential.cloudPlatform())) {
        throw new BadRequestException("Modifying credential platform is forbidden");
    }
    if (credential.getAttributes() != null) {
        credentialToModify.setAttributes(credential.getAttributes());
    }
    if (credential.getDescription() != null) {
        credentialToModify.setDescription(credential.getDescription());
    }
    if (credential.getTopology() != null) {
        credentialToModify.setTopology(credential.getTopology());
    }
    return saveCredentialAndNotify(credentialToModify, ResourceEvent.CREDENTIAL_MODIFIED);
}
Also used : Credential(com.sequenceiq.cloudbreak.domain.Credential) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) Transactional(javax.transaction.Transactional)

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