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));
}
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();
}
}
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();
}
}
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));
}
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));
}
Aggregations