Search in sources :

Example 36 with GluuAttribute

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;
}
Also used : ArrayList(java.util.ArrayList) GluuAttribute(org.gluu.model.GluuAttribute)

Example 37 with GluuAttribute

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;
}
Also used : AttributeDataType(org.gluu.model.attribute.AttributeDataType) GluuAttribute(org.gluu.model.GluuAttribute)

Example 38 with GluuAttribute

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;
}
Also used : AttributeDataType(org.gluu.model.attribute.AttributeDataType) GluuAttribute(org.gluu.model.GluuAttribute)

Example 39 with GluuAttribute

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;
}
Also used : GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) ArrayList(java.util.ArrayList) GluuAttribute(org.gluu.model.GluuAttribute)

Example 40 with GluuAttribute

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);
    }
}
Also used : AttributeValidation(org.gluu.model.attribute.AttributeValidation) ValidatorException(javax.faces.validator.ValidatorException) AttributeService(org.gluu.oxtrust.service.AttributeService) FacesMessage(javax.faces.application.FacesMessage) GluuAttribute(org.gluu.model.GluuAttribute)

Aggregations

GluuAttribute (org.gluu.model.GluuAttribute)68 ArrayList (java.util.ArrayList)21 GluuCustomAttribute (org.gluu.oxtrust.model.GluuCustomAttribute)10 IOException (java.io.IOException)8 Scope (org.oxauth.persistence.model.Scope)8 HttpEntity (org.apache.http.HttpEntity)7 HttpResponse (org.apache.http.HttpResponse)7 ParseException (org.apache.http.ParseException)7 Test (org.junit.Test)7 HttpGet (org.apache.http.client.methods.HttpGet)6 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)6 Filter (org.gluu.search.filter.Filter)5 JSONObject (org.json.JSONObject)4 Operation (io.swagger.v3.oas.annotations.Operation)3 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 FacesMessage (javax.faces.application.FacesMessage)3 UIInput (javax.faces.component.UIInput)3 AttributeValidation (org.gluu.model.attribute.AttributeValidation)3