本文整理汇总了Java中org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator类的典型用法代码示例。如果您正苦于以下问题:Java SimpleTestUsernamePasswordAuthenticator类的具体用法?Java SimpleTestUsernamePasswordAuthenticator怎么用?Java SimpleTestUsernamePasswordAuthenticator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SimpleTestUsernamePasswordAuthenticator类属于org.pac4j.http.credentials.authenticator.test包,在下文中一共展示了SimpleTestUsernamePasswordAuthenticator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clients
import org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator; //导入依赖的package包/类
@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();
}
示例2: allOptionsClients
import org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator; //导入依赖的package包/类
@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);
}
示例3: clientsAndProperties
import org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator; //导入依赖的package包/类
@Test
public void clientsAndProperties() throws Exception {
Pac4jFactory conf = getPac4jFactory("clientsandproperties-pac4j.yaml");
Config config = conf.build();
assertThat(config).isExactlyInstanceOf(JaxRsConfig.class);
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);
}
示例4: getConfig
import org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator; //导入依赖的package包/类
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((c) -> true);
// so that callback url have the correct prefix w.r.t. the container's context
clients.setUrlResolver(new JaxRsUrlResolver());
JaxRsConfig config = new JaxRsConfig();
config.setClients(clients);
config.setDefaultClients(DEFAULT_CLIENT);
return config;
}
示例5: testAuthentication
import org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator; //导入依赖的package包/类
@Test
public void testAuthentication() throws HttpAction, UnsupportedEncodingException {
final DirectBasicAuthClient client = new DirectBasicAuthClient(new SimpleTestUsernamePasswordAuthenticator());
final MockWebContext context = MockWebContext.create();
final String header = USERNAME + ":" + USERNAME;
context.addRequestHeader(HttpConstants.AUTHORIZATION_HEADER,
"Basic " + Base64.getEncoder().encodeToString(header.getBytes(HttpConstants.UTF8_ENCODING)));
final UsernamePasswordCredentials credentials = client.getCredentials(context);
final CommonProfile profile = client.getUserProfile(credentials, context);
assertEquals(USERNAME, profile.getId());
}
示例6: testMissingProfileCreator
import org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator; //导入依赖的package包/类
@Test
public void testMissingProfileCreator() {
final FormClient formClient = new FormClient(LOGIN_URL, new SimpleTestUsernamePasswordAuthenticator());
formClient.setCallbackUrl(CALLBACK_URL);
formClient.setProfileCreator(null);
TestsHelper.expectException(() -> formClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, PASSWORD, CLIENT_NAME),
MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null");
}
示例7: testMissingProfileCreator
import org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator; //导入依赖的package包/类
@Test
public void testMissingProfileCreator() {
final IndirectBasicAuthClient basicAuthClient = new IndirectBasicAuthClient(NAME, new SimpleTestUsernamePasswordAuthenticator());
basicAuthClient.setCallbackUrl(CALLBACK_URL);
basicAuthClient.setProfileCreator(null);
TestsHelper.expectException(() -> basicAuthClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, PASSWORD, CLIENT_NAME),
MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null");
}
示例8: form
import org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator; //导入依赖的package包/类
/**
* Add a simple login form. Useful for development and quick startup.
*
* @param pattern Pattern to protect.ver
* @return This module.
*/
public Pac4j form(String pattern) {
return clientInternal(pattern, conf -> {
showDevLogin = true;
return new FormClient("/login", new SimpleTestUsernamePasswordAuthenticator());
}, null);
}
示例9: newLoginFormClient
import org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator; //导入依赖的package包/类
private MockUnit.Block newLoginFormClient() {
return unit -> {
SimpleTestUsernamePasswordAuthenticator authenticator = unit
.constructor(SimpleTestUsernamePasswordAuthenticator.class)
.build();
FormClient formClient = unit.constructor(FormClient.class)
.build("/login", authenticator);
unit.registerMock(FormClient.class, formClient);
};
}
示例10: testMissingProfileCreator
import org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator; //导入依赖的package包/类
@Test
public void testMissingProfileCreator() {
final DirectBasicAuthClient basicAuthClient = new DirectBasicAuthClient(new SimpleTestUsernamePasswordAuthenticator(), null);
TestsHelper.expectException(() -> basicAuthClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, PASSWORD, CLIENT_NAME),
MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null");
}
示例11: testHasDefaultProfileCreator
import org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator; //导入依赖的package包/类
@Test
public void testHasDefaultProfileCreator() {
final DirectBasicAuthClient basicAuthClient = new DirectBasicAuthClient(new SimpleTestUsernamePasswordAuthenticator());
basicAuthClient.init(null);
}
示例12: testMissingProfileCreator
import org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator; //导入依赖的package包/类
@Test
public void testMissingProfileCreator() {
final DirectFormClient formClient = new DirectFormClient(new SimpleTestUsernamePasswordAuthenticator(), null);
TestsHelper.expectException(() -> formClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, PASSWORD, CLIENT_NAME),
MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null");
}
示例13: testHasDefaultProfileCreator
import org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator; //导入依赖的package包/类
@Test
public void testHasDefaultProfileCreator() {
final DirectFormClient formClient = new DirectFormClient(new LocalCachingAuthenticator<>(new SimpleTestUsernamePasswordAuthenticator(), 10, 10, TimeUnit.DAYS));
formClient.init(null);
}
示例14: getFormClient
import org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator; //导入依赖的package包/类
private DirectFormClient getFormClient() {
return new DirectFormClient(new SimpleTestUsernamePasswordAuthenticator());
}
示例15: testHasDefaultProfileCreator
import org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator; //导入依赖的package包/类
@Test
public void testHasDefaultProfileCreator() {
final FormClient formClient = new FormClient(LOGIN_URL, new SimpleTestUsernamePasswordAuthenticator());
formClient.setCallbackUrl(CALLBACK_URL);
formClient.init(null);
}