Search in sources :

Example 26 with GluuAttribute

use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.

the class PersonService method getPersonsByEmail.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.gluu.oxtrust.ldap.service.IPersonService#getPersonsByEmail(java.lang.
	 * String)
	 */
@Override
public List<GluuCustomPerson> getPersonsByEmail(String mail, String... returnAttributes) {
    log.debug("Getting user information from DB: mail = {}", mail);
    if (StringHelper.isEmpty(mail)) {
        return null;
    }
    String personDn = getDnForPerson(null);
    Filter userMailFilter;
    if (dataSourceTypeService.isSpanner(personDn)) {
        userMailFilter = Filter.createEqualityFilter("mail", StringHelper.toLowerCase(mail));
    } else {
        userMailFilter = Filter.createEqualityFilter(Filter.createLowercaseFilter("mail"), StringHelper.toLowerCase(mail));
    }
    boolean multiValued = false;
    GluuAttribute mailAttribute = attributeService.getAttributeByName("mail");
    if ((mailAttribute != null) && (mailAttribute.getOxMultiValuedAttribute() != null) && mailAttribute.getOxMultiValuedAttribute()) {
        multiValued = true;
    }
    userMailFilter.multiValued(multiValued);
    List<GluuCustomPerson> entries = persistenceEntryManager.findEntries(personDn, GluuCustomPerson.class, userMailFilter, returnAttributes);
    log.debug("Found {} entries for mail = {}", entries.size(), mail);
    return entries;
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) Filter(org.gluu.search.filter.Filter) GluuAttribute(org.gluu.model.GluuAttribute)

Example 27 with GluuAttribute

use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.

the class Shibboleth3ConfService method initAttributeResolverParamMap.

public HashMap<String, Object> initAttributeResolverParamMap() {
    List<NameIdConfig> nameIdConfigs = new ArrayList<NameIdConfig>();
    Set<GluuAttribute> nameIdAttributes = new HashSet<GluuAttribute>();
    AttributeResolverConfiguration attributeResolverConfiguration = configurationFactory.getAttributeResolverConfiguration();
    if ((attributeResolverConfiguration != null) && (attributeResolverConfiguration.getNameIdConfigs() != null)) {
        for (NameIdConfig nameIdConfig : attributeResolverConfiguration.getNameIdConfigs()) {
            if (StringHelper.isNotEmpty(nameIdConfig.getSourceAttribute()) && nameIdConfig.isEnabled()) {
                String attributeName = nameIdConfig.getSourceAttribute();
                GluuAttribute attribute = attributeService.getAttributeByName(attributeName);
                nameIdConfigs.add(nameIdConfig);
                nameIdAttributes.add(attribute);
            }
        }
    }
    HashMap<String, Object> attributeResolverParams = createAttributeMap(nameIdAttributes);
    attributeResolverParams.put("configs", nameIdConfigs);
    attributeResolverParams.put("attributes", nameIdAttributes);
    String baseUserDn = personService.getDnForPerson(null);
    String persistenceType = persistenceEntryManager.getPersistenceType(baseUserDn);
    log.debug(">>>>>>>>>> Shibboleth3ConfService.initAttributeResolverParamMap() - Persistance type: '{}'", persistenceType);
    attributeResolverParams.put("persistenceType", persistenceType);
    return attributeResolverParams;
}
Also used : ArrayList(java.util.ArrayList) AttributeResolverConfiguration(org.gluu.config.oxtrust.AttributeResolverConfiguration) NameIdConfig(org.gluu.config.oxtrust.NameIdConfig) GluuAttribute(org.gluu.model.GluuAttribute) HashSet(java.util.HashSet)

Example 28 with GluuAttribute

use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.

the class AttributeService method setAttributeMetadata.

/**
 * Set metadata for every custom attribute
 *
 * @param customAttributes
 *            List of custom attributes
 * @param attributes
 *            List of attributes
 */
public void setAttributeMetadata(List<GluuCustomAttribute> customAttributes, List<GluuAttribute> attributes) {
    if ((customAttributes == null) || (attributes == null)) {
        return;
    }
    for (GluuCustomAttribute personAttribute : customAttributes) {
        GluuAttribute tmpAttribute = getAttributeByName(personAttribute.getName(), attributes);
        if (tmpAttribute == null) {
            log.warn("Failed to find attribute '{}' metadata", personAttribute.getName());
        }
        personAttribute.setMetadata(tmpAttribute);
    }
}
Also used : GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) GluuAttribute(org.gluu.model.GluuAttribute)

Example 29 with GluuAttribute

use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.

the class AttributeService method getAllAtributesImpl.

@Override
protected List<GluuAttribute> getAllAtributesImpl(String baseDn) {
    List<GluuAttribute> attributeList = persistenceEntryManager.findEntries(baseDn, GluuAttribute.class, null);
    String customOrigin = getCustomOrigin();
    for (GluuAttribute attribute : attributeList) {
        attribute.setCustom(customOrigin.equals(attribute.getOrigin()));
    }
    return attributeList;
}
Also used : GluuAttribute(org.gluu.model.GluuAttribute)

Example 30 with GluuAttribute

use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.

the class AttributeService method getCustomAttributes.

/**
 * Get custom attributes
 *
 * @return List of cusomt attributes
 */
@SuppressWarnings("unchecked")
public List<GluuAttribute> getCustomAttributes() {
    List<GluuAttribute> attributeList = (List<GluuAttribute>) cacheService.get(OxTrustConstants.CACHE_ATTRIBUTE_CUSTOM_KEY_LIST);
    if (attributeList == null) {
        attributeList = new ArrayList<GluuAttribute>();
        for (GluuAttribute attribute : getAllAttributes()) {
            if (attribute.isCustom()) {
                attributeList.add(attribute);
            }
        }
        cacheService.put(OxTrustConstants.CACHE_ATTRIBUTE_CUSTOM_KEY_LIST, attributeList);
    }
    return attributeList;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) 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