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


Java HttpAction.status方法代码示例

本文整理汇总了Java中org.pac4j.core.exception.HttpAction.status方法的典型用法代码示例。如果您正苦于以下问题:Java HttpAction.status方法的具体用法?Java HttpAction.status怎么用?Java HttpAction.status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pac4j.core.exception.HttpAction的用法示例。


在下文中一共展示了HttpAction.status方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testHttpActionExceptionBehaviour

import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
@Test(timeout=1000, expected=HttpAction.class)
public void testHttpActionExceptionBehaviour(final TestContext testContext) throws Exception {
    final HttpAction action = HttpAction.status("Intentional http action", 200, webContext);
    when(extractor.extract(any(WebContext.class))).thenThrow(action);
    final Async async = testContext.async();
    final CompletableFuture<TestCredentials> credsFuture = AsyncCredentialsExtractor.fromNonBlocking(extractor).extract(null);
    assertSuccessfulEvaluation(credsFuture, creds -> {}, async);
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:9,代码来源:AsyncCredentialsExtractorTest.java

示例2: testFromBlockingHttpActionExceptionBehaviour

import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
@Test(timeout=1000, expected=HttpAction.class)
public void testFromBlockingHttpActionExceptionBehaviour(final TestContext testContext) throws Exception {
    final HttpAction action = HttpAction.status("Intentional http action", 200, webContext);
    when(extractor.extract(any(WebContext.class))).thenThrow(action);
    final Async async = testContext.async();
    final CompletableFuture<TestCredentials> credsFuture = AsyncCredentialsExtractor.fromBlocking(extractor).extract(webContext);
    assertSuccessfulEvaluation(credsFuture, creds -> {}, async);
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:9,代码来源:AsyncCredentialsExtractorTest.java

示例3: testHttpActionExceptionBehaviour

import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
@Test(timeout=1000, expected=HttpAction.class)
public void testHttpActionExceptionBehaviour(final TestContext testContext) throws Exception {
    final HttpAction action = HttpAction.status("Intentional http action", 200, webContext);
    doThrow(action).when(authenticator).validate(eq(TEST_CREDENTIALS), eq(webContext));
    final Async async = testContext.async();
    final CompletableFuture<Void> authFuture = asyncAuthenticator.validate(TEST_CREDENTIALS, webContext);
    assertSuccessfulEvaluation(authFuture, res   -> {}, async);
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:9,代码来源:AsyncAuthenticatorTest.java

示例4: testDirectClientThrowsRequiresHttpAction

import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
@Test
public void testDirectClientThrowsRequiresHttpAction() throws Exception {
    final CommonProfile profile = new CommonProfile();
    profile.setId(NAME);
    final DirectClient directClient = new MockDirectClient(NAME, () -> { throw HttpAction.status("bad request", 400, context); }, profile);
    config.setClients(new Clients(CALLBACK_URL, directClient));
    clients = NAME;
    call();
    assertEquals(400, context.getResponseStatus());
    assertEquals(0, nbCall);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:12,代码来源:DefaultSecurityLogicTests.java

示例5: handleInvalidCredentials

import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
private HttpAction handleInvalidCredentials(final WebContext context, final String username, String message, String errorMessage, int errorCode) throws HttpAction {
    // it's an AJAX request -> unauthorized (instead of a redirection)
    if (getAjaxRequestResolver().isAjax(context)) {
        logger.info("AJAX request detected -> returning " + errorCode);
        return HttpAction.status("AJAX request -> " + errorCode, errorCode, context);
    } else {
        String redirectionUrl = CommonHelper.addParameter(this.loginUrl, this.usernameParameter, username);
        redirectionUrl = CommonHelper.addParameter(redirectionUrl, ERROR_PARAMETER, errorMessage);
        logger.debug("redirectionUrl: {}", redirectionUrl);
        logger.debug(message);
        return HttpAction.redirect(message, context, redirectionUrl);
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:14,代码来源:FormClient.java


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