Search in sources :

Example 1 with OxAuthClient

use of org.gluu.oxtrust.model.OxAuthClient in project oxTrust by GluuFederation.

the class ClientAssociationWebService method getAssociatedPersons.

@Path("/Client/{cid}")
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getAssociatedPersons(@HeaderParam("Authorization") String authorization, @PathParam("cid") String cid) throws Exception {
    Response authorizationResponse = processAuthorization(authorization);
    if (authorizationResponse != null) {
        return authorizationResponse;
    }
    try {
        log.info("getting the client");
        OxAuthClient client = clientService.getClientByInum(cid);
        if (client == null) {
            // sets HTTP status code 404 Not Found
            return getErrorResponse("Resource " + cid + " not found", Response.Status.NOT_FOUND.getStatusCode());
        }
        log.info("mapping client attributes");
        ClientAssociation clientAssociation = MapperUtil.map(client, null);
        log.info("getting URL");
        URI location = new URI("/ClientAssociation/Client/" + cid);
        log.info("returning response");
        return Response.ok(clientAssociation).location(location).build();
    } catch (EntryPersistenceException ex) {
        log.error("Exception: ", ex);
        return getErrorResponse("Resource " + cid + " not found", Response.Status.NOT_FOUND.getStatusCode());
    } catch (Exception ex) {
        log.error("Exception: ", ex);
        return getErrorResponse(INTERNAL_SERVER_ERROR_MESSAGE, Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
    }
}
Also used : Response(javax.ws.rs.core.Response) OxAuthClient(org.gluu.oxtrust.model.OxAuthClient) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) ClientAssociation(org.gluu.oxtrust.model.association.ClientAssociation) URI(java.net.URI) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with OxAuthClient

use of org.gluu.oxtrust.model.OxAuthClient in project oxTrust by GluuFederation.

the class UpdateSectorIdentifierAction method clientRedirectUriList.

private List<String> clientRedirectUriList(List<String> clientInum) {
    List<String> clientRedirectUri = new ArrayList<String>();
    for (int i = 0; i < clientInum.size(); i++) {
        OxAuthClient OxAuthClient = clientService.getClientByInum(clientInum.get(i));
        clientRedirectUri.addAll(OxAuthClient.getOxAuthRedirectURIs());
    }
    return clientRedirectUri;
}
Also used : OxAuthClient(org.gluu.oxtrust.model.OxAuthClient) ArrayList(java.util.ArrayList)

Example 3 with OxAuthClient

use of org.gluu.oxtrust.model.OxAuthClient in project oxTrust by GluuFederation.

the class UpdateResourceSetAction method acceptSelectClients.

public void acceptSelectClients() {
    Set<String> addedClientInums = getAddedClientsInums();
    for (SelectableEntity<OxAuthClient> availableClient : this.availableClients) {
        OxAuthClient oxAuthClient = availableClient.getEntity();
        String oxAuthClientInum = oxAuthClient.getInum();
        if (availableClient.isSelected() && !addedClientInums.contains(oxAuthClientInum)) {
            addClient(oxAuthClient);
        }
        if (!availableClient.isSelected() && addedClientInums.contains(oxAuthClientInum)) {
            removeClient(oxAuthClientInum);
        }
    }
}
Also used : OxAuthClient(org.gluu.oxtrust.model.OxAuthClient)

Example 4 with OxAuthClient

use of org.gluu.oxtrust.model.OxAuthClient in project oxTrust by GluuFederation.

the class UpdateClientAction method add.

public String add() throws Exception {
    if (this.client != null) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    this.update = false;
    this.client = new OxAuthClient();
    try {
        this.loginUris = getNonEmptyStringList(client.getOxAuthRedirectURIs());
        this.logoutUris = getNonEmptyStringList(client.getOxAuthPostLogoutRedirectURIs());
        this.clientlogoutUris = getNonEmptyStringList(client.getLogoutUri());
        this.scopes = getInitialScopeDisplayNameEntiries();
        this.responseTypes = getInitialResponseTypes();
        this.grantTypes = getInitialGrantTypes();
        this.contacts = getNonEmptyStringList(client.getContacts());
        this.defaultAcrValues = getNonEmptyStringList(client.getDefaultAcrValues());
        this.requestUris = getNonEmptyStringList(client.getRequestUris());
        this.authorizedOrigins = getNonEmptyStringList(client.getAuthorizedOrigins());
        this.claimRedirectURIList = getNonEmptyStringList(client.getClaimRedirectURI());
    } catch (BaseMappingException ex) {
        log.error("Failed to prepare lists", ex);
        facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to add new client");
        conversationService.endConversation();
        return OxTrustConstants.RESULT_FAILURE;
    }
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) OxAuthClient(org.gluu.oxtrust.model.OxAuthClient)

Example 5 with OxAuthClient

use of org.gluu.oxtrust.model.OxAuthClient in project oxTrust by GluuFederation.

the class UpdateResourceAction method update.

private String update() {
    log.debug("Loading UMA resource set '{}'", this.oxId);
    try {
        String resourceDn = umaResourcesService.getDnForResource(this.oxId);
        this.resource = umaResourcesService.getResourceByDn(resourceDn);
    } catch (BaseMappingException ex) {
        log.error("Failed to find resource set '{}'", this.oxId, ex);
        return OxTrustConstants.RESULT_FAILURE;
    }
    if (this.resource == null) {
        log.error("Resource set is null");
        return OxTrustConstants.RESULT_FAILURE;
    }
    this.scopes = getScopesDisplayNameEntries();
    this.clients = getClientDisplayNameEntries();
    List<String> list = this.resource.getClients();
    if (list != null) {
        clientList = new ArrayList<OxAuthClient>();
        for (String clientDn : list) {
            OxAuthClient oxAuthClient = clientService.getClientByDn(clientDn);
            clientList.add(oxAuthClient);
        }
    }
    if (this.resource.getResources() == null) {
        this.resources = new ArrayList<String>();
    } else {
        this.resources = new ArrayList<String>(this.resource.getResources());
    }
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) OxAuthClient(org.gluu.oxtrust.model.OxAuthClient)

Aggregations

OxAuthClient (org.gluu.oxtrust.model.OxAuthClient)19 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 GET (javax.ws.rs.GET)3 BaseMappingException (org.gluu.persist.exception.mapping.BaseMappingException)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 GluuSAMLTrustRelationship (org.gluu.oxtrust.model.GluuSAMLTrustRelationship)2 URI (java.net.URI)1 PUT (javax.ws.rs.PUT)1 Response (javax.ws.rs.core.Response)1 ClientAssociation (org.gluu.oxtrust.model.association.ClientAssociation)1 Filter (org.gluu.search.filter.Filter)1 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)1 UmaResource (org.xdi.oxauth.model.uma.persistence.UmaResource)1 EncryptionException (org.xdi.util.security.StringEncrypter.EncryptionException)1