use of org.codice.ddf.configuration.PropertyResolver in project ddf by codice.
the class SecureCxfClientFactoryTest method testWebClient.
@Test
public void testWebClient() {
PropertyResolver mockPropertyResolver = mock(PropertyResolver.class);
when(mockPropertyResolver.getResolvedString()).thenReturn(SECURE_ENDPOINT);
// positive case
SecureCxfClientFactory<WebClient> secureCxfClientFactory = new SecureCxfClientFactory<>(SECURE_ENDPOINT, WebClient.class, null, null, false, false, mockPropertyResolver);
WebClient client = secureCxfClientFactory.getWebClient();
assertThat(client, notNullValue());
}
use of org.codice.ddf.configuration.PropertyResolver in project ddf by codice.
the class LdapLoginConfig method createLdapModule.
/**
* Creates a new module with the given properties.
*
* @param properties Map of properties.
* @return newly created module.
*/
private Module createLdapModule(Map<String, ?> properties) {
Module ldapModule = new Module();
ldapModule.setClassName(LDAP_MODULE);
ldapModule.setFlags(SUFFICIENT_FLAG);
ldapModule.setName(id);
Properties props = new Properties();
props.put(CONNECTION_USERNAME, properties.get(LDAP_BIND_USER_DN));
props.put(CONNECTION_PASSWORD, properties.get(LDAP_BIND_USER_PASS));
props.put(CONNECTION_URL, new PropertyResolver((String) properties.get(LDAP_URL)).toString());
final Object userBaseDn = properties.get(USER_BASE_DN);
props.put(SslLdapLoginModule.USER_BASE_DN, userBaseDn);
final Object userNameAttribute = properties.get(USER_NAME_ATTRIBUTE);
props.put(USER_FILTER, String.format("(%s=%%u)", userNameAttribute));
props.put(USER_SEARCH_SUBTREE, "true");
props.put(ROLE_BASE_DN, properties.get(GROUP_BASE_DN));
props.put(ROLE_FILTER, String.format("(member=%s=%%u,%s)", userNameAttribute, userBaseDn));
props.put(ROLE_NAME_ATTRIBUTE, "cn");
props.put(ROLE_SEARCH_SUBTREE, "true");
props.put("authentication", "simple");
props.put("ssl.protocol", "TLS");
props.put("ssl.algorithm", "SunX509");
props.put(SSL_STARTTLS, properties.get(START_TLS));
props.put(BIND_METHOD, properties.get(BIND_METHOD));
props.put(REALM, (properties.get(REALM) != null) ? properties.get(REALM) : "");
props.put(KDC_ADDRESS, (properties.get(KDC_ADDRESS) != null) ? properties.get(KDC_ADDRESS) : "");
if ("GSSAPI SASL".equals(properties.get(BIND_METHOD)) && (StringUtils.isEmpty((String) properties.get(REALM)) || StringUtils.isEmpty((String) properties.get(KDC_ADDRESS)))) {
LOGGER.warn("LDAP connection will fail. GSSAPI SASL connection requires Kerberos Realm and KDC Address.");
}
ldapModule.setOptions(props);
return ldapModule;
}
Aggregations