Search in sources :

Example 1 with NullHCCredentials

use of org.jboss.as.test.integration.security.common.NullHCCredentials in project wildfly by wildfly.

the class SAML2AttributeMappingTestCase method testPassUserPrincipalToAttributeManager.

/**
     * Tests IDP attribute mapping when passUserPrincipalToAttributeManager is set to "true". Automatic handling of redirections
     * is enabled for HTTP client used.
     *
     * @throws Exception
     */
@Test
public void testPassUserPrincipalToAttributeManager() throws Exception {
    Registry<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create().register(AuthSchemes.SPNEGO, new JBossNegotiateSchemeFactory(true)).build();
    CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(new AuthScope(null, -1, null), new NullHCCredentials());
    try (final CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultAuthSchemeRegistry(authSchemeRegistry).setDefaultCredentialsProvider(credentialsProvider).setRedirectStrategy(Utils.REDIRECT_STRATEGY).build()) {
        String response = PicketLinkTestBase.makeCallWithKerberosAuthn(spUrl.toURI(), httpClient, "jduke", "theduke", 200);
        assertEquals("SP index page was not reached", SP_RESPONSE_BODY, response);
        response = PicketLinkTestBase.makeCall(new URL(spUrl.toString() + PrintAttributeServlet.SERVLET_PATH.substring(1)), httpClient, 200);
        assertEquals("cn attribute not stored", "Java Duke", response);
    }
}
Also used : JBossNegotiateSchemeFactory(org.jboss.as.test.integration.security.common.negotiation.JBossNegotiateSchemeFactory) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) NullHCCredentials(org.jboss.as.test.integration.security.common.NullHCCredentials) AuthScope(org.apache.http.auth.AuthScope) AuthSchemeProvider(org.apache.http.auth.AuthSchemeProvider) BasicCredentialsProvider(org.apache.http.impl.client.BasicCredentialsProvider) CredentialsProvider(org.apache.http.client.CredentialsProvider) URL(java.net.URL) Test(org.junit.Test)

Aggregations

URL (java.net.URL)1 AuthSchemeProvider (org.apache.http.auth.AuthSchemeProvider)1 AuthScope (org.apache.http.auth.AuthScope)1 CredentialsProvider (org.apache.http.client.CredentialsProvider)1 BasicCredentialsProvider (org.apache.http.impl.client.BasicCredentialsProvider)1 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)1 NullHCCredentials (org.jboss.as.test.integration.security.common.NullHCCredentials)1 JBossNegotiateSchemeFactory (org.jboss.as.test.integration.security.common.negotiation.JBossNegotiateSchemeFactory)1 Test (org.junit.Test)1