本文整理汇总了Java中org.pac4j.http.client.BasicAuthClient类的典型用法代码示例。如果您正苦于以下问题:Java BasicAuthClient类的具体用法?Java BasicAuthClient怎么用?Java BasicAuthClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BasicAuthClient类属于org.pac4j.http.client包,在下文中一共展示了BasicAuthClient类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkUnautorizedProtocol
import org.pac4j.http.client.BasicAuthClient; //导入依赖的package包/类
@Test
public void checkUnautorizedProtocol() throws Exception {
final MockHttpServletRequest mockRequest = new MockHttpServletRequest();
mockRequest.setParameter(Clients.DEFAULT_CLIENT_NAME_PARAMETER, "BasicAuthClient");
final ServletExternalContext servletExternalContext = mock(ServletExternalContext.class);
when(servletExternalContext.getNativeRequest()).thenReturn(mockRequest);
final MockRequestContext mockRequestContext = new MockRequestContext();
mockRequestContext.setExternalContext(servletExternalContext);
final BasicAuthClient basicAuthClient = new BasicAuthClient();
final Clients clients = new Clients(MY_LOGIN_URL, basicAuthClient);
final ClientAction action = new ClientAction(mock(CentralAuthenticationService.class), clients);
try {
action.execute(mockRequestContext);
fail("Should fail as the HTTP protocol is not authorized");
} catch (final TechnicalException e) {
assertEquals("Only CAS, OAuth, OpenID and SAML protocols are supported: " + basicAuthClient, e.getMessage());
}
}
示例2: setup
import org.pac4j.http.client.BasicAuthClient; //导入依赖的package包/类
@BeforeMethod
public void setup() {
basicClient = mock(BasicAuthClient.class);
when(basicClient.getName()).thenReturn("client1");
clients = new Clients("/callback", basicClient);
sessionStore = mock(SessionStore.class);
configuration = mock(SecurityConfiguration.class);
when(configuration.getSessionStore()).thenReturn(sessionStore);
filter = spy(new AuthenticationFilter(clients, configuration));
context = mock(ContainerRequestContext.class);
uriInfo = mock(UriInfo.class);
when(uriInfo.getPath()).thenReturn("/dummy");
when(context.getUriInfo()).thenReturn(uriInfo);
}
示例3: registerPlugins
import org.pac4j.http.client.BasicAuthClient; //导入依赖的package包/类
@Override
protected void registerPlugins() {
registerPlugin(new JPAPlugin());
// Add security plugin if enabled
if(getConfiguration().isEnableSecurity()) {
BasicAuthClient client = new BasicAuthClient(new SimpleTestUsernamePasswordAuthenticator());
client.setName("basic");
registerPlugin(new SecurityPlugin("/callback", client));
}
}