@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; } }
private Map<String, Object> createConnectionProperties() { HashMap<String, Object> env = new HashMap<String, Object>(); env.put(Context.INITIAL_CONTEXT_FACTORY, this.config.getFactoryName()); env.put(Context.SECURITY_AUTHENTICATION, this.config.getAuthType()); String protocol = this.config.getProtocol(); String bindDN = this.config.getBindDN(); if (this.config.getBindCredential() != null) { bindCredential = this.config.getBindCredential().toCharArray(); String url = this.config.getLdapURL(); Properties additionalProperties = this.config.getConnectionProperties(); if (config.isActiveDirectory()) { env.put("java.naming.ldap.attributes.binary", LDAPConstants.OBJECT_GUID);
attributedType = newInstance(getConfig().getSupportedTypeByBaseDN(entryDN, getEntryObjectClasses(attributes))); if (ldapAttributeName.toLowerCase().equals(getConfig().getUniqueIdentifierAttributeName().toLowerCase())) { attributedType.setId(this.operationManager.decodeEntryUUID(attributeValue)); } else { List<SearchResult> search = this.operationManager.search(getConfig().getBaseDN(), filter.toString(), entryConfig); String parentDN = next.getNameInNamespace(); String parentBaseDN = parentDN.substring(parentDN.indexOf(",") + 1); Class<? extends AttributedType> baseDNType = getConfig().getSupportedTypeByBaseDN(parentBaseDN, getEntryObjectClasses(attributes));
public String decodeEntryUUID(final Object entryUUID) { String id; if (this.config.isActiveDirectory()) { id = LDAPUtil.decodeObjectGUID((byte[]) entryUUID); } else { id = entryUUID.toString(); } return id; }
EqualCondition equalCondition = (EqualCondition) condition; SearchResult search = this.operationManager .lookupById(getConfig().getBaseDN(), equalCondition.getValue().toString(), null); List<SearchResult> search; if (getConfig().isPagination() && identityQuery.getLimit() > 0) { search = this.operationManager.searchPaginated(baseDN, filter.toString(), ldapEntryConfig, identityQuery); } else {
private String getBaseDN(final LDAPMappingConfiguration ldapEntryConfig) { String baseDN = getConfig().getBaseDN(); if (ldapEntryConfig.getBaseDN() != null) { baseDN = ldapEntryConfig.getBaseDN(); } return baseDN; }
private String getUniqueIdentifierAttributeName() { return this.config.getUniqueIdentifierAttributeName(); }
private LDAPMappingConfiguration getMappingConfig(Class<? extends AttributedType> attributedType) { LDAPMappingConfiguration mappingConfig = getConfig().getMappingConfig(attributedType); if (mappingConfig == null) { throw new IdentityManagementException("Not mapped type [" + attributedType + "]."); } return mappingConfig; }
@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 Map<String, Object> createConnectionProperties() { HashMap<String, Object> env = new HashMap<String, Object>(); env.put(Context.INITIAL_CONTEXT_FACTORY, this.config.getFactoryName()); env.put(Context.SECURITY_AUTHENTICATION, this.config.getAuthType()); String protocol = this.config.getProtocol(); String bindDN = this.config.getBindDN(); if (this.config.getBindCredential() != null) { bindCredential = this.config.getBindCredential().toCharArray(); String url = this.config.getLdapURL(); Properties additionalProperties = this.config.getConnectionProperties(); if (config.isActiveDirectory()) { env.put("java.naming.ldap.attributes.binary", LDAPConstants.OBJECT_GUID);
attributedType = newInstance(getConfig().getSupportedTypeByBaseDN(entryDN, getEntryObjectClasses(attributes))); if (ldapAttributeName.toLowerCase().equals(getConfig().getUniqueIdentifierAttributeName().toLowerCase())) { attributedType.setId(this.operationManager.decodeEntryUUID(attributeValue)); } else { List<SearchResult> search = this.operationManager.search(getConfig().getBaseDN(), filter.toString(), entryConfig); String parentDN = next.getNameInNamespace(); String parentBaseDN = parentDN.substring(parentDN.indexOf(",") + 1); Class<? extends AttributedType> baseDNType = getConfig().getSupportedTypeByBaseDN(parentBaseDN, getEntryObjectClasses(attributes));
public String decodeEntryUUID(final Object entryUUID) { String id; if (this.config.isActiveDirectory()) { id = LDAPUtil.decodeObjectGUID((byte[]) entryUUID); } else { id = entryUUID.toString(); } return id; }
EqualCondition equalCondition = (EqualCondition) condition; SearchResult search = this.operationManager .lookupById(getConfig().getBaseDN(), equalCondition.getValue().toString(), null); List<SearchResult> search; if (getConfig().isPagination() && identityQuery.getLimit() > 0) { search = this.operationManager.searchPaginated(baseDN, filter.toString(), ldapEntryConfig, identityQuery); } else {
private String getBaseDN(final LDAPMappingConfiguration ldapEntryConfig) { String baseDN = getConfig().getBaseDN(); if (ldapEntryConfig.getBaseDN() != null) { baseDN = ldapEntryConfig.getBaseDN(); } return baseDN; }
private String getUniqueIdentifierAttributeName() { return this.config.getUniqueIdentifierAttributeName(); }
private LDAPMappingConfiguration getMappingConfig(Class<? extends AttributedType> attributedType) { LDAPMappingConfiguration mappingConfig = getConfig().getMappingConfig(attributedType); if (mappingConfig == null) { throw new IdentityManagementException("Not mapped type [" + attributedType + "]."); } return mappingConfig; }
@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 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; } }
public String getFilterById(String baseDN, String id) { String filter = null; if (this.config.isActiveDirectory()) { final String strObjectGUID = "<GUID=" + id + ">"; try { Attributes attributes = execute(new LdapOperation<Attributes>() { @Override public Attributes execute(LdapContext context) throws NamingException { return context.getAttributes(strObjectGUID); } }); byte[] objectGUID = (byte[]) attributes.get(LDAPConstants.OBJECT_GUID).get(); filter = "(&(objectClass=*)(" + getUniqueIdentifierAttributeName() + EQUAL + convertObjectGUIToByteString(objectGUID) + "))"; } catch (NamingException ne) { return filter; } } if (filter == null) { filter = "(&(objectClass=*)(" + getUniqueIdentifierAttributeName() + EQUAL + id + "))"; } return filter; }
private String getBaseDN(AttributedType attributedType) { LDAPMappingConfiguration mappingConfig = getMappingConfig(attributedType.getClass()); String baseDN = mappingConfig.getBaseDN(); String parentDN = mappingConfig.getParentMapping().get(mappingConfig.getIdProperty().getValue(attributedType)); if (parentDN != null) { baseDN = parentDN; } else { Property<AttributedType> parentProperty = PropertyQueries .<AttributedType>createQuery(attributedType.getClass()) .addCriteria(new TypedPropertyCriteria(attributedType.getClass())).getFirstResult(); if (parentProperty != null) { AttributedType parentType = parentProperty.getValue(attributedType); if (parentType != null) { Property<String> parentIdProperty = getMappingConfig(parentType.getClass()).getIdProperty(); String parentId = parentIdProperty.getValue(parentType); String parentBaseDN = mappingConfig.getParentMapping().get(parentId); if (parentBaseDN != null) { baseDN = parentBaseDN; } else { baseDN = getBaseDN(parentType); } } } } if (baseDN == null) { baseDN = getConfig().getBaseDN(); } return baseDN; }