当前位置: 首页>>代码示例>>Java>>正文


Java SimpleTestUsernamePasswordAuthenticator类代码示例

本文整理汇总了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();
}
 
开发者ID:pac4j,项目名称:dropwizard-pac4j,代码行数:21,代码来源:DefaultConfigurationTest.java

示例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);
}
 
开发者ID:pac4j,项目名称:dropwizard-pac4j,代码行数:26,代码来源:DefaultConfigurationTest.java

示例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);
}
 
开发者ID:pac4j,项目名称:dropwizard-pac4j,代码行数:24,代码来源:DefaultConfigurationTest.java

示例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;
}
 
开发者ID:pac4j,项目名称:jax-rs-pac4j,代码行数:21,代码来源:TestConfig.java

示例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());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:12,代码来源:DirectBasicAuthClientTests.java

示例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");
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:9,代码来源:FormClientTests.java

示例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");
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:9,代码来源:IndirectBasicAuthClientTests.java

示例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);
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:13,代码来源:Pac4j.java

示例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);
  };
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:12,代码来源:Pac4jTest.java

示例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");
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:7,代码来源:DirectBasicAuthClientTests.java

示例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);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:6,代码来源:DirectBasicAuthClientTests.java

示例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");
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:7,代码来源:DirectFormClientTests.java

示例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);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:6,代码来源:DirectFormClientTests.java

示例14: getFormClient

import org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator; //导入依赖的package包/类
private DirectFormClient getFormClient() {
    return new DirectFormClient(new SimpleTestUsernamePasswordAuthenticator());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:4,代码来源:DirectFormClientTests.java

示例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);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:7,代码来源:FormClientTests.java


注:本文中的org.pac4j.http.credentials.authenticator.test.SimpleTestUsernamePasswordAuthenticator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。