.baseDN(ldapConfig.get(LDAPConstants.USER_DN_SUFFIX)) .objectClasses(userObjectClasses) .attribute("loginName", ldapLoginNameMapping, true) .attribute("firstName", ldapFirstNameMapping) .attribute("lastName", SN) .attribute("email", EMAIL) .readOnlyAttribute("createdDate", createTimestampMapping) .readOnlyAttribute("modifyDate", modifyTimestampMapping); ldapUserMappingBuilder.bindingAttribute("fullName", CN); logger.infof("Using 'cn' attribute for DN of user and 'sAMAccountName' for username");
/** * <p>Maps a specific {@link AttributedType}.</p> * * @param attributedType * @return */ public LDAPMappingConfigurationBuilder mapping(Class<? extends AttributedType> attributedType) { LDAPMappingConfigurationBuilder ldapMappingConfigurationBuilder = new LDAPMappingConfigurationBuilder(attributedType, this); this.mappingBuilders.add(ldapMappingConfigurationBuilder); supportType(attributedType); if (Relationship.class.isAssignableFrom(attributedType)) { supportGlobalRelationship((Class <? extends Relationship>) attributedType); } return ldapMappingConfigurationBuilder; }
storeMapping.forMapping((Class<? extends AttributedType>) loadClass(alternativeModule, relatesTo.asString())); } catch (ClassNotFoundException e) { throw new RuntimeException("Could not load LDAP mapped class [" + mappingClass + "].", e); String baseDN = mappingModelNode.get(ModelElement.LDAP_STORE_MAPPING_BASE_DN.getName()).asString(); storeMapping.baseDN(baseDN); storeMapping.objectClasses(objClass); storeMapping.parentMembershipAttributeName(parentAttributeName.asString()); storeMapping.readOnlyAttribute(name, ldapName); } else { ModelNode identifierModelNode = attributeModel.get(ModelElement.LDAP_STORE_ATTRIBUTE_IS_IDENTIFIER.getName()); storeMapping.attribute(name, ldapName, isIdentifier);
/** * <p>Maps a type property to a specific LDAP attribute and mark it as an identifier.</p> * * @param propertyName * @param ldapAttributeName * @param identifier * * @return */ public LDAPMappingConfigurationBuilder attribute(@ParameterConfigID(name = "propertyName") String propertyName, @ParameterConfigID(name = "ldapAttributeName") String ldapAttributeName, @ParameterConfigID(name = "identifier") boolean identifier) { attribute(propertyName, ldapAttributeName); if (identifier) { this.idPropertyName = propertyName; } return this; }
@Override protected LDAPStoreConfigurationBuilder readFrom(LDAPIdentityStoreConfiguration configuration) { super.readFrom(configuration); this.baseDN = configuration.getBaseDN(); this.bindCredential = configuration.getBindCredential(); this.bindDN = configuration.getBindDN(); this.url = configuration.getLdapURL(); this.activeDirectory = configuration.isActiveDirectory(); this.connectionProperties = configuration.getConnectionProperties(); this.pagination = configuration.isPagination(); this.uniqueIdentifierAttributeName = configuration.getUniqueIdentifierAttributeName(); for (Class<? extends AttributedType> attributedType: configuration.getMappingConfig().keySet()) { LDAPMappingConfiguration mappingConfiguration = configuration.getMappingConfig().get(attributedType); mapping(attributedType).readFrom(mappingConfiguration); } return this; } }
@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()); }
storeMapping.forMapping(this.<AttributedType>loadClass(moduleNode, relatesTo)); } else { String baseDN = LDAPStoreMappingResourceDefinition.BASE_DN.resolveModelAttribute(context, ldapMapping) .asString(); storeMapping.baseDN(baseDN); storeMapping.objectClasses(objClass); storeMapping.parentMembershipAttributeName(parentAttributeName.asString()); storeMapping.readOnlyAttribute(name, ldapName); } else { boolean isIdentifier = LDAPStoreAttributeResourceDefinition.IS_IDENTIFIER .resolveModelAttribute(context, attribute).asBoolean(); storeMapping.attribute(name, ldapName, isIdentifier);
/** * <p>Maps a type property to a specific LDAP attribute and mark it as an identifier.</p> * * @param propertyName * @param ldapAttributeName * @param identifier * * @return */ public LDAPMappingConfigurationBuilder attribute(@ParameterConfigID(name = "propertyName") String propertyName, @ParameterConfigID(name = "ldapAttributeName") String ldapAttributeName, @ParameterConfigID(name = "identifier") boolean identifier) { attribute(propertyName, ldapAttributeName); if (identifier) { this.idPropertyName = propertyName; } return this; }
@Override protected LDAPStoreConfigurationBuilder readFrom(LDAPIdentityStoreConfiguration configuration) { super.readFrom(configuration); this.baseDN = configuration.getBaseDN(); this.bindCredential = configuration.getBindCredential(); this.bindDN = configuration.getBindDN(); this.url = configuration.getLdapURL(); this.activeDirectory = configuration.isActiveDirectory(); this.connectionProperties = configuration.getConnectionProperties(); this.pagination = configuration.isPagination(); this.uniqueIdentifierAttributeName = configuration.getUniqueIdentifierAttributeName(); for (Class<? extends AttributedType> attributedType: configuration.getMappingConfig().keySet()) { LDAPMappingConfiguration mappingConfiguration = configuration.getMappingConfig().get(attributedType); mapping(attributedType).readFrom(mappingConfiguration); } return this; } }
@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()); }
storeMapping.forMapping(this.<AttributedType>loadClass(moduleNode, relatesTo)); } else { String baseDN = LDAPStoreMappingResourceDefinition.BASE_DN.resolveModelAttribute(context, ldapMapping) .asString(); storeMapping.baseDN(baseDN); storeMapping.objectClasses(objClass); storeMapping.parentMembershipAttributeName(parentAttributeName.asString()); storeMapping.readOnlyAttribute(name, ldapName); } else { boolean isIdentifier = LDAPStoreAttributeResourceDefinition.IS_IDENTIFIER .resolveModelAttribute(context, attribute).asBoolean(); storeMapping.attribute(name, ldapName, isIdentifier);
/** * <p>Maps a specific {@link AttributedType}.</p> * * @param attributedType * @return */ public LDAPMappingConfigurationBuilder mapping(Class<? extends AttributedType> attributedType) { LDAPMappingConfigurationBuilder ldapMappingConfigurationBuilder = new LDAPMappingConfigurationBuilder(attributedType, this); this.mappingBuilders.add(ldapMappingConfigurationBuilder); supportType(attributedType); if (Relationship.class.isAssignableFrom(attributedType)) { supportGlobalRelationship((Class <? extends Relationship>) attributedType); } return ldapMappingConfigurationBuilder; }