use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.
the class AttributeService method getAllPersonAtributes.
private List<GluuAttribute> getAllPersonAtributes(GluuUserRole gluuUserRole, Collection<GluuAttribute> attributes) {
List<GluuAttribute> attributeList = new ArrayList<GluuAttribute>();
String[] objectClassTypes = appConfiguration.getPersonObjectClassTypes();
log.debug("objectClassTypes={}", Arrays.toString(objectClassTypes));
for (GluuAttribute attribute : attributes) {
if (StringHelper.equalsIgnoreCase(attribute.getOrigin(), appConfiguration.getPersonCustomObjectClass()) && (GluuUserRole.ADMIN == gluuUserRole)) {
attribute.setCustom(true);
attributeList.add(attribute);
continue;
}
for (String objectClassType : objectClassTypes) {
if (attribute.getOrigin().equals(objectClassType)) {
attributeList.add(attribute);
break;
}
}
}
return attributeList;
}
use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.
the class ImportPersonConfiguration method createAttributeFromConfig.
private GluuAttribute createAttributeFromConfig(String prefix) {
String attributeName = importConfiguration.getString(prefix + ATTRIBUTE_LDAP_NAME_SUFFIX, null);
String displayName = importConfiguration.getString(prefix + ATTRIBUTE_DISPLAY_NAME_SUFFIX, null);
String dataType = importConfiguration.getString(prefix + ATTRIBUTE_DATA_TYPE_SUFFIX, null);
boolean required = importConfiguration.getBoolean(prefix + ATTRIBUTE_DATA_REQUIRED_SUFFIX, false);
if (StringHelper.isNotEmpty(attributeName) && StringHelper.isNotEmpty(displayName) && StringHelper.isNotEmpty(dataType)) {
AttributeDataType attributeDataType = AttributeDataType.getByValue(dataType);
if (attributeDataType != null) {
GluuAttribute attr = new GluuAttribute();
attr.setName(attributeName);
attr.setDisplayName(displayName);
attr.setDataType(attributeDataType);
attr.setRequred(required);
return attr;
}
}
return null;
}
use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.
the class ImportPersonConfiguration method createAttributeFromConfig.
private GluuAttribute createAttributeFromConfig(ImportPerson importPerson) {
String attributeName = importPerson.getLdapName();
String displayName = importPerson.getDisplayName();
String dataType = importPerson.getDataType();
boolean required = importPerson.getRequired();
if (StringHelper.isNotEmpty(attributeName) && StringHelper.isNotEmpty(displayName) && StringHelper.isNotEmpty(dataType)) {
AttributeDataType attributeDataType = AttributeDataType.getByValue(dataType);
if (attributeDataType != null) {
GluuAttribute attr = new GluuAttribute();
attr.setName(attributeName);
attr.setDisplayName(displayName);
attr.setDataType(attributeDataType);
attr.setRequred(required);
return attr;
}
}
return null;
}
use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.
the class WhitePagesAction method getReleasedAttributes.
public List<GluuCustomAttribute> getReleasedAttributes(GluuCustomPerson person) {
if (person == null) {
return Arrays.asList(new GluuCustomAttribute[0]);
}
List<GluuCustomAttribute> releasedAttributes = new ArrayList<GluuCustomAttribute>();
for (GluuCustomAttribute attribute : person.getCustomAttributes()) {
List<GluuAttribute> attributes = attributeService.getAllPersonAttributes(GluuUserRole.USER);
GluuAttribute metadata = attributeService.getAttributeByName(attribute.getName(), attributes);
if (metadata != null && metadata.isWhitePagesCanView() && !tableAttributes.contains(attribute.getName())) {
attribute.setMetadata(metadata);
releasedAttributes.add(attribute);
}
}
return releasedAttributes;
}
use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.
the class PasswordValidator method validate.
@Override
public void validate(FacesContext arg0, UIComponent arg1, Object value) throws ValidatorException {
if (attributeService == null) {
attributeService = CdiUtil.bean(AttributeService.class);
}
GluuAttribute attributeByName = attributeService.getAttributeByName(USER_PASSWORD);
AttributeValidation validation = attributeByName.getAttributeValidation();
if (validation != null && validation.getRegexp() != null && !validation.getRegexp().isEmpty()) {
pattern = Pattern.compile(validation.getRegexp());
hasValidation = true;
}
if (hasValidation) {
matcher = pattern.matcher(value.toString());
}
if (hasValidation && !matcher.matches()) {
FacesMessage msg = new FacesMessage(facesMessages.evalResourceAsString("#{msgs['password.validation.invalid']}"));
msg.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ValidatorException(msg);
}
}
Aggregations