Example usage for javax.servlet SessionTrackingMode URL

List of usage examples for javax.servlet SessionTrackingMode URL

Introduction

In this page you can find the example usage for javax.servlet SessionTrackingMode URL.

Prototype

SessionTrackingMode URL

To view the source code for javax.servlet SessionTrackingMode URL.

Click Source Link

Usage

From source file:io.undertow.servlet.test.session.ServletURLRewritingSessionTestCase.java

@BeforeClass
public static void setup() {
    DeploymentUtils.setupServlet(new ServletExtension() {
        @Override//from   w  ww .  j a  va 2  s  . c  o  m
        public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) {
            deploymentInfo.setServletSessionConfig(new ServletSessionConfig()
                    .setSessionTrackingModes(Collections.singleton(SessionTrackingMode.URL)));
        }
    }, Servlets.servlet(URLRewritingServlet.class).addMapping("/foo"));
}

From source file:io.undertow.servlet.test.security.form.ServletFormAuthURLRewriteTestCase.java

@BeforeClass
public static void setup() throws ServletException {

    final PathHandler path = new PathHandler();

    final ServletContainer container = ServletContainer.Factory.newInstance();

    ServletInfo s = new ServletInfo("servlet", SendUsernameServlet.class)
            .setServletSecurityInfo(new ServletSecurityInfo().addRoleAllowed("role1")).addMapping("/secured/*");

    ServletInfo echo = new ServletInfo("echo", EchoServlet.class)
            .setServletSecurityInfo(new ServletSecurityInfo().addRoleAllowed("role1"))
            .addMapping("/secured/echo");

    ServletInfo echoParam = new ServletInfo("echoParam", RequestParamEchoServlet.class)
            .setServletSecurityInfo(new ServletSecurityInfo().addRoleAllowed("role1"))
            .addMapping("/secured/echoParam");

    ServletInfo s1 = new ServletInfo("loginPage", FormLoginServlet.class)
            .setServletSecurityInfo(new ServletSecurityInfo().addRoleAllowed("group1"))
            .addMapping("/FormLoginServlet");

    ServletIdentityManager identityManager = new ServletIdentityManager();
    identityManager.addUser("user1", "password1", "role1");

    DeploymentInfo builder = new DeploymentInfo()
            .setServletSessionConfig(new ServletSessionConfig()
                    .setSessionTrackingModes(Collections.singleton(SessionTrackingMode.URL)))
            .setClassLoader(SimpleServletTestCase.class.getClassLoader()).setContextPath("/servletContext")
            .setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war")
            .setAuthenticationMode(AuthenticationMode.CONSTRAINT_DRIVEN).setIdentityManager(identityManager)
            .setLoginConfig(new LoginConfig("FORM", "Test Realm", "/FormLoginServlet", "/error.html"))
            .addServlets(s, s1, echo, echoParam);

    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();/*  w  w w. j a v a 2s .c  o m*/
    path.addPrefixPath(builder.getContextPath(), manager.start());

    DefaultServer.setRootHandler(path);
}