本文整理汇总了Java中org.pac4j.core.exception.HttpAction.ok方法的典型用法代码示例。如果您正苦于以下问题:Java HttpAction.ok方法的具体用法?Java HttpAction.ok怎么用?Java HttpAction.ok使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pac4j.core.exception.HttpAction
的用法示例。
在下文中一共展示了HttpAction.ok方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: perform
import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
/**
* Perform a {@link RedirectAction} on the web context.
*
* @param context the web context
* @return the performed {@link HttpAction}
*/
public HttpAction perform(final WebContext context) {
if (type == RedirectType.REDIRECT) {
return HttpAction.redirect("redirection via 302", context, location);
} else {
return HttpAction.ok("redirection via 200", context, content);
}
}
示例2: testExtractionHttpActionOnSuccess
import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
@Test(timeout = 1000)
public void testExtractionHttpActionOnSuccess(final TestContext testContext) {
final Async async = testContext.async();
final AsyncWebContext asyncWebContext = MockAsyncWebContextBuilder.from(rule.vertx(), asynchronousComputationAdapter).build();
final HttpAction okAction = HttpAction.ok("No op", asyncWebContext);
final CompletableFuture<HttpAction> okFuture = delayedResult(() -> okAction)
.handle(softenBiFunction(AsyncExceptionHandler::extractAsyncHttpAction));
okFuture.thenAccept(a -> {
assertThat(a.getCode(), is(200));
async.complete();
});
}
示例3: perform
import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
@Override
public R perform(final C context, final Config config, final HttpActionAdapter<R, C> httpActionAdapter,
final String defaultUrl, final String inputLogoutUrlPattern) {
logger.debug("=== APP LOGOUT ===");
// default value
final String logoutUrlPattern;
if (inputLogoutUrlPattern == null) {
logoutUrlPattern = Pac4jConstants.DEFAULT_LOGOUT_URL_PATTERN_VALUE;
} else {
logoutUrlPattern = inputLogoutUrlPattern;
}
// checks
assertNotNull("context", context);
assertNotNull("config", config);
assertNotNull("httpActionAdapter", httpActionAdapter);
assertNotBlank(Pac4jConstants.LOGOUT_URL_PATTERN, logoutUrlPattern);
// logic
final ProfileManager manager = getProfileManager(context);
manager.logout();
postLogout(context);
final String url = context.getRequestParameter(Pac4jConstants.URL);
String redirectUrl = defaultUrl;
if (url != null && Pattern.matches(logoutUrlPattern, url)) {
redirectUrl = url;
}
logger.debug("redirectUrl: {}", redirectUrl);
final HttpAction action;
if (redirectUrl != null) {
action = HttpAction.redirect("redirect", context, redirectUrl);
} else {
action = HttpAction.ok("ok", context);
}
return httpActionAdapter.adapt(action.getCode(), context);
}
示例4: redirect
import org.pac4j.core.exception.HttpAction; //导入方法依赖的package包/类
@Override
public final HttpAction redirect(final WebContext context) throws HttpAction {
final RedirectAction action = getRedirectAction(context);
if (action.getType() == RedirectType.REDIRECT) {
return HttpAction.redirect("redirection via 302", context, action.getLocation());
} else {
return HttpAction.ok("redirection via 200", context, action.getContent());
}
}