public LDAPMappingConfiguration getMappingConfig(Class<? extends AttributedType> attributedType) { for (LDAPMappingConfiguration mappingConfig : this.mappingConfig.values()) { if (attributedType.equals(mappingConfig.getMappedClass())) { return mappingConfig; } } return null; }
public LDAPMappingConfiguration getMappingConfig(Class<? extends AttributedType> attributedType) { for (LDAPMappingConfiguration mappingConfig : this.mappingConfig.values()) { if (attributedType.equals(mappingConfig.getMappedClass())) { return mappingConfig; } } return null; }
public Class<? extends AttributedType> getSupportedTypeByBaseDN(String entryDN, List<String> objectClasses) { String entryBaseDN = entryDN.substring(entryDN.indexOf(COMMA) + 1); for (LDAPMappingConfiguration mappingConfig : this.mappingConfig.values()) { if (mappingConfig.getBaseDN() != null) { if (!Relationship.class.isAssignableFrom(mappingConfig.getMappedClass())) { if (mappingConfig.getBaseDN().equalsIgnoreCase(entryDN) || mappingConfig.getParentMapping().values().contains(entryDN)) { return mappingConfig.getMappedClass(); } if (mappingConfig.getBaseDN().equalsIgnoreCase(entryBaseDN) || mappingConfig.getParentMapping().values().contains(entryBaseDN)) { return mappingConfig.getMappedClass(); } } } } for (LDAPMappingConfiguration mappingConfig : this.mappingConfig.values()) { if (!Relationship.class.isAssignableFrom(mappingConfig.getMappedClass())) { for (String objectClass : objectClasses) { if (mappingConfig.getObjectClasses().contains(objectClass)) { return mappingConfig.getMappedClass(); } } } } throw new IdentityManagementException("No type found with Base DN [" + entryDN + "] or objectClasses [" + objectClasses + "."); }
public Class<? extends AttributedType> getSupportedTypeByBaseDN(String entryDN, List<String> objectClasses) { String entryBaseDN = entryDN.substring(entryDN.indexOf(COMMA) + 1); for (LDAPMappingConfiguration mappingConfig : this.mappingConfig.values()) { if (mappingConfig.getBaseDN() != null) { if (!Relationship.class.isAssignableFrom(mappingConfig.getMappedClass())) { if (mappingConfig.getBaseDN().equalsIgnoreCase(entryDN) || mappingConfig.getParentMapping().values().contains(entryDN)) { return mappingConfig.getMappedClass(); } if (mappingConfig.getBaseDN().equalsIgnoreCase(entryBaseDN) || mappingConfig.getParentMapping().values().contains(entryBaseDN)) { return mappingConfig.getMappedClass(); } } } } for (LDAPMappingConfiguration mappingConfig : this.mappingConfig.values()) { if (!Relationship.class.isAssignableFrom(mappingConfig.getMappedClass())) { for (String objectClass : objectClasses) { if (mappingConfig.getObjectClasses().contains(objectClass)) { return mappingConfig.getMappedClass(); } } } } throw new IdentityManagementException("No type found with Base DN [" + entryDN + "] or objectClasses [" + objectClasses + "."); }
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; } }
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()); }
@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); } } } }
private <V extends Relationship> List<V> fetchRelationships(final RelationshipQuery<V> query, final LDAPMappingConfiguration mappingConfig) { List<V> results = new ArrayList<V>(); Class<V> relationshipClass = (Class<V>) mappingConfig.getMappedClass(); Map<QueryParameter, Object[]> parameters = query.getParameters(); LDAPMappingConfiguration relatedTypeConfig = getMappingConfig(mappingConfig.getRelatedAttributedType()); bindingDN = result.getNameInNamespace(); if (!attributedType.getClass().equals(relatedTypeConfig.getMappedClass())) { entriesToFilter.add(bindingDN); boolean filterByOwner = attributedType.getClass().equals(relatedTypeConfig.getMappedClass()); filterByOwner = property.getJavaClass().equals(relatedTypeConfig.getMappedClass());
@Override protected LDAPIdentityStoreConfiguration create() { Map<Class<? extends AttributedType>, LDAPMappingConfiguration> mappingConfig = new HashMap<Class<? extends AttributedType>, LDAPMappingConfiguration>(); for (LDAPMappingConfigurationBuilder builder: this.mappingBuilders) { LDAPMappingConfiguration ldapMappingConfiguration = builder.create(); mappingConfig.put(ldapMappingConfiguration.getMappedClass(), ldapMappingConfiguration); } return new LDAPIdentityStoreConfiguration( this.url, this.connectionProperties, this.bindDN, this.bindCredential, this.baseDN, this.activeDirectory, this.pagination, this.uniqueIdentifierAttributeName, mappingConfig, getSupportedTypes(), getUnsupportedTypes(), getContextInitializers(), getCredentialHandlerProperties(), getCredentialHandlers(), isSupportCredentials()); }
@Override protected LDAPIdentityStoreConfiguration create() { Map<Class<? extends AttributedType>, LDAPMappingConfiguration> mappingConfig = new HashMap<Class<? extends AttributedType>, LDAPMappingConfiguration>(); for (LDAPMappingConfigurationBuilder builder: this.mappingBuilders) { LDAPMappingConfiguration ldapMappingConfiguration = builder.create(); mappingConfig.put(ldapMappingConfiguration.getMappedClass(), ldapMappingConfiguration); } return new LDAPIdentityStoreConfiguration( this.url, this.connectionProperties, this.bindDN, this.bindCredential, this.baseDN, this.activeDirectory, this.pagination, this.uniqueIdentifierAttributeName, mappingConfig, getSupportedTypes(), getUnsupportedTypes(), getContextInitializers(), getCredentialHandlerProperties(), getCredentialHandlers(), isSupportCredentials()); }
private <V extends Relationship> List<V> fetchRelationships(final RelationshipQuery<V> query, final LDAPMappingConfiguration mappingConfig) { List<V> results = new ArrayList<V>(); Class<V> relationshipClass = (Class<V>) mappingConfig.getMappedClass(); Map<QueryParameter, Object[]> parameters = query.getParameters(); LDAPMappingConfiguration relatedTypeConfig = getMappingConfig(mappingConfig.getRelatedAttributedType()); bindingDN = result.getNameInNamespace(); if (!attributedType.getClass().equals(relatedTypeConfig.getMappedClass())) { entriesToFilter.add(bindingDN); boolean filterByOwner = attributedType.getClass().equals(relatedTypeConfig.getMappedClass()); filterByOwner = property.getJavaClass().equals(relatedTypeConfig.getMappedClass());
.<String>createQuery(getMappedClass()) .addCriteria(new NamedPropertyCriteria(idPropertyName)).getFirstResult(); } else {
.<String>createQuery(getMappedClass()) .addCriteria(new NamedPropertyCriteria(idPropertyName)).getFirstResult(); } else {
private Property getBindingProperty(final String bindingPropertyName) { Property bindingProperty = PropertyQueries .<String>createQuery(getMappedClass()) .addCriteria(new NamedPropertyCriteria(bindingPropertyName)).getFirstResult();
private Property getBindingProperty(final String bindingPropertyName) { Property bindingProperty = PropertyQueries .<String>createQuery(getMappedClass()) .addCriteria(new NamedPropertyCriteria(bindingPropertyName)).getFirstResult();