Search in sources :

Example 16 with ServletIdentityManager

use of io.undertow.servlet.test.security.constraint.ServletIdentityManager in project undertow by undertow-io.

the class WelcomeFileSecurityTestCase method setup.

@BeforeClass
public static void setup() throws ServletException {
    final PathHandler root = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();
    ServletIdentityManager identityManager = new ServletIdentityManager();
    identityManager.addUser("user1", "password1", "role1");
    DeploymentInfo builder = new DeploymentInfo().setClassIntrospecter(TestClassIntrospector.INSTANCE).setClassLoader(ServletPathMappingTestCase.class.getClassLoader()).setContextPath("/servletContext").setDeploymentName("servletContext.war").setResourceManager(new TestResourceLoader(WelcomeFileSecurityTestCase.class)).addWelcomePages("doesnotexist.html", "index.html", "default").setIdentityManager(identityManager).setLoginConfig(new LoginConfig("BASIC", "Test Realm")).addServlet(new ServletInfo("DefaultTestServlet", PathTestServlet.class).setServletSecurityInfo(new ServletSecurityInfo().addRoleAllowed("role1")).addMapping("/path/default")).addSecurityConstraint(new SecurityConstraint().addRoleAllowed("role1").addWebResourceCollection(new WebResourceCollection().addUrlPattern("/index.html")));
    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    root.addPrefixPath(builder.getContextPath(), manager.start());
    DefaultServer.setRootHandler(root);
}
Also used : ServletInfo(io.undertow.servlet.api.ServletInfo) WebResourceCollection(io.undertow.servlet.api.WebResourceCollection) ServletSecurityInfo(io.undertow.servlet.api.ServletSecurityInfo) TestResourceLoader(io.undertow.servlet.test.util.TestResourceLoader) DeploymentManager(io.undertow.servlet.api.DeploymentManager) ServletContainer(io.undertow.servlet.api.ServletContainer) LoginConfig(io.undertow.servlet.api.LoginConfig) PathHandler(io.undertow.server.handlers.PathHandler) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) ServletPathMappingTestCase(io.undertow.servlet.test.path.ServletPathMappingTestCase) ServletIdentityManager(io.undertow.servlet.test.security.constraint.ServletIdentityManager) SecurityConstraint(io.undertow.servlet.api.SecurityConstraint) BeforeClass(org.junit.BeforeClass)

Aggregations

DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)16 ServletContainer (io.undertow.servlet.api.ServletContainer)16 ServletIdentityManager (io.undertow.servlet.test.security.constraint.ServletIdentityManager)16 PathHandler (io.undertow.server.handlers.PathHandler)15 DeploymentManager (io.undertow.servlet.api.DeploymentManager)15 LoginConfig (io.undertow.servlet.api.LoginConfig)15 BeforeClass (org.junit.BeforeClass)15 ServletInfo (io.undertow.servlet.api.ServletInfo)14 SecurityConstraint (io.undertow.servlet.api.SecurityConstraint)8 ServletSecurityInfo (io.undertow.servlet.api.ServletSecurityInfo)8 WebResourceCollection (io.undertow.servlet.api.WebResourceCollection)8 AuthMethodConfig (io.undertow.servlet.api.AuthMethodConfig)6 SimpleServletTestCase (io.undertow.servlet.test.SimpleServletTestCase)6 HashMap (java.util.HashMap)5 TestResourceLoader (io.undertow.servlet.test.util.TestResourceLoader)4 SendUsernameServlet (io.undertow.servlet.test.security.SendUsernameServlet)3 SendAuthTypeServlet (io.undertow.servlet.test.security.SendAuthTypeServlet)2 Test (org.junit.Test)2 Servlets (io.undertow.servlet.Servlets)1 ErrorPage (io.undertow.servlet.api.ErrorPage)1