Search in sources :

Example 6 with LdapConfigurationField

use of org.codice.ddf.admin.ldap.fields.config.LdapConfigurationField 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)

Example 7 with LdapConfigurationField

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

the class ITAdminSecurity method saveLdapAuthenticationAndAttributeStoreConfig.

@Test
public void saveLdapAuthenticationAndAttributeStoreConfig() throws IOException {
    try {
        LdapConfigurationField newConfig = createSampleLdapConfiguration(LdapUseCase.AUTHENTICATION_AND_ATTRIBUTE_STORE);
        List<Map<String, Object>> expectedConfigs = ImmutableList.of(createSampleLdapConfiguration(LdapUseCase.AUTHENTICATION).getValue(), createSampleLdapConfiguration(LdapUseCase.ATTRIBUTE_STORE).getValue());
        LDAP_REQUEST_HELPER.createLdapConfig(newConfig);
        LDAP_REQUEST_HELPER.waitForConfigs(expectedConfigs, true);
    } finally {
        LDAP_REQUEST_HELPER.resetLdapConfigs();
    }
}
Also used : LdapConfigurationField(org.codice.ddf.admin.ldap.fields.config.LdapConfigurationField) Map(java.util.Map) Test(org.junit.Test)

Example 8 with LdapConfigurationField

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

the class ITAdminSecurity method saveLdapAuthenticationConfig.

@Test
public void saveLdapAuthenticationConfig() throws IOException {
    try {
        LdapConfigurationField newConfig = createSampleLdapConfiguration(LdapUseCase.AUTHENTICATION);
        LDAP_REQUEST_HELPER.createLdapConfig(newConfig);
        LDAP_REQUEST_HELPER.waitForConfigs(Collections.singletonList(newConfig.getValue()), true);
    } finally {
        LDAP_REQUEST_HELPER.resetLdapConfigs();
    }
}
Also used : LdapConfigurationField(org.codice.ddf.admin.ldap.fields.config.LdapConfigurationField) Test(org.junit.Test)

Example 9 with LdapConfigurationField

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

the class LdapServiceCommons method ldapLoginServiceToLdapConfiguration.

private LdapConfigurationField ldapLoginServiceToLdapConfiguration(Map<String, Object> props) {
    LdapConnectionField.ListImpl connections = getLdapConnectionsField(props, LdapLoginServiceProperties.LDAP_URL, LdapLoginServiceProperties.START_TLS);
    LdapLoadBalancingField loadBalancing = new LdapLoadBalancingField();
    loadBalancing.setValue(mapValue(props, LdapLoginServiceProperties.LDAP_LOAD_BALANCING));
    LdapBindUserInfo bindUserInfo = new LdapBindUserInfo().username(mapValue(props, LdapLoginServiceProperties.LDAP_BIND_USER_DN)).password(FLAG_PASSWORD).bindMethod(mapValue(props, LdapLoginServiceProperties.BIND_METHOD));
    if (bindUserInfo.bindMethod() == LdapBindMethod.DigestMd5Sasl.DIGEST_MD5_SASL) {
        bindUserInfo.realm(mapValue(props, LdapLoginServiceProperties.REALM));
    }
    // ldapConfiguration.bindKdcAddress((String) props.get(KDC_ADDRESS))
    LdapDirectorySettingsField settings = new LdapDirectorySettingsField().loginUserAttribute(mapValue(props, LdapLoginServiceProperties.LOGIN_USER_ATTRIBUTE)).memberAttributeReferencedInGroup(mapValue(props, LdapLoginServiceProperties.MEMBERSHIP_USER_ATTRIBUTE)).groupAttributeHoldingMember(mapValue(props, LdapLoginServiceProperties.MEMBER_NAME_ATTRIBUTE)).baseUserDn(mapValue(props, LdapLoginServiceProperties.USER_BASE_DN)).baseGroupDn(mapValue(props, LdapLoginServiceProperties.GROUP_BASE_DN)).useCase(AUTHENTICATION);
    return new LdapConfigurationField().connections(connections).loadBalancing(loadBalancing).bindUserInfo(bindUserInfo).settings(settings).pid(mapValue(props, SERVICE_PID_KEY));
}
Also used : LdapLoadBalancingField(org.codice.ddf.admin.ldap.fields.connection.LdapLoadBalancingField) 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)

Example 10 with LdapConfigurationField

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

the class LdapServiceCommons method ldapClaimsHandlerServiceToLdapConfig.

private LdapConfigurationField ldapClaimsHandlerServiceToLdapConfig(Map<String, Object> props) {
    LdapConnectionField.ListImpl connections = getLdapConnectionsField(props, LdapClaimsHandlerServiceProperties.URL, LdapClaimsHandlerServiceProperties.START_TLS);
    LdapLoadBalancingField loadBalancing = new LdapLoadBalancingField();
    loadBalancing.setValue(mapValue(props, LdapClaimsHandlerServiceProperties.LOAD_BALANCING));
    LdapBindUserInfo bindUserInfo = new LdapBindUserInfo().username(mapValue(props, LdapClaimsHandlerServiceProperties.LDAP_BIND_USER_DN)).password(FLAG_PASSWORD).bindMethod(mapValue(props, LdapClaimsHandlerServiceProperties.BIND_METHOD));
    LdapDirectorySettingsField settings = new LdapDirectorySettingsField().loginUserAttribute(mapValue(props, LdapClaimsHandlerServiceProperties.LOGIN_USER_ATTRIBUTE)).baseUserDn(mapValue(props, LdapClaimsHandlerServiceProperties.USER_BASE_DN)).baseGroupDn(mapValue(props, LdapClaimsHandlerServiceProperties.GROUP_BASE_DN)).groupObjectClass(mapValue(props, LdapClaimsHandlerServiceProperties.OBJECT_CLASS)).groupAttributeHoldingMember(mapValue(props, LdapClaimsHandlerServiceProperties.MEMBER_NAME_ATTRIBUTE)).memberAttributeReferencedInGroup(mapValue(props, LdapClaimsHandlerServiceProperties.MEMBERSHIP_USER_ATTRIBUTE)).useCase(ATTRIBUTE_STORE);
    Map<String, String> claimMappings = Collections.emptyMap();
    String attributeMappingsPath = mapValue(props, PROPERTY_FILE_LOCATION);
    if (StringUtils.isNotEmpty(attributeMappingsPath)) {
        Path path = Paths.get(attributeMappingsPath).toAbsolutePath();
        if (path.toFile().exists()) {
            claimMappings = new HashMap<>(configuratorSuite.getPropertyActions().getProperties(path));
        }
    }
    return new LdapConfigurationField().connections(connections).loadBalancing(loadBalancing).bindUserInfo(bindUserInfo).settings(settings).mapAllClaims(claimMappings).pid(props.get(ServiceCommons.SERVICE_PID_KEY) == null ? null : (String) props.get(ServiceCommons.SERVICE_PID_KEY));
}
Also used : Path(java.nio.file.Path) LdapLoadBalancingField(org.codice.ddf.admin.ldap.fields.connection.LdapLoadBalancingField) 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)

Aggregations

LdapConfigurationField (org.codice.ddf.admin.ldap.fields.config.LdapConfigurationField)10 LdapBindUserInfo (org.codice.ddf.admin.ldap.fields.connection.LdapBindUserInfo)5 LdapConnectionField (org.codice.ddf.admin.ldap.fields.connection.LdapConnectionField)5 LdapDirectorySettingsField (org.codice.ddf.admin.ldap.fields.config.LdapDirectorySettingsField)3 Test (org.junit.Test)3 URI (java.net.URI)2 LdapSettingsField (org.codice.ddf.admin.ldap.fields.config.LdapSettingsField)2 LdapLoadBalancingField (org.codice.ddf.admin.ldap.fields.connection.LdapLoadBalancingField)2 LdapClaimsHandlerServiceProperties (org.codice.ddf.admin.security.common.services.LdapClaimsHandlerServiceProperties)2 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CredentialsField (org.codice.ddf.admin.common.fields.common.CredentialsField)1 ClaimsMapEntry (org.codice.ddf.admin.security.common.fields.wcpm.ClaimsMapEntry)1 LdapLoginServiceProperties (org.codice.ddf.admin.security.common.services.LdapLoginServiceProperties)1