Search in sources :

Example 1 with LdapConnectionField

use of org.codice.ddf.admin.ldap.fields.connection.LdapConnectionField 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 LdapConnectionField

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

the class LdapServiceCommons method getLdapConnectionField.

private LdapConnectionField getLdapConnectionField(String url, Boolean startTls) {
    LdapConnectionField connection = new LdapConnectionField();
    URI ldapUri = getUriFromProperty(url);
    if (ldapUri != null && ldapUri.getScheme() != null) {
        // TODO: tbatie - 8/17/17 - It'd be great if we had some sort of match method in the EnumValue
        // instead of doing little checks like this
        connection.encryptionMethod(ldapUri.getScheme().equals("ldap") ? LdapEncryptionMethodField.NoEncryption.NONE : ldapUri.getScheme()).hostname(ldapUri.getHost()).port(ldapUri.getPort());
    }
    if (startTls) {
        connection.encryptionMethod(LdapLoginServiceProperties.START_TLS);
    }
    return connection;
}
Also used : LdapConnectionField(org.codice.ddf.admin.ldap.fields.connection.LdapConnectionField) URI(java.net.URI)

Example 3 with LdapConnectionField

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

the class ITAdminSecurity method createSampleLdapConfiguration.

public LdapConfigurationField createSampleLdapConfiguration(EnumValue<String> ldapUseCase) {
    LdapConfigurationField newConfig = new LdapConfigurationField();
    CredentialsField creds = new CredentialsField().username(TEST_USERNAME).password(TEST_PASSWORD);
    LdapBindUserInfo bindUserInfo = new LdapBindUserInfo().bindMethod(SimpleEnumValue.SIMPLE).credentialsField(creds);
    LdapConnectionField connection = new LdapConnectionField().encryptionMethod(LdapEncryptionMethodField.NoEncryption.NONE).hostname("testHostName").port(666);
    LdapConnectionField.ListImpl connections = new LdapConnectionField.ListImpl();
    connections.add(connection);
    LdapDirectorySettingsField dirSettings = new LdapDirectorySettingsField().baseUserDn(TEST_DN).loginUserAttribute(TEST_ATTRIBUTE).memberAttributeReferencedInGroup(TEST_ATTRIBUTE).baseGroupDn(TEST_DN).groupAttributeHoldingMember(TEST_ATTRIBUTE).useCase(ldapUseCase.getValue());
    if (ldapUseCase.getValue().equals(LdapUseCase.ATTRIBUTE_STORE.getValue()) || ldapUseCase.getValue().equals(LdapUseCase.AUTHENTICATION_AND_ATTRIBUTE_STORE.getValue())) {
        dirSettings.groupObjectClass(TEST_ATTRIBUTE);
        newConfig.claimMappingsField(new ClaimsMapEntry.ListImpl().add(new ClaimsMapEntry().key(TEST_CLAIM_KEY).value(TEST_CLAIM_VALUE)));
    }
    return newConfig.connections(connections).bindUserInfo(bindUserInfo).settings(dirSettings);
}
Also used : ClaimsMapEntry(org.codice.ddf.admin.security.common.fields.wcpm.ClaimsMapEntry) 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) LdapDirectorySettingsField(org.codice.ddf.admin.ldap.fields.config.LdapDirectorySettingsField) CredentialsField(org.codice.ddf.admin.common.fields.common.CredentialsField)

Example 4 with LdapConnectionField

use of org.codice.ddf.admin.ldap.fields.connection.LdapConnectionField 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

LdapConnectionField (org.codice.ddf.admin.ldap.fields.connection.LdapConnectionField)4 URI (java.net.URI)3 LdapConfigurationField (org.codice.ddf.admin.ldap.fields.config.LdapConfigurationField)3 LdapBindUserInfo (org.codice.ddf.admin.ldap.fields.connection.LdapBindUserInfo)3 LdapSettingsField (org.codice.ddf.admin.ldap.fields.config.LdapSettingsField)2 HashMap (java.util.HashMap)1 CredentialsField (org.codice.ddf.admin.common.fields.common.CredentialsField)1 LdapDirectorySettingsField (org.codice.ddf.admin.ldap.fields.config.LdapDirectorySettingsField)1 ClaimsMapEntry (org.codice.ddf.admin.security.common.fields.wcpm.ClaimsMapEntry)1