Search in sources :

Example 6 with OxAuthClient

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

the class UpdateScopeDescriptionAction method update.

private String update() {
    if (this.scopeDescription != null) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    log.debug("Loading UMA resource '{}'", this.scopeInum);
    try {
        String scopeDn = scopeDescriptionService.getDnForScopeDescription(this.scopeInum);
        this.scopeDescription = scopeDescriptionService.getScopeDescriptionByDn(scopeDn);
        this.authorizationPolicies = getInitialAuthorizationPolicies();
        List<UmaResource> umaResourceList = resourceSetService.findResourcesByScope(scopeDn);
        if (umaResourceList != null) {
            for (UmaResource umaResource : umaResourceList) {
                List<String> list = umaResource.getClients();
                if (list != null) {
                    clientList = new ArrayList<OxAuthClient>();
                    for (String clientDn : list) {
                        OxAuthClient oxAuthClient = clientService.getClientByDn(clientDn);
                        clientList.add(oxAuthClient);
                    }
                }
            }
        }
    } catch (BaseMappingException ex) {
        log.error("Failed to find scope description '{}'", this.scopeInum, ex);
        return OxTrustConstants.RESULT_FAILURE;
    }
    if (this.scopeDescription == null) {
        log.error("Scope description is null");
        return OxTrustConstants.RESULT_FAILURE;
    }
    initIconImage();
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) OxAuthClient(org.gluu.oxtrust.model.OxAuthClient) UmaResource(org.xdi.oxauth.model.uma.persistence.UmaResource)

Example 7 with OxAuthClient

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

the class ClientWebService method list.

@GET
@Path("/list")
@Produces(MediaType.APPLICATION_JSON)
public String list(@Context HttpServletResponse response) {
    try {
        List<OxAuthClient> clientList = clientService.getAllClients();
        ObjectMapper mapper = new ObjectMapper();
        String clientListJson = mapper.writeValueAsString(clientList);
        response.setStatus(HttpServletResponse.SC_OK);
        return clientListJson;
    } catch (Exception e) {
        logger.error("delete() Exception", e);
        try {
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "INTERNAL SERVER ERROR");
        } catch (Exception ex) {
        }
        return OxTrustConstants.RESULT_FAILURE;
    }
}
Also used : OxAuthClient(org.gluu.oxtrust.model.OxAuthClient) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 8 with OxAuthClient

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

the class ClientWebService method read.

// TODO
@GET
@Path("/read/{inum}")
@Produces(MediaType.APPLICATION_JSON)
public String read(@PathParam("inum") String inum, @Context HttpServletResponse response) {
    try {
        String result = null;
        OxAuthClient client = clientService.getClientByInum(inum);
        // TODO
        ObjectMapper mapper = new ObjectMapper();
        String clientJson = mapper.writeValueAsString(client);
        response.setStatus(HttpServletResponse.SC_OK);
        return clientJson;
    } catch (Exception e) {
        logger.error("read() Exception", e);
        try {
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "INTERNAL SERVER ERROR");
        } catch (Exception ex) {
        }
        return null;
    }
}
Also used : OxAuthClient(org.gluu.oxtrust.model.OxAuthClient) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 9 with OxAuthClient

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

the class ClientService method getClientByIname.

/**
 * returns oxAuthClient by Dn
 *
 * @return oxAuthClient
 */
/**
 * Get Client by iname
 *
 * @param iname
 * @return Client
 */
public OxAuthClient getClientByIname(String iname) {
    OxAuthClient client = new OxAuthClient();
    client.setBaseDn(getDnForClient(null));
    client.setIname(iname);
    List<OxAuthClient> clients = ldapEntryManager.findEntries(client);
    if ((clients != null) && (clients.size() > 0)) {
        return clients.get(0);
    }
    return null;
}
Also used : OxAuthClient(org.gluu.oxtrust.model.OxAuthClient)

Example 10 with OxAuthClient

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

the class SectorIdentifierService method removeSectorIdentifier.

/**
 * Remove sector identifier entry
 *
 * @param sectorIdentifier Sector identifier
 */
public void removeSectorIdentifier(OxAuthSectorIdentifier sectorIdentifier) {
    if (sectorIdentifier.getClientIds() != null) {
        List<String> clientDNs = sectorIdentifier.getClientIds();
        // clear references in Client entries
        for (String clientDN : clientDNs) {
            OxAuthClient client = clientService.getClientByDn(clientDN);
            client.setSectorIdentifierUri(null);
            clientService.updateClient(client);
        }
    }
    ldapEntryManager.remove(sectorIdentifier);
}
Also used : 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