use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.
the class ConfigureCacheRefreshAction method validateInterceptorScript.
public void validateInterceptorScript() {
String result = update();
if (!OxTrustConstants.RESULT_SUCCESS.equals(result)) {
return;
}
// Reinit dialog
init();
this.showInterceptorValidationDialog = true;
boolean loadedScripts = externalCacheRefreshService.getCustomScriptConfigurations().size() > 0;
if (!loadedScripts) {
String message = "Can't load Cache Refresh scripts. Using default script";
log.error(message);
this.interceptorValidationMessage = message;
return;
}
// Prepare data for dummy entry
String targetInum = inumService.generateInums(OxTrustConstants.INUM_TYPE_PEOPLE_SLUG, false);
String targetPersonDn = personService.getDnForPerson(targetInum);
String[] targetCustomObjectClasses = appConfiguration.getPersonObjectClassTypes();
// Collect all attributes
String[] keyAttributesWithoutValues = getCompoundKeyAttributesWithoutValues(cacheRefreshConfiguration);
String[] sourceAttributes = getSourceAttributes(cacheRefreshConfiguration);
// Merge all attributes into one set
Set<String> allAttributes = new HashSet<String>();
for (String attribute : keyAttributesWithoutValues) {
allAttributes.add(attribute);
}
for (String attribute : sourceAttributes) {
allAttributes.add(attribute);
}
// Prepare source person entry with default attributes values
GluuSimplePerson sourcePerson = new GluuSimplePerson();
List<GluuCustomAttribute> customAttributes = sourcePerson.getCustomAttributes();
for (String attribute : allAttributes) {
customAttributes.add(new GluuCustomAttribute(attribute, "Test value"));
}
// Prepare target person
GluuCustomPerson targetPerson = new GluuCustomPerson();
targetPerson.setDn(targetPersonDn);
targetPerson.setInum(targetInum);
targetPerson.setStatus(appConfiguration.getSupportedUserStatus().get(0));
targetPerson.setCustomObjectClasses(targetCustomObjectClasses);
// Execute mapping according to configuration
Map<String, String> targetServerAttributesMapping = getTargetServerAttributesMapping(cacheRefreshConfiguration);
cacheRefreshService.setTargetEntryAttributes(sourcePerson, targetServerAttributesMapping, targetPerson);
// Execute interceptor script
boolean executionResult = externalCacheRefreshService.executeExternalUpdateUserMethods(targetPerson);
if (!executionResult) {
String message = "Can't execute Cache Refresh scripts.";
log.error(message);
this.interceptorValidationMessage = message;
return;
}
log.info("Script has been executed successfully.\n\nSample source entry is:\n'{}'.\n\nSample result entry is:\n'{}'", getGluuSimplePersonAttributesWithValues(sourcePerson), getGluuCustomPersonAttributesWithValues(targetPerson));
this.interceptorValidationMessage = String.format("Script has been executed successfully.\n\nSample source entry is:\n%s.\n\nSample result entry is:\n%s", getGluuSimplePersonAttributesWithValues(sourcePerson), getGluuCustomPersonAttributesWithValues(targetPerson));
}
use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.
the class LanguageBean method getLocaleCode.
public String getLocaleCode() {
GluuCustomPerson gluuCustomPerson = (GluuCustomPerson) identity.getUser();
if (gluuCustomPerson == null) {
return null;
}
GluuCustomAttribute locale = getLocaleOrNull(gluuCustomPerson);
if (locale == null) {
return null;
} else {
return locale.getValue();
}
}
use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.
the class Authenticator method postLogin.
/**
* Set session variables after user login
*
* @throws Exception
*/
private void postLogin(User user) {
identity.login();
log.debug("Configuring application after user '{}' login", user.getUid());
GluuCustomPerson person = findPersonByDn(user.getDn());
identity.setUser(person);
// Set user roles
UserRole[] userRoles = securityService.getUserRoles(user);
if (ArrayHelper.isNotEmpty(userRoles)) {
log.debug("Get '{}' user roles", Arrays.toString(userRoles));
} else {
log.debug("Get 0 user roles");
}
for (UserRole userRole : userRoles) {
identity.addRole(userRole.getRoleName());
}
}
use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.
the class UpdatePersonAction method add.
/**
* Initializes attributes for adding new person
*
* @return String describing success of the operation
* @throws Exception
*/
public String add() {
if (!organizationService.isAllowPersonModification()) {
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to add new person");
conversationService.endConversation();
return OxTrustConstants.RESULT_FAILURE;
}
if (this.person != null) {
return OxTrustConstants.RESULT_SUCCESS;
}
this.update = false;
this.person = new GluuCustomPerson();
initAttributes(true);
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.
the class UpdatePersonAction method userEmailIsUniqAtCreationTime.
private boolean userEmailIsUniqAtCreationTime(String email) {
if (email == null) {
return true;
}
boolean emailIsUniq = true;
List<GluuCustomPerson> gluuCustomPersons = personService.getPersonsByEmail(email);
if (gluuCustomPersons != null && gluuCustomPersons.size() > 0) {
for (GluuCustomPerson gluuCustomPerson : gluuCustomPersons) {
if (gluuCustomPerson.getAttribute(MAIL).equalsIgnoreCase(email)) {
emailIsUniq = false;
break;
}
}
}
return emailIsUniq;
}
Aggregations