Java Code Examples for org.apache.catalina.startup.Tomcat#addRole()
The following examples show how to use
org.apache.catalina.startup.Tomcat#addRole() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSSOnonLoginAndDigestAuthenticator.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override public void setUp() throws Exception { super.setUp(); // create a tomcat server using the default in-memory Realm Tomcat tomcat = getTomcatInstance(); // associate the SingeSignOn Valve before the Contexts SingleSignOn sso = new SingleSignOn(); tomcat.getHost().getPipeline().addValve(sso); // add the test user and role to the Realm tomcat.addUser(USER, PWD); tomcat.addRole(USER, ROLE); // setup both NonLogin, Login and digest webapps setUpNonLogin(tomcat); setUpDigest(tomcat); tomcat.start(); }
Example 2
Source File: TestSSOnonLoginAndDigestAuthenticator.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@Override public void setUp() throws Exception { super.setUp(); // create a tomcat server using the default in-memory Realm Tomcat tomcat = getTomcatInstance(); // associate the SingeSignOn Valve before the Contexts SingleSignOn sso = new SingleSignOn(); tomcat.getHost().getPipeline().addValve(sso); // add the test user and role to the Realm tomcat.addUser(USER, PWD); tomcat.addRole(USER, ROLE); // setup both NonLogin, Login and digest webapps setUpNonLogin(tomcat); setUpDigest(tomcat); tomcat.start(); }
Example 3
Source File: TestSSOnonLoginAndDigestAuthenticator.java From tomcatsrc with Apache License 2.0 | 6 votes |
@Override public void setUp() throws Exception { super.setUp(); // create a tomcat server using the default in-memory Realm Tomcat tomcat = getTomcatInstance(); // associate the SingeSignOn Valve before the Contexts SingleSignOn sso = new SingleSignOn(); tomcat.getHost().getPipeline().addValve(sso); // add the test user and role to the Realm tomcat.addUser(USER, PWD); tomcat.addRole(USER, ROLE); // setup both NonLogin, Login and digest webapps setUpNonLogin(tomcat); setUpDigest(tomcat); tomcat.start(); }
Example 4
Source File: TomcatTestServer.java From olingo-odata4 with Apache License 2.0 | 6 votes |
private TestServerBuilder(final int fixedPort) { initializeProperties(); baseDir = getFileForDirProperty(TOMCAT_BASE_DIR); if (!baseDir.exists() && !baseDir.mkdirs()) { throw new RuntimeException("Unable to create temporary test directory at {" + baseDir.getAbsolutePath() + "}"); } resourceDir = getFileForDirProperty(PROJECT_RESOURCES_DIR); if(!resourceDir.exists()){ throw new RuntimeException("Unable to load resources"); } tomcat = new Tomcat(); tomcat.setBaseDir(baseDir.getParentFile().getAbsolutePath()); tomcat.setPort(fixedPort); tomcat.getHost().setAppBase(baseDir.getAbsolutePath()); tomcat.getHost().setDeployOnStartup(true); tomcat.getConnector().setSecure(false); tomcat.setSilent(true); tomcat.addUser("odatajclient", "odatajclient"); tomcat.addRole("odatajclient", "odatajclient"); }
Example 5
Source File: TestWebSocketFrameClient.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Test public void testConnectToBasicEndpoint() throws Exception { Tomcat tomcat = getTomcatInstance(); Context ctx = tomcat.addContext(URI_PROTECTED, null); ctx.addApplicationListener(TesterEchoServer.Config.class.getName()); Tomcat.addServlet(ctx, "default", new DefaultServlet()); ctx.addServletMappingDecoded("/", "default"); SecurityCollection collection = new SecurityCollection(); collection.addPatternDecoded("/"); String utf8User = "test"; String utf8Pass = "123\u00A3"; // pound sign tomcat.addUser(utf8User, utf8Pass); tomcat.addRole(utf8User, ROLE); SecurityConstraint sc = new SecurityConstraint(); sc.addAuthRole(ROLE); sc.addCollection(collection); ctx.addConstraint(sc); LoginConfig lc = new LoginConfig(); lc.setAuthMethod("BASIC"); ctx.setLoginConfig(lc); AuthenticatorBase basicAuthenticator = new org.apache.catalina.authenticator.BasicAuthenticator(); ctx.getPipeline().addValve(basicAuthenticator); tomcat.start(); ClientEndpointConfig clientEndpointConfig = ClientEndpointConfig.Builder.create().build(); clientEndpointConfig.getUserProperties().put(Constants.WS_AUTHENTICATION_USER_NAME, utf8User); clientEndpointConfig.getUserProperties().put(Constants.WS_AUTHENTICATION_PASSWORD, utf8Pass); echoTester(URI_PROTECTED, clientEndpointConfig); }
Example 6
Source File: TestWebSocketFrameClient.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Test public void testConnectToDigestEndpoint() throws Exception { Tomcat tomcat = getTomcatInstance(); Context ctx = tomcat.addContext(URI_PROTECTED, null); ctx.addApplicationListener(TesterEchoServer.Config.class.getName()); Tomcat.addServlet(ctx, "default", new DefaultServlet()); ctx.addServletMappingDecoded("/", "default"); SecurityCollection collection = new SecurityCollection(); collection.addPatternDecoded("/*"); tomcat.addUser(USER, PWD); tomcat.addRole(USER, ROLE); SecurityConstraint sc = new SecurityConstraint(); sc.addAuthRole(ROLE); sc.addCollection(collection); ctx.addConstraint(sc); LoginConfig lc = new LoginConfig(); lc.setAuthMethod("DIGEST"); ctx.setLoginConfig(lc); AuthenticatorBase digestAuthenticator = new org.apache.catalina.authenticator.DigestAuthenticator(); ctx.getPipeline().addValve(digestAuthenticator); tomcat.start(); ClientEndpointConfig clientEndpointConfig = ClientEndpointConfig.Builder.create().build(); clientEndpointConfig.getUserProperties().put(Constants.WS_AUTHENTICATION_USER_NAME, USER); clientEndpointConfig.getUserProperties().put(Constants.WS_AUTHENTICATION_PASSWORD,PWD); echoTester(URI_PROTECTED, clientEndpointConfig); }