use of org.gluu.oxtrust.model.OxAuthClient in project oxTrust by GluuFederation.
the class ClientPasswordAction method update.
public String update() {
OxAuthClient client = clientService.getClientByDn(updateClientAction.getClient().getDn());
try {
client.setOxAuthClientSecret(newPassword);
} catch (EncryptionException e) {
log.error("Failed to encrypt password", e);
}
clientService.updateClient(client);
// Update client password in action class
updateClientAction.getClient().setEncodedClientSecret(client.getEncodedClientSecret());
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.gluu.oxtrust.model.OxAuthClient in project oxTrust by GluuFederation.
the class UpdateSectorIdentifierAction method updateClients.
private void updateClients(List<DisplayNameEntry> oldClientDisplayNameEntries, List<DisplayNameEntry> newClientDisplayNameEntries) throws Exception {
log.debug("Old clients: {}", oldClientDisplayNameEntries);
log.debug("New clients: {}", newClientDisplayNameEntries);
String sectorIdentifierDn = this.sectorIdentifier.getDn();
// Convert members to array of DNs
String[] oldClientDns = convertToDNsArray(oldClientDisplayNameEntries);
String[] newClientDns = convertToDNsArray(newClientDisplayNameEntries);
Arrays.sort(oldClientDns);
Arrays.sort(newClientDns);
boolean[] retainOldClients = new boolean[oldClientDns.length];
Arrays.fill(retainOldClients, false);
List<String> addedMembers = new ArrayList<String>();
List<String> removedMembers = new ArrayList<String>();
List<String> existingMembers = new ArrayList<String>();
// Add new values
for (String value : newClientDns) {
int idx = Arrays.binarySearch(oldClientDns, value);
if (idx >= 0) {
// Old members array contains member. Retain member
retainOldClients[idx] = true;
} else {
// This is new member
addedMembers.add(value);
}
}
// Remove clients which we don't have in new clients
for (int i = 0; i < oldClientDns.length; i++) {
if (retainOldClients[i]) {
existingMembers.add(oldClientDns[i]);
} else {
removedMembers.add(oldClientDns[i]);
}
}
for (String dn : addedMembers) {
OxAuthClient client = clientService.getClientByDn(dn);
log.debug("Adding sector identifier {} to client {}", sectorIdentifierDn, client.getDisplayName());
client.setSectorIdentifierUri(getSectorIdentifierUrl());
clientService.updateClient(client);
}
for (String dn : removedMembers) {
OxAuthClient client = clientService.getClientByDn(dn);
log.debug("Removing sector identifier {} from client {}", sectorIdentifierDn, client.getDisplayName());
client.setSectorIdentifierUri(null);
clientService.updateClient(client);
}
}
use of org.gluu.oxtrust.model.OxAuthClient in project oxTrust by GluuFederation.
the class UpdateTrustRelationshipAction method saveTR.
private void saveTR(boolean isUpdate) {
log.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(this.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(this.trustRelationship, identity.getCredentials().getUsername());
} else {
trustService.addTrustRelationship(this.trustRelationship);
svnSyncTimer.addTrustRelationship(this.trustRelationship, identity.getCredentials().getUsername());
}
}
use of org.gluu.oxtrust.model.OxAuthClient in project oxTrust by GluuFederation.
the class UpdateResourceAction 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);
}
}
}
use of org.gluu.oxtrust.model.OxAuthClient in project oxTrust by GluuFederation.
the class ClientWebService method update.
@PUT
@Path("/update/{inum}")
@Produces(MediaType.TEXT_PLAIN)
public String update(@PathParam("inum") String inum, OxAuthClient client, @Context HttpServletResponse response) {
try {
// TODO
clientService.updateClient(client);
OxAuthClient updatedClient = clientService.getClientByInum(inum);
ObjectMapper mapper = new ObjectMapper();
String clientJson = mapper.writeValueAsString(updatedClient);
return OxTrustConstants.RESULT_SUCCESS;
} catch (Exception e) {
logger.error("update() Exception", e);
try {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "INTERNAL SERVER ERROR");
} catch (Exception ex) {
}
return OxTrustConstants.RESULT_FAILURE;
}
}
Aggregations