org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator Java Examples
The following examples show how to use
org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultConfigurationTest.java From dropwizard-pac4j with Apache License 2.0 | 6 votes |
@Test public void clients() throws Exception { Pac4jFactory conf = getPac4jFactory("clients.yaml"); Config config = conf.build(); assertThat(config.getClients().getClients()).hasSize(2); Client client = config.getClients().getClients().get(0); assertThat(client).isInstanceOf(DirectBasicAuthClient.class); assertThat(client.getName()).isEqualTo("DirectBasicAuthClient"); assertThat(((DirectBasicAuthClient) client).getAuthenticator()) .isNotNull() .isInstanceOf(SimpleTestUsernamePasswordAuthenticator.class); Client client1 = config.getClients().getClients().get(1); assertThat(client1).isInstanceOf(DirectBasicAuthClient.class); assertThat(client1.getName()).isEqualTo("basic"); assertThat(((DirectBasicAuthClient) client1).getAuthenticator()) .isNull(); }
Example #2
Source File: DefaultConfigurationTest.java From dropwizard-pac4j with Apache License 2.0 | 6 votes |
@Test public void allOptionsClients() throws Exception { Pac4jFactory conf = getPac4jFactory("alloptions-pac4j.yaml"); Config config = conf.build(); assertThat(config).isExactlyInstanceOf(FakeConfig.class); final FakeConfig fakeConfig = (FakeConfig) config; assertThat(fakeConfig.getProperties().size()).isEqualTo(2); assertThat(config.getClients().getClients()).hasSize(2); Client client0 = config.getClients().getClients().get(0); assertThat(client0).isExactlyInstanceOf(FacebookClient.class); assertThat(((FacebookClient) client0).getKey()).isEqualTo("fbId"); Client client1 = config.getClients().getClients().get(1); assertThat(client1).isInstanceOf(DirectBasicAuthClient.class); assertThat(client1.getName()).isEqualTo("DirectBasicAuthClient"); assertThat(((DirectBasicAuthClient) client1).getAuthenticator()) .isNotNull() .isInstanceOf(SimpleTestUsernamePasswordAuthenticator.class); assertThat(config.getAuthorizers().size()).isEqualTo(1); assertThat(config.getMatchers().size()).isEqualTo(1); }
Example #3
Source File: DefaultConfigurationTest.java From dropwizard-pac4j with Apache License 2.0 | 6 votes |
@Test public void clientsAndProperties() throws Exception { Pac4jFactory conf = getPac4jFactory("clientsandproperties-pac4j.yaml"); Config config = conf.build(); assertThat(config.getClients().getClients()).hasSize(2); Client client0 = config.getClients().getClients().get(0); assertThat(client0).isExactlyInstanceOf(FacebookClient.class); assertThat(((FacebookClient) client0).getKey()).isEqualTo("fbId"); Client client1 = config.getClients().getClients().get(1); assertThat(client1).isInstanceOf(DirectBasicAuthClient.class); assertThat(client1.getName()).isEqualTo("DirectBasicAuthClient"); assertThat(((DirectBasicAuthClient) client1).getAuthenticator()) .isNotNull() .isInstanceOf(SimpleTestUsernamePasswordAuthenticator.class); assertThat(config.getAuthorizers().size()).isEqualTo(0); assertThat(config.getMatchers().size()).isEqualTo(0); }
Example #4
Source File: TestConfig.java From jax-rs-pac4j with Apache License 2.0 | 6 votes |
default Config getConfig() { // login not used because the ajax resolver always answer true Authenticator<UsernamePasswordCredentials> auth = new SimpleTestUsernamePasswordAuthenticator(); FormClient client = new FormClient("notUsedLoginUrl", auth); DirectFormClient client2 = new DirectFormClient(auth); DirectFormClient client3 = new DirectFormClient(auth); client3.setName(DEFAULT_CLIENT); Clients clients = new Clients("notUsedCallbackUrl", client, client2, client3); // in case of invalid credentials, we simply want the error, not a redirect to the login url clients.setAjaxRequestResolver(new JaxRsAjaxRequestResolver()); // so that callback url have the correct prefix w.r.t. the container's context clients.setUrlResolver(new JaxRsUrlResolver()); clients.setDefaultSecurityClients(DEFAULT_CLIENT); return new Config(clients); }