Search in sources :

Example 11 with CheckPermissionByAccount

use of com.sequenceiq.authorization.annotation.CheckPermissionByAccount 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);
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Example 12 with CheckPermissionByAccount

use of com.sequenceiq.authorization.annotation.CheckPermissionByAccount 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);
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Example 13 with CheckPermissionByAccount

use of com.sequenceiq.authorization.annotation.CheckPermissionByAccount in project cloudbreak by hortonworks.

the class CredentialV1Controller method initCodeGrantFlow.

@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_CREDENTIAL)
public Response initCodeGrantFlow(CredentialRequest credentialRequest) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
    Credential credential = credentialConverter.convert(credentialRequest);
    credential.setType(ENVIRONMENT);
    String loginURL = credentialService.initCodeGrantFlow(accountId, credential, userCrn);
    return Response.status(Status.FOUND).header("Referrer-Policy", "origin-when-cross-origin").header("Location", loginURL).build();
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Example 14 with CheckPermissionByAccount

use of com.sequenceiq.authorization.annotation.CheckPermissionByAccount in project cloudbreak by hortonworks.

the class CredentialV1Controller method interactiveLogin.

@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.CREATE_CREDENTIAL)
public InteractiveCredentialResponse interactiveLogin(@Valid CredentialRequest credentialRequest) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    Credential credential = credentialConverter.convert(credentialRequest);
    credential.setType(ENVIRONMENT);
    Map<String, String> result = credentialService.interactiveLogin(accountId, credential);
    return new InteractiveCredentialResponse(result.get("user_code"), result.get("verification_url"));
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) InteractiveCredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.InteractiveCredentialResponse) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Example 15 with CheckPermissionByAccount

use of com.sequenceiq.authorization.annotation.CheckPermissionByAccount in project cloudbreak by hortonworks.

the class DatabaseServerV4Controller method register.

@CheckPermissionByAccount(action = AuthorizationResourceAction.REGISTER_DATABASE_SERVER)
public DatabaseServerV4Response register(DatabaseServerV4Request request) {
    MDCBuilder.addEnvironmentCrn(request.getEnvironmentCrn());
    DatabaseServerConfig server = databaseServerConfigService.create(databaseServerV4RequestToDatabaseServerConfigConverter.convert(request), DEFAULT_WORKSPACE, false);
    // notify(ResourceEvent.DATABASE_SERVER_CONFIG_CREATED);
    return databaseServerConfigToDatabaseServerV4ResponseConverter.convert(server);
}
Also used : DatabaseServerConfig(com.sequenceiq.redbeams.domain.DatabaseServerConfig) CheckPermissionByAccount(com.sequenceiq.authorization.annotation.CheckPermissionByAccount)

Aggregations

CheckPermissionByAccount (com.sequenceiq.authorization.annotation.CheckPermissionByAccount)33 Credential (com.sequenceiq.environment.credential.domain.Credential)8 ProxyConfig (com.sequenceiq.environment.proxy.domain.ProxyConfig)4 StackView (com.sequenceiq.cloudbreak.domain.view.StackView)3 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)3 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)3 SdxClusterResponse (com.sequenceiq.sdx.api.model.SdxClusterResponse)3 PageRequest (org.springframework.data.domain.PageRequest)3 AuthorizationResourceAction (com.sequenceiq.authorization.resource.AuthorizationResourceAction)2 AccountId (com.sequenceiq.cloudbreak.auth.security.internal.AccountId)2 TenantAwareParam (com.sequenceiq.cloudbreak.auth.security.internal.TenantAwareParam)2 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)2 ProxyResponse (com.sequenceiq.environment.api.v1.proxy.model.response.ProxyResponse)2 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)2 Controller (org.springframework.stereotype.Controller)2 CheckPermissionByRequestProperty (com.sequenceiq.authorization.annotation.CheckPermissionByRequestProperty)1 EventV4Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v4.events.EventV4Endpoint)1 CloudbreakEventV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.events.responses.CloudbreakEventV4Response)1 CloudbreakEventV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.events.responses.CloudbreakEventV4Responses)1 ResourceEventResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.ResourceEventResponse)1