本文整理匯總了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));
}
}