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();
}
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;
}
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;
}
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;
}
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;
}
Aggregations