private List<String> getReturningAttributes(final LDAPMappingConfiguration mappingConfiguration) { List<String> returningAttributes = new ArrayList<String>(); if (mappingConfiguration != null) { returningAttributes.addAll(mappingConfiguration.getMappedProperties().values()); returningAttributes.add(mappingConfiguration.getParentMembershipAttributeName()); for (LDAPMappingConfiguration relationshipConfig : this.config.getRelationshipConfigs()) { if (relationshipConfig.getRelatedAttributedType().equals(mappingConfiguration.getMappedClass())) { returningAttributes.addAll(relationshipConfig.getMappedProperties().values()); } } } else { returningAttributes.add("*"); } returningAttributes.add(getUniqueIdentifierAttributeName()); returningAttributes.add(CREATE_TIMESTAMP); returningAttributes.add(LDAPConstants.OBJECT_CLASS); return returningAttributes; } }
private List<String> getReturningAttributes(final LDAPMappingConfiguration mappingConfiguration) { List<String> returningAttributes = new ArrayList<String>(); if (mappingConfiguration != null) { returningAttributes.addAll(mappingConfiguration.getMappedProperties().values()); returningAttributes.add(mappingConfiguration.getParentMembershipAttributeName()); for (LDAPMappingConfiguration relationshipConfig : this.config.getRelationshipConfigs()) { if (relationshipConfig.getRelatedAttributedType().equals(mappingConfiguration.getMappedClass())) { returningAttributes.addAll(relationshipConfig.getMappedProperties().values()); } } } else { returningAttributes.add("*"); } returningAttributes.add(getUniqueIdentifierAttributeName()); returningAttributes.add(CREATE_TIMESTAMP); returningAttributes.add(LDAPConstants.OBJECT_CLASS); return returningAttributes; } }
Attributes entryAttributes = this.operationManager.getAttributes(ownerType.getId(), getBaseDN(ownerType), mappingConfig); for (String relationshipTypeProperty : mappingConfig.getMappedProperties().keySet()) { Property<AttributedType> relationshipProperty = PropertyQueries .<AttributedType>createQuery(relationship.getClass()) .getSingleResult(); Attribute attribute = entryAttributes.get(mappingConfig.getMappedProperties().get(relationshipTypeProperty));
Attributes entryAttributes = this.operationManager.getAttributes(ownerType.getId(), getBaseDN(ownerType), mappingConfig); for (String relationshipTypeProperty : mappingConfig.getMappedProperties().keySet()) { Property<AttributedType> relationshipProperty = PropertyQueries .<AttributedType>createQuery(relationship.getClass()) .getSingleResult(); Attribute attribute = entryAttributes.get(mappingConfig.getMappedProperties().get(relationshipTypeProperty));
if (AttributeParameter.class.isInstance(queryParameter)) { AttributeParameter attributeParameter = (AttributeParameter) queryParameter; String attributeName = ldapEntryConfig.getMappedProperties().get(attributeParameter.getName());
if (AttributeParameter.class.isInstance(queryParameter)) { AttributeParameter attributeParameter = (AttributeParameter) queryParameter; String attributeName = ldapEntryConfig.getMappedProperties().get(attributeParameter.getName());
private String getRelationshipMappedProperty(Class<? extends IdentityType> identityType, LDAPMappingConfiguration mappingConfig) { final Property<Object> property = PropertyQueries.createQuery(mappingConfig.getMappedClass()).addCriteria(new TypedPropertyCriteria(identityType, MatchOption.ALL)).getFirstResult(); if (property == null) { return null; } return mappingConfig.getMappedProperties().get(property.getName()); }
private String getRelationshipMappedProperty(Class<? extends IdentityType> identityType, LDAPMappingConfiguration mappingConfig) { final Property<Object> property = PropertyQueries.createQuery(mappingConfig.getMappedClass()).addCriteria(new TypedPropertyCriteria(identityType, MatchOption.ALL)).getFirstResult(); if (property == null) { return null; } return mappingConfig.getMappedProperties().get(property.getName()); }
public String getBindingDN(AttributedType attributedType, boolean appendBaseDN) { LDAPMappingConfiguration mappingConfig = getMappingConfig(attributedType.getClass()); Property<String> idProperty = mappingConfig.getIdProperty(); String baseDN; if (mappingConfig.getBaseDN() == null || !appendBaseDN) { baseDN = ""; } else { baseDN = COMMA + getBaseDN(attributedType); } Property<String> bindingProperty = mappingConfig.getBindingProperty(); String bindingAttribute; String dn; if (bindingProperty == null) { bindingAttribute = mappingConfig.getMappedProperties().get(idProperty.getName()); dn = idProperty.getValue(attributedType); } else { bindingAttribute = mappingConfig.getMappedProperties().get(bindingProperty.getName()); dn = mappingConfig.getBindingProperty().getValue(attributedType); } return bindingAttribute + EQUAL + dn + baseDN; }
public String getBindingDN(AttributedType attributedType, boolean appendBaseDN) { LDAPMappingConfiguration mappingConfig = getMappingConfig(attributedType.getClass()); Property<String> idProperty = mappingConfig.getIdProperty(); String baseDN; if (mappingConfig.getBaseDN() == null || !appendBaseDN) { baseDN = ""; } else { baseDN = COMMA + getBaseDN(attributedType); } Property<String> bindingProperty = mappingConfig.getBindingProperty(); String bindingAttribute; String dn; if (bindingProperty == null) { bindingAttribute = mappingConfig.getMappedProperties().get(idProperty.getName()); dn = idProperty.getValue(attributedType); } else { bindingAttribute = mappingConfig.getMappedProperties().get(bindingProperty.getName()); dn = mappingConfig.getBindingProperty().getValue(attributedType); } return bindingAttribute + EQUAL + dn + baseDN; }
@Override protected Builder<LDAPMappingConfiguration> readFrom(LDAPMappingConfiguration fromConfiguration) { this.mappedClass = fromConfiguration.getMappedClass(); this.objectClasses.addAll(fromConfiguration.getObjectClasses()); this.baseDN = fromConfiguration.getBaseDN(); if (fromConfiguration.getIdProperty() != null) { this.idPropertyName = fromConfiguration.getIdProperty().getName(); } this.mappedProperties.putAll(fromConfiguration.getMappedProperties()); this.readOnlyAttributes.addAll(fromConfiguration.getReadOnlyAttributes()); this.parentMapping.putAll(fromConfiguration.getParentMapping()); this.relatedAttributedType = fromConfiguration.getRelatedAttributedType(); this.parentMembershipAttributeName = fromConfiguration.getParentMembershipAttributeName(); this.hierarchySearchDepth = fromConfiguration.getHierarchySearchDepth(); return this; }
@Override protected Builder<LDAPMappingConfiguration> readFrom(LDAPMappingConfiguration fromConfiguration) { this.mappedClass = fromConfiguration.getMappedClass(); this.objectClasses.addAll(fromConfiguration.getObjectClasses()); this.baseDN = fromConfiguration.getBaseDN(); if (fromConfiguration.getIdProperty() != null) { this.idPropertyName = fromConfiguration.getIdProperty().getName(); } this.mappedProperties.putAll(fromConfiguration.getMappedProperties()); this.readOnlyAttributes.addAll(fromConfiguration.getReadOnlyAttributes()); this.parentMapping.putAll(fromConfiguration.getParentMapping()); this.relatedAttributedType = fromConfiguration.getRelatedAttributedType(); this.parentMembershipAttributeName = fromConfiguration.getParentMembershipAttributeName(); this.hierarchySearchDepth = fromConfiguration.getHierarchySearchDepth(); return this; }
@Override protected void removeFromRelationships(final IdentityContext context, final IdentityType identityType) { String bindingDN = getBindingDN(identityType, true); for (LDAPMappingConfiguration relationshipConfig : getConfig().getRelationshipConfigs()) { for (String attributeName : relationshipConfig.getMappedProperties().values()) { StringBuilder filter = new StringBuilder(); filter.append("(&(").append(attributeName).append(EQUAL).append("").append(bindingDN).append("))"); try { List<SearchResult> search = this.operationManager.search(getMappingConfig(relationshipConfig.getRelatedAttributedType()).getBaseDN(), filter.toString(), getMappingConfig(relationshipConfig.getRelatedAttributedType())); for (SearchResult result : search) { Attributes attributes = result.getAttributes(); Attribute relationshipAttribute = attributes.get(attributeName); if (relationshipAttribute != null && relationshipAttribute.contains(bindingDN)) { relationshipAttribute.remove(bindingDN); if (relationshipAttribute.size() == 0) { relationshipAttribute.add(EMPTY_ATTRIBUTE_VALUE); } this.operationManager.modifyAttribute(result.getNameInNamespace(), relationshipAttribute); } } } catch (NamingException e) { throw new IdentityManagementException("Could not remove " + identityType + " from relationship " + relationshipConfig.getMappedClass(), e); } } } }
@Override protected void removeFromRelationships(final IdentityContext context, final IdentityType identityType) { String bindingDN = getBindingDN(identityType, true); for (LDAPMappingConfiguration relationshipConfig : getConfig().getRelationshipConfigs()) { for (String attributeName : relationshipConfig.getMappedProperties().values()) { StringBuilder filter = new StringBuilder(); filter.append("(&(").append(attributeName).append(EQUAL).append("").append(bindingDN).append("))"); try { List<SearchResult> search = this.operationManager.search(getMappingConfig(relationshipConfig.getRelatedAttributedType()).getBaseDN(), filter.toString(), getMappingConfig(relationshipConfig.getRelatedAttributedType())); for (SearchResult result : search) { Attributes attributes = result.getAttributes(); Attribute relationshipAttribute = attributes.get(attributeName); if (relationshipAttribute != null && relationshipAttribute.contains(bindingDN)) { relationshipAttribute.remove(bindingDN); if (relationshipAttribute.size() == 0) { relationshipAttribute.add(EMPTY_ATTRIBUTE_VALUE); } this.operationManager.modifyAttribute(result.getNameInNamespace(), relationshipAttribute); } } } catch (NamingException e) { throw new IdentityManagementException("Could not remove " + identityType + " from relationship " + relationshipConfig.getMappedClass(), e); } } } }
Attributes ownerAttributes = this.operationManager.getAttributes(ownerType.getId(), getBaseDN(ownerType), mappingConfig); for (String typeProperty : mappingConfig.getMappedProperties().keySet()) { Property<AttributedType> relProperty = PropertyQueries .<AttributedType>createQuery(relationship.getClass()) .getSingleResult(); Attribute mappedAttribute = ownerAttributes.get(mappingConfig.getMappedProperties().get(typeProperty));
Attributes ownerAttributes = this.operationManager.getAttributes(ownerType.getId(), getBaseDN(ownerType), mappingConfig); for (String typeProperty : mappingConfig.getMappedProperties().keySet()) { Property<AttributedType> relProperty = PropertyQueries .<AttributedType>createQuery(relationship.getClass()) .getSingleResult(); Attribute mappedAttribute = ownerAttributes.get(mappingConfig.getMappedProperties().get(typeProperty));
attributeName = mappingConfig.getMappedProperties().get(relationshipQueryParameter.getName()); } else if (Relationship.IDENTITY.equals(queryParameter)) { IdentityType identityType = (IdentityType) values[0]; AttributedType ownerType = populateAttributedType(entry, null); for (Entry<String, String> memberAttribute : mappingConfig.getMappedProperties().entrySet()) { String attributeName = memberAttribute.getValue(); Attribute attribute = ownerAttributes.get(attributeName);
protected BasicAttributes extractAttributes(AttributedType attributedType, boolean isCreate) { BasicAttributes entryAttributes = new BasicAttributes(); LDAPMappingConfiguration mappingConfig = getMappingConfig(attributedType.getClass()); Map<String, String> mappedProperties = mappingConfig.getMappedProperties();
protected BasicAttributes extractAttributes(AttributedType attributedType, boolean isCreate) { BasicAttributes entryAttributes = new BasicAttributes(); LDAPMappingConfiguration mappingConfig = getMappingConfig(attributedType.getClass()); Map<String, String> mappedProperties = mappingConfig.getMappedProperties();
attributedType.setId(this.operationManager.decodeEntryUUID(attributeValue)); } else { String attributeName = findAttributeName(mappingConfig.getMappedProperties(), ldapAttributeName);