本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}