use of org.codice.ddf.admin.ldap.fields.connection.LdapBindUserInfo 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));
}
use of org.codice.ddf.admin.ldap.fields.connection.LdapBindUserInfo 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);
}
use of org.codice.ddf.admin.ldap.fields.connection.LdapBindUserInfo 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.connection.LdapBindUserInfo 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.connection.LdapBindUserInfo 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