org.pac4j.javalin.DefaultHttpActionAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javalin-pac4j Show documentation
Show all versions of javalin-pac4j Show documentation
Security library for Javalin based on pac4j
package org.pac4j.javalin;
import io.javalin.http.ForbiddenResponse;
import io.javalin.http.UnauthorizedResponse;
import org.pac4j.core.context.HttpConstants;
import org.pac4j.core.http.adapter.HttpActionAdapter;
public class DefaultHttpActionAdapter implements HttpActionAdapter {
@Override
public Void adapt(int code, Pac4jContext context) {
if (code == HttpConstants.UNAUTHORIZED) {
throw new UnauthorizedResponse();
} else if (code == HttpConstants.FORBIDDEN) {
throw new ForbiddenResponse();
} else if (code == HttpConstants.TEMP_REDIRECT) {
String location = context.getJavalinCtx().res.getHeader(HttpConstants.LOCATION_HEADER);
context.getJavalinCtx().redirect(location);
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy