// Path: jersey228/src/main/java/org/pac4j/jax/rs/grizzly/features/GrizzlyJaxRsContextFactoryProvider.java
// public class GrizzlyJaxRsContextFactoryProvider extends JaxRsContextFactoryProvider {
// 
//     @Inject
//     protected Provider<Request> requestProvider;
// 
//     @Override
//     public JaxRsContextFactory getContext(Class<?> type) {
//         Request request = requestProvider.get();
//         assert request != null;
//         return context -> new GrizzlyJaxRsContext(getProviders(), context, getConfig().getSessionStore(), request);
//     }
// }
// 
// Path: jersey225/src/test/java/org/pac4j/jax/rs/resources/JerseyResource.java
// @Path("/containerSpecific")
// public class JerseyResource {
// 
//     @Context
//     private Providers providers;
// 
//     @Inject
//     private ContainerRequestContext requestContext;
// 
//     @POST
//     @Path("/securitycontext")
//     @Pac4JSecurity(clients = "DirectFormClient", authorizers = DefaultAuthorizers.IS_AUTHENTICATED)
//     public String directSecurityContext() {
//         // Note: SecurityContext injected via @Context can't be cast
//         SecurityContext context = requestContext.getSecurityContext();
//         if (context != null) {
//             if (context instanceof Pac4JSecurityContext) {
//                 return "ok";
//             } else {
//                 return "fail";
//             }
//         } else {
//             return "error";
//         }
//     }
// 
//     @POST
//     @Path("/context")
//     @Pac4JSecurity(clients = "DirectFormClient", authorizers = DefaultAuthorizers.IS_AUTHENTICATED)
//     public String directContext() {
//         JaxRsContext context = new ProvidersContext(providers).resolveNotNull(JaxRsContextFactory.class)
//                 .provides(requestContext);
//         if (context != null) {
//             return "ok";
//         } else {
//             return "fail";
//         }
//     }
// }


import java.util.Set;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.DeploymentContext;
import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory;
import org.glassfish.jersey.test.spi.TestContainerFactory;
import org.pac4j.jax.rs.grizzly.features.GrizzlyJaxRsContextFactoryProvider;
import org.pac4j.jax.rs.resources.JerseyResource;
package org.pac4j.jax.rs.rules;



public class JerseyGrizzlyRule extends JerseyRule implements SessionContainerRule {

    @Override
    public Set<Class<?>> getResources() {
        Set<Class<?>> resources = SessionContainerRule.super.getResources();
        resources.add(JerseyResource.class);
        return resources;
    }

    @Override
    protected TestContainerFactory getTestContainerFactory() {
        return new GrizzlyTestContainerFactory();
    }

    @Override
    protected DeploymentContext configureDeployment(ResourceConfig config) {
        return DeploymentContext.builder(config).build();
    }

    @Override
    protected ResourceConfig configureResourceConfig(ResourceConfig config) {
        return super
                .configureResourceConfig(config)
// Path: jersey228/src/main/java/org/pac4j/jax/rs/grizzly/features/GrizzlyJaxRsContextFactoryProvider.java
// public class GrizzlyJaxRsContextFactoryProvider extends JaxRsContextFactoryProvider {
// 
//     @Inject
//     protected Provider<Request> requestProvider;
// 
//     @Override
//     public JaxRsContextFactory getContext(Class<?> type) {
//         Request request = requestProvider.get();
//         assert request != null;
//         return context -> new GrizzlyJaxRsContext(getProviders(), context, getConfig().getSessionStore(), request);
//     }
// }
// 
// Path: jersey225/src/test/java/org/pac4j/jax/rs/resources/JerseyResource.java
// @Path("/containerSpecific")
// public class JerseyResource {
// 
//     @Context
//     private Providers providers;
// 
//     @Inject
//     private ContainerRequestContext requestContext;
// 
//     @POST
//     @Path("/securitycontext")
//     @Pac4JSecurity(clients = "DirectFormClient", authorizers = DefaultAuthorizers.IS_AUTHENTICATED)
//     public String directSecurityContext() {
//         // Note: SecurityContext injected via @Context can't be cast
//         SecurityContext context = requestContext.getSecurityContext();
//         if (context != null) {
//             if (context instanceof Pac4JSecurityContext) {
//                 return "ok";
//             } else {
//                 return "fail";
//             }
//         } else {
//             return "error";
//         }
//     }
// 
//     @POST
//     @Path("/context")
//     @Pac4JSecurity(clients = "DirectFormClient", authorizers = DefaultAuthorizers.IS_AUTHENTICATED)
//     public String directContext() {
//         JaxRsContext context = new ProvidersContext(providers).resolveNotNull(JaxRsContextFactory.class)
//                 .provides(requestContext);
//         if (context != null) {
//             return "ok";
//         } else {
//             return "fail";
//         }
//     }
// }


// Path: jersey225/src/test/java/org/pac4j/jax/rs/rules/JerseyGrizzlyRule.java
import java.util.Set;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.DeploymentContext;
import org.glassfish.jersey.test.grizzly.GrizzlyTestContainerFactory;
import org.glassfish.jersey.test.spi.TestContainerFactory;
import org.pac4j.jax.rs.grizzly.features.GrizzlyJaxRsContextFactoryProvider;
import org.pac4j.jax.rs.resources.JerseyResource;

package org.pac4j.jax.rs.rules;



public class JerseyGrizzlyRule extends JerseyRule implements SessionContainerRule {

    @Override
    public Set<Class<?>> getResources() {
        Set<Class<?>> resources = SessionContainerRule.super.getResources();
        resources.add(JerseyResource.class);
        return resources;
    }

    @Override
    protected TestContainerFactory getTestContainerFactory() {
        return new GrizzlyTestContainerFactory();
    }

    @Override
    protected DeploymentContext configureDeployment(ResourceConfig config) {
        return DeploymentContext.builder(config).build();
    }

    @Override
    protected ResourceConfig configureResourceConfig(ResourceConfig config) {
        return super
                .configureResourceConfig(config)
                .register(new GrizzlyJaxRsContextFactoryProvider());