Search in sources :

Example 6 with PropertyResolver

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());
}
Also used : PropertyResolver(org.codice.ddf.configuration.PropertyResolver) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Example 7 with PropertyResolver

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;
}
Also used : Module(org.apache.karaf.jaas.config.impl.Module) Properties(java.util.Properties) PropertyResolver(org.codice.ddf.configuration.PropertyResolver)

Aggregations

PropertyResolver (org.codice.ddf.configuration.PropertyResolver)7 IOException (java.io.IOException)2 WebClient (org.apache.cxf.jaxrs.client.WebClient)2 Test (org.junit.Test)2 GenericUrl (com.google.api.client.http.GenericUrl)1 HttpBackOffIOExceptionHandler (com.google.api.client.http.HttpBackOffIOExceptionHandler)1 HttpBackOffUnsuccessfulResponseHandler (com.google.api.client.http.HttpBackOffUnsuccessfulResponseHandler)1 HttpRequest (com.google.api.client.http.HttpRequest)1 HttpResponse (com.google.api.client.http.HttpResponse)1 HttpTransport (com.google.api.client.http.HttpTransport)1 NetHttpTransport (com.google.api.client.http.javanet.NetHttpTransport)1 ExponentialBackOff (com.google.api.client.util.ExponentialBackOff)1 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 StringReader (java.io.StringReader)1 Path (java.nio.file.Path)1 GeneralSecurityException (java.security.GeneralSecurityException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1