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());
}
}
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;
}
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;
}
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;
}
Aggregations