use of org.gluu.oxtrust.model.OrganizationalUnit in project oxTrust by GluuFederation.
the class TrustService method addTrustRelationship.
public void addTrustRelationship(GluuSAMLTrustRelationship trustRelationship) {
log.info("Creating TR " + trustRelationship.getInum());
String[] clusterMembers = appConfiguration.getClusteredInums();
String applianceInum = appConfiguration.getApplianceInum();
if (clusterMembers == null || clusterMembers.length == 0) {
log.debug("there is no cluster configuration. Assuming standalone appliance.");
clusterMembers = new String[] { applianceInum };
}
String dn = trustRelationship.getDn();
for (String clusterMember : clusterMembers) {
String clusteredDN = StringHelper.replaceLast(dn, applianceInum, clusterMember);
trustRelationship.setDn(clusteredDN);
GluuSAMLTrustRelationship tr = new GluuSAMLTrustRelationship();
tr.setDn(trustRelationship.getDn());
if (!containsTrustRelationship(tr)) {
log.debug("Adding TR" + clusteredDN);
OrganizationalUnit ou = new OrganizationalUnit();
ou.setDn(getDnForTrustRelationShip(null));
if (!ldapEntryManager.contains(ou)) {
ldapEntryManager.persist(ou);
}
ldapEntryManager.persist(trustRelationship);
} else {
ldapEntryManager.merge(trustRelationship);
}
}
trustRelationship.setDn(dn);
}
use of org.gluu.oxtrust.model.OrganizationalUnit in project oxTrust by GluuFederation.
the class PasswordReminderAction method requestReminder.
public String requestReminder() throws Exception {
if (enabled()) {
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext == null) {
return OxTrustConstants.RESULT_FAILURE;
}
ExternalContext externalContext = facesContext.getExternalContext();
if (externalContext == null) {
return OxTrustConstants.RESULT_FAILURE;
}
HttpServletRequest httpServletRequest = (HttpServletRequest) externalContext.getRequest();
GluuCustomPerson person = new GluuCustomPerson();
person.setMail(email);
List<GluuCustomPerson> matchedPersons = personService.findPersons(person, 0);
if (matchedPersons != null && matchedPersons.size() > 0) {
GluuAppliance appliance = applianceService.getAppliance();
OrganizationalUnit requests = new OrganizationalUnit();
requests.setOu("resetPasswordRequests");
requests.setDn("ou=resetPasswordRequests," + appliance.getDn());
if (!ldapEntryManager.contains(requests)) {
ldapEntryManager.persist(requests);
}
PasswordResetRequest request = new PasswordResetRequest();
do {
request.setCreationDate(Calendar.getInstance().getTime());
request.setPersonInum(matchedPersons.get(0).getInum());
request.setOxGuid(StringHelper.getRandomString(16));
request.setBaseDn("oxGuid=" + request.getOxGuid() + ", ou=resetPasswordRequests," + appliance.getDn());
} while (ldapEntryManager.contains(request));
String subj = String.format("Password reset was requested at %1$s identity server", organizationService.getOrganization().getDisplayName());
MailUtils mail = new MailUtils(appliance.getSmtpHost(), appliance.getSmtpPort(), appliance.isRequiresSsl(), appliance.isRequiresAuthentication(), appliance.getSmtpUserName(), applianceService.getDecryptedSmtpPassword(appliance));
mail.sendMail(appliance.getSmtpFromName() + " <" + appliance.getSmtpFromEmailAddress() + ">", email, subj, String.format(MESSAGE_FOUND, matchedPersons.get(0).getGivenName(), organizationService.getOrganization().getDisplayName(), appConfiguration.getApplianceUrl() + httpServletRequest.getContextPath() + "/resetPassword/" + request.getOxGuid()));
ldapEntryManager.persist(request);
} else {
GluuAppliance appliance = applianceService.getAppliance();
String subj = String.format("Password reset was requested at %1$s identity server", organizationService.getOrganization().getDisplayName());
MailUtils mail = new MailUtils(appliance.getSmtpHost(), appliance.getSmtpPort(), appliance.isRequiresSsl(), appliance.isRequiresAuthentication(), appliance.getSmtpUserName(), applianceService.getDecryptedSmtpPassword(appliance));
String fromName = appliance.getSmtpFromName();
if (fromName == null) {
fromName = String.format("%1$s identity server", organizationService.getOrganization().getDisplayName());
}
mail.sendMail(fromName + " <" + appliance.getSmtpFromEmailAddress() + ">", email, subj, String.format(MESSAGE_NOT_FOUND, organizationService.getOrganization().getDisplayName()));
}
return OxTrustConstants.RESULT_SUCCESS;
}
return OxTrustConstants.RESULT_FAILURE;
}
use of org.gluu.oxtrust.model.OrganizationalUnit in project oxTrust by GluuFederation.
the class TrustService method updateTrustRelationship.
public void updateTrustRelationship(GluuSAMLTrustRelationship trustRelationship) {
log.debug("Updating TR " + trustRelationship.getInum());
String[] clusterMembers = appConfiguration.getClusteredInums();
String applianceInum = appConfiguration.getApplianceInum();
if (clusterMembers == null || clusterMembers.length == 0) {
log.debug("there is no cluster configuration. Assuming standalone appliance.");
clusterMembers = new String[] { applianceInum };
}
String dn = trustRelationship.getDn();
for (String clusterMember : clusterMembers) {
String clusteredDN = StringHelper.replaceLast(dn, applianceInum, clusterMember);
trustRelationship.setDn(clusteredDN);
GluuSAMLTrustRelationship tr = new GluuSAMLTrustRelationship();
tr.setDn(trustRelationship.getDn());
if (containsTrustRelationship(tr)) {
log.trace("Updating TR" + clusteredDN);
ldapEntryManager.merge(trustRelationship);
} else {
OrganizationalUnit ou = new OrganizationalUnit();
ou.setDn(getDnForTrustRelationShip(null));
if (!ldapEntryManager.contains(ou)) {
ldapEntryManager.persist(ou);
}
ldapEntryManager.persist(trustRelationship);
}
}
trustRelationship.setDn(dn);
}
Aggregations