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;
}
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;
}
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));
}
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;
}
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);
}
Aggregations