Search in sources :

Example 1 with LdapSettingsField

use of org.codice.ddf.admin.ldap.fields.config.LdapSettingsField in project admin-console-beta by connexta.

the class LdapServiceCommons method ldapLoginServiceToLdapConfiguration.

public LdapConfigurationField ldapLoginServiceToLdapConfiguration(Map<String, Object> props) {
    LdapConnectionField connection = new LdapConnectionField();
    URI ldapUri = getUriFromProperty(mapStringValue(LdapLoginServiceProperties.LDAP_URL, props));
    if (ldapUri != null) {
        connection.encryptionMethod(ldapUri.getScheme()).hostname(ldapUri.getHost()).port(ldapUri.getPort());
    }
    if ((Boolean) props.get(LdapLoginServiceProperties.START_TLS)) {
        connection.encryptionMethod(LdapLoginServiceProperties.START_TLS);
    }
    LdapBindUserInfo bindUserInfo = new LdapBindUserInfo().username(mapStringValue(LdapLoginServiceProperties.LDAP_BIND_USER_DN, props)).password(mapStringValue(LdapLoginServiceProperties.LDAP_BIND_USER_PASS, props)).bindMethod(mapStringValue(LdapLoginServiceProperties.BIND_METHOD, props)).realm(mapStringValue(LdapLoginServiceProperties.REALM, props));
    //        ldapConfiguration.bindKdcAddress((String) props.get(KDC_ADDRESS));
    LdapSettingsField settings = new LdapSettingsField().usernameAttribute(mapStringValue(LdapLoginServiceProperties.USER_NAME_ATTRIBUTE, props)).baseUserDn(mapStringValue(LdapLoginServiceProperties.USER_BASE_DN, props)).baseGroupDn(mapStringValue(LdapLoginServiceProperties.GROUP_BASE_DN, props)).useCase(LOGIN);
    return new LdapConfigurationField().connection(connection).bindUserInfo(bindUserInfo).settings(settings).pid(mapStringValue(SERVICE_PID_KEY, props));
}
Also used : LdapConfigurationField(org.codice.ddf.admin.ldap.fields.config.LdapConfigurationField) LdapConnectionField(org.codice.ddf.admin.ldap.fields.connection.LdapConnectionField) LdapBindUserInfo(org.codice.ddf.admin.ldap.fields.connection.LdapBindUserInfo) LdapSettingsField(org.codice.ddf.admin.ldap.fields.config.LdapSettingsField) URI(java.net.URI)

Example 2 with LdapSettingsField

use of org.codice.ddf.admin.ldap.fields.config.LdapSettingsField in project admin-console-beta by connexta.

the class LdapServiceCommons method ldapClaimsHandlerServiceToLdapConfig.

public LdapConfigurationField ldapClaimsHandlerServiceToLdapConfig(Map<String, Object> props) {
    LdapConnectionField connection = new LdapConnectionField();
    URI ldapUri = getUriFromProperty((String) props.get(LdapClaimsHandlerServiceProperties.URL));
    if (ldapUri != null) {
        connection.encryptionMethod(ldapUri.getScheme()).hostname(ldapUri.getHost()).port(ldapUri.getPort());
    }
    if ((Boolean) props.get(LdapClaimsHandlerServiceProperties.START_TLS)) {
        connection.encryptionMethod(LdapClaimsHandlerServiceProperties.START_TLS);
    }
    LdapBindUserInfo bindUserInfo = new LdapBindUserInfo().username(mapStringValue(LdapClaimsHandlerServiceProperties.LDAP_BIND_USER_DN, props)).password(mapStringValue(LdapClaimsHandlerServiceProperties.PASSWORD, props)).bindMethod(mapStringValue(LdapClaimsHandlerServiceProperties.BIND_METHOD, props));
    LdapSettingsField settings = new LdapSettingsField().usernameAttribute(mapStringValue(LdapClaimsHandlerServiceProperties.LOGIN_USER_ATTRIBUTE, props)).baseUserDn(mapStringValue(LdapClaimsHandlerServiceProperties.USER_BASE_DN, props)).baseGroupDn(mapStringValue(LdapClaimsHandlerServiceProperties.GROUP_BASE_DN, props)).groupObjectClass(mapStringValue(LdapClaimsHandlerServiceProperties.OBJECT_CLASS, props)).groupAttributeHoldingMember(mapStringValue(LdapClaimsHandlerServiceProperties.MEMBERSHIP_USER_ATTRIBUTE, props)).memberAttributeReferencedInGroup(mapStringValue(LdapClaimsHandlerServiceProperties.MEMBER_NAME_ATTRIBUTE, props)).useCase(ATTRIBUTE_STORE);
    String attributeMappingsPath = mapStringValue(LdapClaimsHandlerServiceProperties.PROPERTY_FILE_LOCATION, props);
    if (StringUtils.isNotEmpty(attributeMappingsPath)) {
        // TODO: tbatie - 5/26/17 - Need to check if this path exists before trying to read. If it doesn't don't populate the attributeMappings field
        Map<String, String> attributeMappings = new HashMap<>(configuratorFactory.getConfigReader().getProperties(Paths.get(attributeMappingsPath)));
        settings.attributeMapField(attributeMappings);
    }
    return new LdapConfigurationField().connection(connection).bindUserInfo(bindUserInfo).settings(settings).pid(props.get(ServiceCommons.SERVICE_PID_KEY) == null ? null : (String) props.get(ServiceCommons.SERVICE_PID_KEY));
}
Also used : HashMap(java.util.HashMap) LdapConfigurationField(org.codice.ddf.admin.ldap.fields.config.LdapConfigurationField) LdapConnectionField(org.codice.ddf.admin.ldap.fields.connection.LdapConnectionField) LdapBindUserInfo(org.codice.ddf.admin.ldap.fields.connection.LdapBindUserInfo) LdapSettingsField(org.codice.ddf.admin.ldap.fields.config.LdapSettingsField) URI(java.net.URI)

Aggregations

URI (java.net.URI)2 LdapConfigurationField (org.codice.ddf.admin.ldap.fields.config.LdapConfigurationField)2 LdapSettingsField (org.codice.ddf.admin.ldap.fields.config.LdapSettingsField)2 LdapBindUserInfo (org.codice.ddf.admin.ldap.fields.connection.LdapBindUserInfo)2 LdapConnectionField (org.codice.ddf.admin.ldap.fields.connection.LdapConnectionField)2 HashMap (java.util.HashMap)1