Search in sources :

Example 16 with OxAuthClient

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

the class TrustRelationshipWebService method saveTR.

private void saveTR(GluuSAMLTrustRelationship trustRelationship, boolean isUpdate) {
    logger.trace("Saving Trust Relationship");
    if (isUpdate) {
        String oldLogoutRedirectUri = trustService.getRelationshipByDn(trustRelationship.getDn()).getSpLogoutURL();
        String newLogoutRedirectUri = trustRelationship.getSpLogoutURL();
        boolean oxClientUpdateNeeded = (oldLogoutRedirectUri != null) && (newLogoutRedirectUri != null) && !newLogoutRedirectUri.equals(oldLogoutRedirectUri);
        boolean parentInactive = trustRelationship.getStatus().equals(GluuStatus.INACTIVE);
        // if(! federatedSites.isEmpty()){
        // for (GluuSAMLTrustRelationship trust : federatedSites) {
        // if (parentInactive) {
        // trust.setStatus(GluuStatus.INACTIVE);
        // }
        // trustService.updateReleasedAttributes(trust);
        // trustService.updateTrustRelationship(trust);
        // svnSyncTimer.updateTrustRelationship(trust, identity.getCredentials().getUsername());
        // }
        // }
        trustService.updateTrustRelationship(trustRelationship);
        if (oxClientUpdateNeeded) {
            OxAuthClient client = clientService.getClientByInum(appConfiguration.getOxAuthClientId());
            Set<String> updatedLogoutRedirectUris = new HashSet<String>();
            List<GluuSAMLTrustRelationship> trs = trustService.getAllTrustRelationships();
            if (trs != null && !trs.isEmpty()) {
                for (GluuSAMLTrustRelationship tr : trs) {
                    String logoutRedirectUri = tr.getSpLogoutURL();
                    if (logoutRedirectUri != null && !logoutRedirectUri.isEmpty()) {
                        updatedLogoutRedirectUris.add(logoutRedirectUri);
                    }
                }
            }
            if (updatedLogoutRedirectUris.isEmpty()) {
                client.setPostLogoutRedirectUris(null);
            } else {
                client.setPostLogoutRedirectUris(updatedLogoutRedirectUris.toArray(new String[0]));
            }
            clientService.updateClient(client);
        }
        svnSyncTimer.updateTrustRelationship(trustRelationship, identity.getCredentials().getUsername());
    } else {
        trustService.addTrustRelationship(trustRelationship);
        svnSyncTimer.addTrustRelationship(trustRelationship, identity.getCredentials().getUsername());
    }
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) OxAuthClient(org.gluu.oxtrust.model.OxAuthClient) HashSet(java.util.HashSet)

Example 17 with OxAuthClient

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

the class ClientService method generateInumForNewClient.

/**
 * Generate new inum for client
 *
 * @return New inum for client
 */
public String generateInumForNewClient() {
    OxAuthClient client = new OxAuthClient();
    String newInum = null;
    do {
        newInum = generateInumForNewClientImpl();
        String newDn = getDnForClient(newInum);
        client.setDn(newDn);
    } while (ldapEntryManager.contains(client));
    return newInum;
}
Also used : OxAuthClient(org.gluu.oxtrust.model.OxAuthClient)

Example 18 with OxAuthClient

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

the class ClientService method searchClients.

/**
 * Search clients by pattern
 *
 * @param pattern   Pattern
 * @param sizeLimit Maximum count of results
 * @return List of clients
 */
public List<OxAuthClient> searchClients(String pattern, int sizeLimit) {
    String[] targetArray = new String[] { pattern };
    Filter displayNameFilter = Filter.createSubstringFilter(OxTrustConstants.displayName, null, targetArray, null);
    Filter descriptionFilter = Filter.createSubstringFilter(OxTrustConstants.description, null, targetArray, null);
    Filter inameFilter = Filter.createSubstringFilter(OxTrustConstants.iname, null, targetArray, null);
    Filter inumFilter = Filter.createSubstringFilter(OxTrustConstants.inum, null, targetArray, null);
    Filter searchFilter = Filter.createORFilter(displayNameFilter, descriptionFilter, inameFilter, inumFilter);
    List<OxAuthClient> result = ldapEntryManager.findEntries(getDnForClient(null), OxAuthClient.class, searchFilter, sizeLimit);
    return result;
}
Also used : Filter(org.gluu.search.filter.Filter) OxAuthClient(org.gluu.oxtrust.model.OxAuthClient)

Example 19 with OxAuthClient

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

the class ClientService method getClientByDisplayName.

/**
 * Get client by DisplayName
 *
 * @param DisplayName
 * @return client
 * @throws Exception
 */
public OxAuthClient getClientByDisplayName(String DisplayName) {
    OxAuthClient client = new OxAuthClient();
    client.setBaseDn(getDnForClient(null));
    client.setDisplayName(DisplayName);
    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)

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