use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class EnvironmentModificationService method changeCredential.
private EnvironmentDto changeCredential(String accountId, String environmentName, EnvironmentChangeCredentialDto dto, Environment environment) {
// CHECKSTYLE:OFF
// TODO: 2019. 06. 03. also we have to check for SDXs and DistroXs what uses the given credential. If there is at least one, we have to update the crn reference
// through the other services
// CHECKSTYLE:ON
Credential credential = credentialService.getByNameForAccountId(dto.getCredentialName(), accountId, ENVIRONMENT);
environment.setCredential(credential);
LOGGER.debug("About to change credential on environment \"{}\"", environmentName);
Environment saved = environmentService.save(environment);
return environmentDtoConverter.environmentToDto(saved);
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class AuditCredentialV1Controller method post.
@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_AUDIT_CREDENTIAL)
public CredentialResponse post(@Valid CredentialRequest request) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
String creator = ThreadBasedUserCrnProvider.getUserCrn();
Credential credential = credentialConverter.convert(request);
credential.setType(AUDIT);
credential.setVerifyPermissions(false);
notify(ResourceEvent.CREDENTIAL_CREATED);
Set<Credential> auditCredentialsByPlatfom = credentialService.listAvailablesByAccountId(accountId, AUDIT).stream().filter(c -> c.getCloudPlatform().equals(credential.getCloudPlatform())).collect(Collectors.toSet());
if (auditCredentialsByPlatfom.isEmpty()) {
return credentialConverter.convert(credentialService.create(credential, accountId, creator, AUDIT));
} else {
throw new BadRequestException(String.format("Audit credential already exist for %s cloud.", credential.getCloudPlatform()));
}
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class AuditCredentialV1Controller method deleteByName.
@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_AUDIT_CREDENTIAL)
public CredentialResponse deleteByName(String name) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
Credential deleted = credentialDeleteService.deleteByName(name, accountId, AUDIT);
notify(ResourceEvent.CREDENTIAL_DELETED);
return credentialConverter.convert(deleted);
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class AuditCredentialV1Controller method put.
@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.MODIFY_AUDIT_CREDENTIAL)
public CredentialResponse put(@Valid EditCredentialRequest credentialRequest) {
Credential credential = credentialConverter.convert(credentialRequest);
credential.setType(AUDIT);
credential = credentialService.updateByAccountId(credential, ThreadBasedUserCrnProvider.getAccountId(), AUDIT);
notify(ResourceEvent.CREDENTIAL_MODIFIED);
return credentialConverter.convert(credential);
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class CredentialV1Controller method getByEnvironmentCrn.
@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_CREDENTIAL_ON_ENVIRONMENT)
public CredentialResponse getByEnvironmentCrn(@TenantAwareParam @ResourceCrn String environmentCrn) {
String accountId = ThreadBasedUserCrnProvider.getAccountId();
Credential credential = credentialService.getByEnvironmentCrnAndAccountId(environmentCrn, accountId, ENVIRONMENT);
return credentialConverter.convert(credential);
}
Aggregations