// Path: core/src/main/java/org/pac4j/jax/rs/features/JaxRsContextFactoryProvider.java
// public class JaxRsContextFactoryProvider implements ContextResolver<JaxRsContextFactory> {
// 
//     @Context
//     private Providers providers;
// 
//     @Override
//     public JaxRsContextFactory getContext(Class<?> type) {
//         return context -> new JaxRsContext(getProviders(), context, getConfig().getSessionStore());
//     }
// 
//     protected Providers getProviders() {
//         assert providers != null;
//         return providers;
//     }
// 
//     protected Config getConfig() {
//         return new ProvidersContext(providers).resolveNotNull(Config.class);
//     }
// 
//     /**
//      * We need to provide a factory because it is not possible to get the {@link ContainerRequestContext} injected
//      * directly here...
//      */
//     @FunctionalInterface
//     public interface JaxRsContextFactory {
//         JaxRsContext provides(ContainerRequestContext context);
//     }
// }
// 
// Path: core/src/main/java/org/pac4j/jax/rs/servlet/pac4j/ServletJaxRsContext.java
// public class ServletJaxRsContext extends JaxRsContext {
// 
//     private final HttpServletRequest request;
// 
//     public ServletJaxRsContext(Providers providers, ContainerRequestContext requestContext,
//             SessionStore sessionStore, HttpServletRequest request) {
//         super(providers, requestContext, sessionStore != null ? sessionStore : new ServletSessionStore());
//         CommonHelper.assertNotNull("request", request);
//         this.request = request;
//     }
//     
//     public HttpServletRequest getRequest() {
//         return request;
//     }
// 
//     @Override
//     public String getRemoteAddr() {
//         return request.getRemoteAddr();
//     }
// }


import javax.inject.Inject;
import javax.inject.Provider;
import javax.servlet.http.HttpServletRequest;
import org.pac4j.jax.rs.features.JaxRsContextFactoryProvider;
import org.pac4j.jax.rs.servlet.pac4j.ServletJaxRsContext;
package org.pac4j.jax.rs.servlet.features;



/**
 * Extends {@link JaxRsContextFactoryProvider} to support any servlet-based container and its session manager (i.e.,
 * pac4j indirect clients will work, contrary than with {@link JaxRsContextFactoryProvider}).
 * 
 * @see JaxRsContextFactoryProvider
 * @author Victor Noel - Linagora
 * @since 1.0.0
 *
 */
public class ServletJaxRsContextFactoryProvider extends JaxRsContextFactoryProvider {

    @Inject
    private Provider<HttpServletRequest> requestProvider;

    @Override
    public JaxRsContextFactory getContext(Class<?> type) {
// Path: core/src/main/java/org/pac4j/jax/rs/features/JaxRsContextFactoryProvider.java
// public class JaxRsContextFactoryProvider implements ContextResolver<JaxRsContextFactory> {
// 
//     @Context
//     private Providers providers;
// 
//     @Override
//     public JaxRsContextFactory getContext(Class<?> type) {
//         return context -> new JaxRsContext(getProviders(), context, getConfig().getSessionStore());
//     }
// 
//     protected Providers getProviders() {
//         assert providers != null;
//         return providers;
//     }
// 
//     protected Config getConfig() {
//         return new ProvidersContext(providers).resolveNotNull(Config.class);
//     }
// 
//     /**
//      * We need to provide a factory because it is not possible to get the {@link ContainerRequestContext} injected
//      * directly here...
//      */
//     @FunctionalInterface
//     public interface JaxRsContextFactory {
//         JaxRsContext provides(ContainerRequestContext context);
//     }
// }
// 
// Path: core/src/main/java/org/pac4j/jax/rs/servlet/pac4j/ServletJaxRsContext.java
// public class ServletJaxRsContext extends JaxRsContext {
// 
//     private final HttpServletRequest request;
// 
//     public ServletJaxRsContext(Providers providers, ContainerRequestContext requestContext,
//             SessionStore sessionStore, HttpServletRequest request) {
//         super(providers, requestContext, sessionStore != null ? sessionStore : new ServletSessionStore());
//         CommonHelper.assertNotNull("request", request);
//         this.request = request;
//     }
//     
//     public HttpServletRequest getRequest() {
//         return request;
//     }
// 
//     @Override
//     public String getRemoteAddr() {
//         return request.getRemoteAddr();
//     }
// }


// Path: core/src/main/java/org/pac4j/jax/rs/servlet/features/ServletJaxRsContextFactoryProvider.java
import javax.inject.Inject;
import javax.inject.Provider;
import javax.servlet.http.HttpServletRequest;
import org.pac4j.jax.rs.features.JaxRsContextFactoryProvider;
import org.pac4j.jax.rs.servlet.pac4j.ServletJaxRsContext;

package org.pac4j.jax.rs.servlet.features;



/**
 * Extends {@link JaxRsContextFactoryProvider} to support any servlet-based container and its session manager (i.e.,
 * pac4j indirect clients will work, contrary than with {@link JaxRsContextFactoryProvider}).
 * 
 * @see JaxRsContextFactoryProvider
 * @author Victor Noel - Linagora
 * @since 1.0.0
 *
 */
public class ServletJaxRsContextFactoryProvider extends JaxRsContextFactoryProvider {

    @Inject
    private Provider<HttpServletRequest> requestProvider;

    @Override
    public JaxRsContextFactory getContext(Class<?> type) {
        return context -> new ServletJaxRsContext(getProviders(), context, getConfig().getSessionStore(), requestProvider.get());