Search in sources :

Example 26 with GluuAttribute

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

the class PersonImportAction method getAttributesString.

private String getAttributesString(List<GluuAttribute> attributes) {
    StringBuilder sb = new StringBuilder();
    for (Iterator<GluuAttribute> iterator = attributes.iterator(); iterator.hasNext(); ) {
        GluuAttribute attribute = iterator.next();
        sb.append('\'').append(attribute.getDisplayName()).append('\'');
        if (!attribute.isRequred()) {
            sb.append(" (non mandatory)");
        }
        if (iterator.hasNext()) {
            sb.append(", ");
        }
    }
    return sb.toString();
}
Also used : GluuAttribute(org.xdi.model.GluuAttribute)

Example 27 with GluuAttribute

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

the class Shibboleth3ConfService method initAttributeParamMap.

private HashMap<String, Object> initAttributeParamMap(List<GluuSAMLTrustRelationship> trustRelationships) {
    HashMap<String, Object> attrParams = new HashMap<String, Object>();
    // Collect attributes
    List<GluuAttribute> attributes = new ArrayList<GluuAttribute>();
    List<String> attributeNames = new ArrayList<String>();
    for (GluuSAMLTrustRelationship trustRelationship : trustRelationships) {
        for (GluuCustomAttribute customAttribute : trustRelationship.getReleasedCustomAttributes()) {
            GluuAttribute metadata = customAttribute.getMetadata();
            if (!attributes.contains(metadata)) {
                attributes.add(metadata);
                String attributeName = metadata.getName();
                attributeNames.add(attributeName);
            }
        }
    }
    SchemaEntry schemaEntry = shemaService.getSchema();
    List<AttributeTypeDefinition> attributeTypes = shemaService.getAttributeTypeDefinitions(schemaEntry, attributeNames);
    Map<String, String> attributeSAML1Strings = new HashMap<String, String>();
    Map<String, String> attributeSAML2Strings = new HashMap<String, String>();
    for (GluuAttribute metadata : attributes) {
        String attributeName = metadata.getName();
        AttributeTypeDefinition attributeTypeDefinition = shemaService.getAttributeTypeDefinition(attributeTypes, attributeName);
        if (attributeTypeDefinition == null) {
            log.error("Failed to get OID for attribute name {}", attributeName);
            return null;
        }
        //
        // urn::dir:attribute-def:$attribute.name
        // urn:oid:$attrParams.attributeOids.get($attribute.name)
        String saml1String = metadata.getSaml1Uri();
        if (StringHelper.isEmpty(saml1String)) {
            boolean standard = metadata.isCustom() || StringHelper.isEmpty(metadata.getUrn()) || (!StringHelper.isEmpty(metadata.getUrn()) && metadata.getUrn().startsWith("urn:gluu:dir:attribute-def:"));
            saml1String = String.format("urn:%s:dir:attribute-def:%s", standard ? "gluu" : "mace", attributeName);
        }
        attributeSAML1Strings.put(attributeName, saml1String);
        String saml2String = metadata.getSaml2Uri();
        if (StringHelper.isEmpty(saml2String)) {
            saml2String = String.format("urn:oid:%s", attributeTypeDefinition.getOID());
        }
        attributeSAML2Strings.put(attributeName, saml2String);
    }
    attrParams.put("attributes", attributes);
    attrParams.put("attributeSAML1Strings", attributeSAML1Strings);
    attrParams.put("attributeSAML2Strings", attributeSAML2Strings);
    return attrParams;
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SchemaEntry(org.xdi.model.SchemaEntry) GluuAttribute(org.xdi.model.GluuAttribute) AttributeTypeDefinition(com.unboundid.ldap.sdk.schema.AttributeTypeDefinition)

Example 28 with GluuAttribute

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

the class ImportPersonConfiguration method prepareAttributes.

private List<GluuAttribute> prepareAttributes() throws Exception {
    List<GluuAttribute> result = new ArrayList<GluuAttribute>();
    List<ImportPerson> mappings = configurationFactory.getImportPersonConfig().getMappings();
    Iterator<ImportPerson> it = mappings.iterator();
    while (it.hasNext()) {
        ImportPerson importPerson = (ImportPerson) it.next();
        String attributeName = importPerson.getLdapName();
        boolean required = importPerson.getRequired();
        if (StringHelper.isNotEmpty(attributeName)) {
            GluuAttribute attr = null;
            try {
                attr = attributeService.getAttributeByName(attributeName);
            } catch (EntryPersistenceException ex) {
                log.error("Failed to load attribute '{}' definition from LDAP", ex, attributeName);
            }
            if (attr == null) {
                log.warn("Failed to find attribute '{}' definition in LDAP", attributeName);
                attr = createAttributeFromConfig(importPerson);
                if (attr == null) {
                    log.error("Failed to find attribute '{}' definition in '{}'", attributeName, GLUU_IMPORT_PERSON_PROPERTIES_FILE);
                    continue;
                }
            } else {
                attr.setRequred(required);
            }
            result.add(attr);
        }
    //}
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) ImportPerson(org.xdi.config.oxtrust.ImportPerson) GluuAttribute(org.xdi.model.GluuAttribute)

Example 29 with GluuAttribute

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

the class AttributeService method getAllActiveAtributesImpl.

/**
	 * @return
	 * @throws LDAPException
	 */
private List<GluuAttribute> getAllActiveAtributesImpl(GluuUserRole gluuUserRole) {
    Filter filter = Filter.createEqualityFilter("gluuStatus", "active");
    List<GluuAttribute> attributeList = ldapEntryManager.findEntries(getDnForAttribute(null), GluuAttribute.class, filter);
    String customOrigin = getCustomOrigin();
    String[] objectClassTypes = appConfiguration.getPersonObjectClassTypes();
    log.debug("objectClassTypes={}", Arrays.toString(objectClassTypes));
    List<GluuAttribute> returnAttributeList = new ArrayList<GluuAttribute>();
    for (GluuAttribute attribute : attributeList) {
        if (StringHelper.equalsIgnoreCase(attribute.getOrigin(), appConfiguration.getPersonCustomObjectClass()) && (GluuUserRole.ADMIN == gluuUserRole)) {
            attribute.setCustom(true);
            returnAttributeList.add(attribute);
            continue;
        }
        for (String objectClassType : objectClassTypes) {
            if (attribute.getOrigin().equals(objectClassType) && ((attribute.allowViewBy(gluuUserRole) || attribute.allowEditBy(gluuUserRole)))) {
                attribute.setCustom(customOrigin.equals(attribute.getOrigin()));
                returnAttributeList.add(attribute);
                break;
            }
        }
    }
    return returnAttributeList;
}
Also used : Filter(com.unboundid.ldap.sdk.Filter) ArrayList(java.util.ArrayList) GluuAttribute(org.xdi.model.GluuAttribute)

Example 30 with GluuAttribute

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

the class AttributeService method getAllContactAtributesImpl.

/**
	 * Get all contact attributes
	 * 
	 * @param attributes
	 *            List of attributes
	 * @return List of contact attributes
	 */
private List<GluuAttribute> getAllContactAtributesImpl(GluuUserRole gluuUserRole, Collection<GluuAttribute> attributes) {
    List<GluuAttribute> returnAttributeList = new ArrayList<GluuAttribute>();
    String[] objectClassTypes = appConfiguration.getContactObjectClassTypes();
    for (GluuAttribute attribute : attributes) {
        if (StringHelper.equalsIgnoreCase(attribute.getOrigin(), appConfiguration.getPersonCustomObjectClass()) && (GluuUserRole.ADMIN == gluuUserRole)) {
            attribute.setCustom(true);
            returnAttributeList.add(attribute);
            continue;
        }
        for (String objectClassType : objectClassTypes) {
            if (attribute.getOrigin().equals(objectClassType) && (attribute.allowViewBy(gluuUserRole) || attribute.allowEditBy(gluuUserRole))) {
                returnAttributeList.add(attribute);
                break;
            }
        }
    }
    return returnAttributeList;
}
Also used : ArrayList(java.util.ArrayList) GluuAttribute(org.xdi.model.GluuAttribute)

Aggregations

GluuAttribute (org.xdi.model.GluuAttribute)64 ArrayList (java.util.ArrayList)24 GluuCustomAttribute (org.gluu.oxtrust.model.GluuCustomAttribute)15 JSONObject (org.codehaus.jettison.json.JSONObject)9 JSONArray (org.codehaus.jettison.json.JSONArray)8 GluuAttributeDataType (org.xdi.model.GluuAttributeDataType)6 IOException (java.io.IOException)5 BigDecimal (java.math.BigDecimal)5 Date (java.util.Date)5 HashMap (java.util.HashMap)5 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)5 Extension (org.gluu.oxtrust.model.scim2.Extension)5 JwtSubClaimObject (org.xdi.oxauth.model.jwt.JwtSubClaimObject)5 Filter (com.unboundid.ldap.sdk.Filter)4 List (java.util.List)4 GluuSAMLTrustRelationship (org.gluu.oxtrust.model.GluuSAMLTrustRelationship)4 Claim (org.xdi.oxauth.model.authorize.Claim)4 Scope (org.xdi.oxauth.model.common.Scope)4 PairwiseIdentifier (org.xdi.oxauth.model.ldap.PairwiseIdentifier)4 DynamicScopeExternalContext (org.xdi.oxauth.service.external.context.DynamicScopeExternalContext)4