use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.
the class Shibboleth3ConfService method initAttributes.
/*
* Init attributes
*/
private void initAttributes(List<GluuSAMLTrustRelationship> trustRelationships) {
List<GluuAttribute> attributes = attributeService.getAllPersonAttributes(GluuUserRole.ADMIN);
HashMap<String, GluuAttribute> attributesByDNs = attributeService.getAttributeMapByDNs(attributes);
GluuAttribute uid = attributeService.getAttributeByName(OxConstants.UID);
// Load attributes definition
for (GluuSAMLTrustRelationship trustRelationship : trustRelationships) {
// Add first attribute uid
List<String> oldAttributes = trustRelationship.getReleasedAttributes();
List<String> releasedAttributes = new ArrayList<String>();
if (oldAttributes != null) {
releasedAttributes.addAll(oldAttributes);
}
if (uid != null) {
if (releasedAttributes.remove(uid.getDn())) {
releasedAttributes.add(0, uid.getDn());
}
}
// Resolve custom attributes by DNs
trustRelationship.setReleasedCustomAttributes(attributeService.getCustomAttributesByAttributeDNs(releasedAttributes, attributesByDNs));
// Set attribute meta-data
attributeService.setAttributeMetadata(trustRelationship.getReleasedCustomAttributes(), attributes);
}
}
use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.
the class Shibboleth3ConfService method createAttributeMap.
private HashMap<String, Object> createAttributeMap(Set<GluuAttribute> attributes) {
HashMap<String, Object> resolver = new HashMap<String, Object>();
List<String> attributeNames = new ArrayList<>();
for (GluuAttribute attribute : attributes) attributeNames.add(attribute.getName());
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();
// 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)) {
AttributeTypeDefinition attributeTypeDefinition = shemaService.getAttributeTypeDefinition(attributeTypes, attributeName);
if (attributeTypeDefinition == null) {
log.error("Failed to get OID for attribute name {}", attributeName);
return null;
}
saml2String = String.format("urn:oid:%s", attributeTypeDefinition.getOID());
}
attributeSAML2Strings.put(attributeName, saml2String);
}
resolver.put("attributes", attributes);
resolver.put("attributeSAML1Strings", attributeSAML1Strings);
resolver.put("attributeSAML2Strings", attributeSAML2Strings);
return resolver;
}
use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.
the class AttributeService method searchAttributes.
/**
* Search groups by pattern
*
* @param pattern
* Pattern
* @param sizeLimit
* Maximum count of results
* @return List of groups
* @throws Exception
*/
public List<GluuAttribute> searchAttributes(String pattern, int sizeLimit) throws Exception {
String[] targetArray = new String[] { pattern };
Filter displayNameFilter = Filter.createSubstringFilter(OxTrustConstants.displayName, null, targetArray, null);
Filter descriptionFilter = Filter.createSubstringFilter(OxTrustConstants.description, null, targetArray, null);
Filter nameFilter = Filter.createSubstringFilter(OxTrustConstants.attributeName, null, targetArray, null);
Filter searchFilter = Filter.createORFilter(displayNameFilter, descriptionFilter, nameFilter);
List<GluuAttribute> result = persistenceEntryManager.findEntries(getDnForAttribute(null), GluuAttribute.class, searchFilter, sizeLimit);
String customOrigin = getCustomOrigin();
for (GluuAttribute attribute : result) {
attribute.setCustom(customOrigin.equals(attribute.getOrigin()));
}
return result;
}
use of org.gluu.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 = persistenceEntryManager.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.setCustom(customOrigin.equals(attribute.getOrigin()));
returnAttributeList.add(attribute);
break;
}
}
}
return returnAttributeList;
}
use of org.gluu.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