All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.pac4j.javalin.DefaultHttpActionAdapter Maven / Gradle / Ivy

There is a newer version: 7.0.0
Show newest version
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