use of org.gluu.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.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);
jsonConfigurationService.saveOxTrustappConfiguration(this.oxTrustappConfiguration);
facesMessages.add(FacesMessage.SEVERITY_INFO, "Registration configuration updated successfully");
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.gluu.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.gluu.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("userPassword");
hiddenAttributes.add("gluuStatus");
hiddenAttributes.add("oxExternalUid");
hiddenAttributes.add("oxLastLogonTime");
}
use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.
the class UpdateAttributeAction method add.
public String add() {
if (this.attribute != null) {
return OxTrustConstants.RESULT_SUCCESS;
}
this.update = false;
this.showAttributeDeleteConfirmation = false;
this.attribute = new GluuAttribute();
attribute.setAttributeValidation(new AttributeValidation());
this.attribute.setStatus(GluuStatus.ACTIVE);
this.attribute.setEditType(new GluuUserRole[] { GluuUserRole.ADMIN });
this.canEdit = true;
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.
the class OxTrustAttributeValidator method validate.
@Override
public void validate(FacesContext context, UIComponent comp, Object value) {
GluuAttribute attribute = (GluuAttribute) comp.getAttributes().get("attribute");
if (attribute == null) {
((UIInput) comp).setValid(true);
return;
}
AttributeValidation attributeValidation = attribute.getAttributeValidation();
Integer minvalue = attributeValidation != null ? attributeValidation.getMinLength() : null;
Integer maxValue = attributeValidation != null ? attributeValidation.getMaxLength() : null;
String regexpValue = attributeValidation != null ? attributeValidation.getRegexp() : null;
String attributeValue = (String) value;
// Minimum length validation
if (minvalue != null) {
int min = attributeValidation.getMinLength();
if ((attributeValue != null) && (attributeValue.length() < min)) {
((UIInput) comp).setValid(false);
FacesMessage message = new FacesMessage(attribute.getDisplayName() + " should be at least " + min + " symbols. ");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
context.addMessage(comp.getClientId(context), message);
}
}
// default maxlength
int max = 400;
if (maxValue != null) {
max = attributeValidation.getMaxLength();
}
// Maximum Length validation
if ((attributeValue != null) && (attributeValue.length() > max)) {
((UIInput) comp).setValid(false);
FacesMessage message = new FacesMessage(attribute.getDisplayName() + " should not exceed " + max + " symbols. ");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
context.addMessage(comp.getClientId(context), message);
}
if ((attribute.getName().equalsIgnoreCase("mail") && ((regexpValue == null) || (StringHelper.isEmpty(regexpValue))))) {
regexpValue = "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@" + "[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$";
}
if ((regexpValue != null) && StringHelper.isNotEmpty(regexpValue)) {
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(regexpValue);
if ((attributeValue != null) && !(attributeValue.trim().equals(""))) {
java.util.regex.Matcher matcher = pattern.matcher(attributeValue);
boolean flag = matcher.matches();
if (!flag) {
((UIInput) comp).setValid(false);
FacesMessage message = new FacesMessage(attribute.getDisplayName() + " Format is invalid. ");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
context.addMessage(comp.getClientId(context), message);
}
}
}
}
Aggregations