Search in sources :

Example 91 with Credential

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

the class AuditCredentialV1Controller method deleteByResourceCrn.

@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_AUDIT_CREDENTIAL)
public CredentialResponse deleteByResourceCrn(String crn) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    Credential deleted = credentialDeleteService.deleteByCrn(crn, accountId, AUDIT);
    notify(ResourceEvent.CREDENTIAL_DELETED);
    return credentialConverter.convert(deleted);
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Example 92 with Credential

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

the class CredentialV1Controller method post.

@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_CREDENTIAL)
public CredentialResponse post(@Valid CredentialRequest request) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    String creator = ThreadBasedUserCrnProvider.getUserCrn();
    Credential credential = credentialConverter.convert(request);
    credential.setType(ENVIRONMENT);
    notify(ResourceEvent.CREDENTIAL_CREATED);
    return credentialConverter.convert(credentialService.create(credential, accountId, creator, ENVIRONMENT));
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Example 93 with Credential

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

the class CredentialV1Controller method put.

@Override
@CheckPermissionByRequestProperty(path = "name", type = NAME, action = EDIT_CREDENTIAL)
public CredentialResponse put(@RequestObject @Valid EditCredentialRequest credentialRequest) {
    Credential credential = credentialConverter.convert(credentialRequest);
    credential.setType(ENVIRONMENT);
    credential = credentialService.updateByAccountId(credential, ThreadBasedUserCrnProvider.getAccountId(), ENVIRONMENT);
    notify(ResourceEvent.CREDENTIAL_MODIFIED);
    return credentialConverter.convert(credential);
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CheckPermissionByRequestProperty(com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty)

Example 94 with Credential

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

the class CredentialV1Controller method authorizeCodeGrantFlow.

@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_CREDENTIAL)
public CredentialResponse authorizeCodeGrantFlow(String platform, String code, String state) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    Credential credential = credentialService.authorizeCodeGrantFlow(code, state, accountId, platform);
    notify(ResourceEvent.CREDENTIAL_CREATED);
    return credentialConverter.convert(credential);
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Example 95 with Credential

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

the class CredentialV1Controller method verifyByName.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.DESCRIBE_CREDENTIAL)
public CredentialResponse verifyByName(@ResourceName String name) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    Credential credential = credentialService.getByNameForAccountId(name, accountId, ENVIRONMENT);
    Credential verifiedCredential = credentialService.verify(credential);
    return credentialConverter.convert(verifiedCredential);
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

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