當前位置: 首頁>>代碼示例>>Java>>正文


Java BasicAuthClient類代碼示例

本文整理匯總了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());
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:23,代碼來源:ClientActionTests.java

示例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);
}
 
開發者ID:minnal,項目名稱:minnal,代碼行數:15,代碼來源:AuthenticationFilterTest.java

示例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));
	}
}
 
開發者ID:minnal,項目名稱:minnal,代碼行數:11,代碼來源:OrderApplication.java


注:本文中的org.pac4j.http.client.BasicAuthClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。