Search in sources :

Example 96 with Credential

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

the class CredentialV1Controller method deleteByName.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.DELETE_CREDENTIAL)
public CredentialResponse deleteByName(@ResourceName String name) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    Credential deleted = credentialDeleteService.deleteByName(name, accountId, ENVIRONMENT);
    notify(ResourceEvent.CREDENTIAL_DELETED);
    return credentialConverter.convert(deleted);
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 97 with Credential

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

the class CredentialV1Controller method getByEnvironmentName.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.DESCRIBE_CREDENTIAL_ON_ENVIRONMENT)
public CredentialResponse getByEnvironmentName(@ResourceName String environmentName) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    Credential credential = credentialService.getByEnvironmentNameAndAccountId(environmentName, accountId, ENVIRONMENT);
    return credentialConverter.convert(credential);
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 98 with Credential

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

the class CredentialToCredentialV1ResponseConverter method convert.

public Credential convert(EditCredentialRequest source) {
    if (source == null) {
        return null;
    }
    Credential credential = new Credential();
    credential.setName(Strings.isNullOrEmpty(source.getName()) ? UUID.randomUUID().toString() : source.getName());
    credential.setDescription(source.getDescription());
    credential.setCloudPlatform(source.getCloudPlatform());
    credential.setVerificationStatusText(source.getVerificationStatusText());
    credential.setVerifyPermissions(source.isVerifyPermissions());
    convertAttributes(source, credential);
    if (source.getAws() != null) {
        credential.setGovCloud(source.getAws().getGovCloud());
    }
    return credential;
}
Also used : ExtendedCloudCredential(com.sequenceiq.cloudbreak.cloud.model.ExtendedCloudCredential) Credential(com.sequenceiq.environment.credential.domain.Credential)

Example 99 with Credential

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

the class CredentialV1RequestToCredentialConverter method convert.

public Credential convert(CredentialRequest source) {
    Credential credential = new Credential();
    credential.setName(Strings.isNullOrEmpty(source.getName()) ? UUID.randomUUID().toString() : source.getName());
    credential.setDescription(source.getDescription());
    credential.setCloudPlatform(source.getCloudPlatform());
    credential.setVerificationStatusText(source.getVerificationStatusText());
    convertAttributes(source, credential);
    if (source.getAws() != null) {
        credential.setGovCloud(source.getAws().getGovCloud());
    }
    return credential;
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential)

Example 100 with Credential

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

the class CredentialService method updateByAccountId.

public Credential updateByAccountId(Credential credential, String accountId, CredentialType type) {
    Credential original = getCredentialAndValidateUpdate(credential, accountId, type);
    credential.setId(original.getId());
    credential.setAccountId(accountId);
    credential.setResourceCrn(original.getResourceCrn());
    credential.setCreator(original.getCreator());
    Credential updated = repository.save(credentialAdapter.verify(credential, accountId).getCredential());
    secretService.delete(original.getAttributesSecret());
    sendCredentialNotification(credential, ResourceEvent.CREDENTIAL_MODIFIED);
    return updated;
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential)

Aggregations

Credential (com.sequenceiq.environment.credential.domain.Credential)102 Test (org.junit.jupiter.api.Test)49 Environment (com.sequenceiq.environment.environment.domain.Environment)27 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)23 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)13 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)10 ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)9 EnvironmentAuthentication (com.sequenceiq.environment.environment.domain.EnvironmentAuthentication)9 EnvironmentCreationDto (com.sequenceiq.environment.environment.dto.EnvironmentCreationDto)9 BadRequestException (javax.ws.rs.BadRequestException)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 CheckPermissionByAccount (com.sequenceiq.authorization.annotation.CheckPermissionByAccount)8 ParametersDto (com.sequenceiq.environment.parameter.dto.ParametersDto)8 Set (java.util.Set)8 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)7 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)7 AwsNetwork (com.sequenceiq.environment.network.dao.domain.AwsNetwork)7 Map (java.util.Map)7 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)6 BaseNetwork (com.sequenceiq.environment.network.dao.domain.BaseNetwork)6