Search in sources :

Example 1 with ClusterSecurityService

use of com.sequenceiq.cloudbreak.cluster.api.ClusterSecurityService in project cloudbreak by hortonworks.

the class ClusterCredentialChangeHandler method accept.

@Override
public void accept(Event<ClusterCredentialChangeRequest> event) {
    ClusterCredentialChangeRequest request = event.getData();
    ClusterCredentialChangeResult result;
    try {
        Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
        ClusterSecurityService clusterSecurityService = clusterApiConnectors.getConnector(stack).clusterSecurityService();
        switch(request.getType()) {
            case REPLACE:
                clusterSecurityService.replaceUserNamePassword(request.getUser(), request.getPassword());
                break;
            case UPDATE:
                clusterSecurityService.updateUserNamePassword(request.getPassword());
                break;
            default:
                throw new UnsupportedOperationException("Ambari credential update request not supported: " + request.getType());
        }
        result = new ClusterCredentialChangeResult(request);
    } catch (Exception e) {
        result = new ClusterCredentialChangeResult(e.getMessage(), e, request);
    }
    eventBus.notify(result.selector(), new Event<>(event.getHeaders(), result));
}
Also used : ClusterCredentialChangeRequest(com.sequenceiq.cloudbreak.reactor.api.event.resource.ClusterCredentialChangeRequest) ClusterCredentialChangeResult(com.sequenceiq.cloudbreak.reactor.api.event.resource.ClusterCredentialChangeResult) ClusterSecurityService(com.sequenceiq.cloudbreak.cluster.api.ClusterSecurityService) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

ClusterSecurityService (com.sequenceiq.cloudbreak.cluster.api.ClusterSecurityService)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 ClusterCredentialChangeRequest (com.sequenceiq.cloudbreak.reactor.api.event.resource.ClusterCredentialChangeRequest)1 ClusterCredentialChangeResult (com.sequenceiq.cloudbreak.reactor.api.event.resource.ClusterCredentialChangeResult)1