use of com.sequenceiq.cloudbreak.domain.Credential in project cloudbreak by hortonworks.
the class CredentialService method getPublicCredential.
public Credential getPublicCredential(String name, IdentityUser user) {
Credential credential = credentialRepository.findOneByName(name, user.getAccount());
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 delete.
@Transactional(TxType.NEVER)
public void delete(Long id, IdentityUser user) {
Credential credential = credentialRepository.findByIdInAccount(id, user.getAccount());
if (credential == null) {
throw new AccessDeniedException(String.format("Access is denied: Credential '%d'.", id));
}
delete(credential);
}
use of com.sequenceiq.cloudbreak.domain.Credential in project cloudbreak by hortonworks.
the class CredentialService method delete.
@Transactional(TxType.NEVER)
public void delete(String name, IdentityUser user) {
Credential credential = credentialRepository.findByNameInAccount(name, user.getAccount(), user.getUserId());
if (credential == null) {
throw new AccessDeniedException(String.format("Access is denied: Credential '%s'.", name));
}
delete(credential);
}
use of com.sequenceiq.cloudbreak.domain.Credential in project cloudbreak by hortonworks.
the class ServiceTestUtils method createCredential.
public static Credential createCredential(String owner, String account, String platform) {
switch(platform) {
case AWS:
Credential awsCredential = new Credential();
awsCredential.setId(1L);
awsCredential.setOwner(owner);
awsCredential.setCloudPlatform(platform);
awsCredential.setAccount(account);
awsCredential.setPublicInAccount(true);
return awsCredential;
case GCP:
Credential gcpCredential = new Credential();
gcpCredential.setId(1L);
gcpCredential.setOwner(owner);
gcpCredential.setCloudPlatform(platform);
gcpCredential.setAccount(account);
gcpCredential.setPublicInAccount(true);
return gcpCredential;
default:
return null;
}
}
use of com.sequenceiq.cloudbreak.domain.Credential in project cloudbreak by hortonworks.
the class CredentialServiceTest method testModifyDifferentPlatform.
@Test
public void testModifyDifferentPlatform() {
Credential credential = new Credential();
credential.setCloudPlatform("BAD");
thrown.expect(BadRequestException.class);
thrown.expectMessage("Modifying credential platform is forbidden");
credentialService.modify(user, credential);
}
Aggregations