All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cloudfoundry.identity.uaa.zone.IdentityZoneEndpointClientRegistrationService Maven / Gradle / Ivy

package org.cloudfoundry.identity.uaa.zone;

import org.cloudfoundry.identity.uaa.client.ClientDetailsValidator;
import org.cloudfoundry.identity.uaa.client.ClientDetailsValidator.Mode;
import org.cloudfoundry.identity.uaa.approval.ApprovalStore;
import org.springframework.security.oauth2.provider.ClientDetails;

public class IdentityZoneEndpointClientRegistrationService {

    private final ClientServicesExtension clientDetailsService;
    private final ClientDetailsValidator clientDetailsValidator;
    private final ApprovalStore approvalStore;


    public IdentityZoneEndpointClientRegistrationService(ClientServicesExtension clientDetailsService,
                                                         ClientDetailsValidator clientDetailsValidator,
                                                         ApprovalStore approvalStore) {
        super();
        this.clientDetailsService = clientDetailsService;
        this.clientDetailsValidator = clientDetailsValidator;
        this.approvalStore = approvalStore;
    }

    public ClientDetails createClient(ClientDetails clientDetails) {
        ClientDetails validated = clientDetailsValidator.validate(clientDetails, Mode.CREATE);
        clientDetailsService.addClientDetails(validated, IdentityZoneHolder.get().getId());
        return validated;
    }

    public ClientDetails deleteClient(String clientId) {
        String zoneId = IdentityZoneHolder.get().getId();
        ClientDetails clientDetails = clientDetailsService.loadClientByClientId(clientId, zoneId);
        clientDetailsValidator.validate(clientDetails, Mode.DELETE);
        clientDetailsService.removeClientDetails(clientId, zoneId);
        approvalStore.revokeApprovalsForClient(clientId, zoneId);
        return clientDetails;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy