use of org.xdi.model.GluuAttribute in project oxTrust by GluuFederation.
the class RegisterPersonAction method initAttributes.
private void initAttributes() {
List<GluuAttribute> allPersonAttributes = attributeService.getAllActivePersonAttributes(GluuUserRole.ADMIN);
List<String> allAttributOrigins = attributeService.getAllAttributeOrigins(allPersonAttributes);
GluuOrganization organization = organizationService.getOrganization();
List<GluuCustomAttribute> customAttributes = this.person.getCustomAttributes();
boolean isNewPerson = (customAttributes == null) || customAttributes.isEmpty();
if (isNewPerson) {
customAttributes = new ArrayList<GluuCustomAttribute>();
this.person.setCustomAttributes(customAttributes);
}
String[] personOCs = appConfiguration.getPersonObjectClassTypes();
String[] personOCDisplayNames = appConfiguration.getPersonObjectClassDisplayNames();
customAttributeAction.initCustomAttributes(allPersonAttributes, customAttributes, allAttributOrigins, personOCs, personOCDisplayNames);
List<GluuCustomAttribute> mandatoryAttributes = new ArrayList<GluuCustomAttribute>();
RegistrationConfiguration config = organization.getOxRegistrationConfiguration();
boolean registrationCustomized = config != null;
boolean registrationAttributesCustomized = registrationCustomized && config.getAdditionalAttributes() != null && !config.getAdditionalAttributes().isEmpty();
if (registrationAttributesCustomized) {
for (String attributeInum : config.getAdditionalAttributes()) {
GluuAttribute attribute = attributeService.getAttributeByInum(attributeInum);
GluuCustomAttribute customAttribute = new GluuCustomAttribute(attribute.getName(), "", false, false);
mandatoryAttributes.add(customAttribute);
}
}
for (GluuCustomAttribute attribute : personService.getMandatoryAtributes()) {
if (!mandatoryAttributes.contains(attribute)) {
mandatoryAttributes.add(attribute);
}
}
mandatoryAttributes.addAll(personService.getMandatoryAtributes());
if (isNewPerson) {
customAttributeAction.addCustomAttributes(mandatoryAttributes);
}
hiddenAttributes = new ArrayList<String>();
hiddenAttributes.add("inum");
hiddenAttributes.add("iname");
hiddenAttributes.add("userPassword");
hiddenAttributes.add("gluuStatus");
hiddenAttributes.add("oxExternalUid");
hiddenAttributes.add("oxLastLogonTime");
}
use of org.xdi.model.GluuAttribute in project oxTrust by GluuFederation.
the class RegistrationManagementAction method lookupAttributeData.
public String lookupAttributeData() {
GluuAttribute attribute = attributeService.getAttributeByName(attributeName);
attributeData = "Uid:\t" + attributeName;
attributeData += "<br/>Description:\t" + attribute.getDescription();
attributeData += "<br/>Origin:\t" + attribute.getOrigin();
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.xdi.model.GluuAttribute in project oxTrust by GluuFederation.
the class RegistrationManagementAction method save.
public String save() {
GluuOrganization org = organizationService.getOrganization();
RegistrationConfiguration config = org.getOxRegistrationConfiguration();
if (config == null) {
config = new RegistrationConfiguration();
}
config.setRegistrationInterceptorsConfigured(configureInterceptors);
if (configureInterceptors) {
config.setRegistrationInterceptorScripts(registrationInterceptors);
} else {
config.setRegistrationInterceptorScripts(null);
}
config.setCaptchaDisabled(captchaDisabled);
List<String> attributeList = new ArrayList<String>();
if (configureRegistrationForm) {
for (GluuAttribute attribute : selectedAttributes) {
attributeList.add(attribute.getInum());
}
}
config.setAdditionalAttributes(attributeList);
org.setOxRegistrationConfiguration(config);
organizationService.updateOrganization(org);
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.xdi.model.GluuAttribute in project oxTrust by GluuFederation.
the class UpdateScopeAction method removeDuplicates.
public void removeDuplicates() {
List<GluuAttribute> tempAvailableClaims = new ArrayList<GluuAttribute>();
for (int i = 0; i < this.availableClaims.size(); i++) {
for (int j = i + 1; j < this.availableClaims.size(); ) {
if (this.availableClaims.get(i).getDisplayName().equalsIgnoreCase(this.availableClaims.get(j).getDisplayName())) {
this.availableClaims.remove(j);
} else {
j++;
}
}
}
for (GluuAttribute availableClaim : this.availableClaims) {
if (availableClaim != null) {
tempAvailableClaims.add(availableClaim);
}
}
this.availableClaims = tempAvailableClaims;
}
use of org.xdi.model.GluuAttribute in project oxTrust by GluuFederation.
the class PersonImportAction method convertTableToPersons.
protected List<GluuCustomPerson> convertTableToPersons(Table table, List<ImportAttribute> importAttributes) throws Exception {
// Prepare for conversion to list of GluuCustomPerson and check data
// type
Map<String, List<AttributeData>> entriesAttributes = new HashMap<String, List<AttributeData>>();
int rows = table.getCountRows();
boolean validTable = true;
for (int i = 1; i <= rows; i++) {
List<AttributeData> attributeDataList = new ArrayList<AttributeData>();
for (ImportAttribute importAttribute : importAttributes) {
if (importAttribute.getCol() == -1) {
continue;
}
GluuAttribute attribute = importAttribute.getAttribute();
String cellValue = table.getCellValue(importAttribute.getCol(), i);
if (StringHelper.isEmpty(cellValue)) {
if (attribute.isRequred()) {
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Import failed. Empty '{}' not allowed", attribute.getDisplayName());
validTable = false;
}
continue;
}
String ldapValue = getTypedValue(attribute, cellValue);
if (StringHelper.isEmpty(ldapValue)) {
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Invalid value '{}' in column '{}' at row {} were specified", cellValue, attribute.getDisplayName(), i + 1);
validTable = false;
continue;
}
AttributeData attributeData = new AttributeData(attribute.getName(), ldapValue);
attributeDataList.add(attributeData);
}
entriesAttributes.put(Integer.toString(i), attributeDataList);
}
if (!validTable) {
return null;
}
// Convert to GluuCustomPerson and set right DN
List<GluuCustomPerson> persons = personService.createEntities(entriesAttributes);
log.info("Found {} persons in input Excel file", persons.size());
for (GluuCustomPerson person : persons) {
for (String key : entriesAttributes.keySet()) {
boolean flag = false;
for (AttributeData AttributeData : entriesAttributes.get(key)) {
if (AttributeData.getName().equalsIgnoreCase("uid")) {
if (person.getUid().equalsIgnoreCase(AttributeData.getValue())) {
for (AttributeData AttributeData1 : entriesAttributes.get(key)) {
if (AttributeData1.getName().equalsIgnoreCase("userPassword")) {
person.setUserPassword(AttributeData1.getValue());
flag = true;
break;
} else if (AttributeData1.getName().equalsIgnoreCase("gluuStatus")) {
person.setStatus(GluuStatus.getByValue(AttributeData1.getValue()));
flag = true;
break;
}
}
}
} else {
if (flag)
break;
}
}
if (flag)
break;
}
}
return persons;
}
Aggregations