parent
3e78f82c9e
commit
756cf2102e
|
@ -13,32 +13,30 @@
|
|||
<bundle-symbolic-name>${project.groupId}.jaas</bundle-symbolic-name>
|
||||
</properties>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<!--
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty.ee10</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<artifactId>jetty-ee10-maven-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<configuration>
|
||||
<scan>10</scan>
|
||||
<systemProperties>
|
||||
<!-- This is for convenience so that the src/etc/login.conf file can stay unmodified when copied to $jetty.home/etc directory -->
|
||||
<jetty.base>${basedir}/src/main/config/modules/demo.d</jetty.base>
|
||||
<!-- Mandatory. This system property tells JAAS where to find the login module configuration file -->
|
||||
<java.security.auth.login.config>${basedir}/src/main/config/modules/demo.d/demo-login.conf</java.security.auth.login.config>
|
||||
<java.security.auth.login.config>${basedir}/src/main/etc/ee10-demo-login.conf</java.security.auth.login.config>
|
||||
</systemProperties>
|
||||
<webApp>
|
||||
<contextPath>/test-jaas</contextPath>
|
||||
<contextPath>/ee10-test-jaas</contextPath>
|
||||
<securityHandler implementation="org.eclipse.jetty.ee10.security.ConstraintSecurityHandler">
|
||||
<loginService implementation="org.eclipse.jetty.ee10.jaas.JAASLoginService">
|
||||
<name>Test JAAS Realm</name>
|
||||
<loginModuleName>xyz</loginModuleName>
|
||||
<loginModuleName>ee10-xyz</loginModuleName>
|
||||
</loginService>
|
||||
</securityHandler>
|
||||
</webApp>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
-->
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<Set name="loginService">
|
||||
<New class="org.eclipse.jetty.ee10.jaas.JAASLoginService">
|
||||
<Set name="name">Demo JAAS Realm</Set>
|
||||
<Set name="loginModuleName">xyz</Set>
|
||||
<Set name="loginModuleName">ee10-xyz</Set>
|
||||
</New>
|
||||
</Set>
|
||||
</New>
|
||||
|
|
|
@ -11,6 +11,7 @@ demo
|
|||
webapp
|
||||
|
||||
[depends]
|
||||
demo-jaas
|
||||
ee10-deploy
|
||||
ee10-jaas
|
||||
jdbc
|
||||
|
@ -20,7 +21,6 @@ ext
|
|||
|
||||
[files]
|
||||
basehome:modules/demo.d/ee10-demo-jaas.xml|webapps/ee10-demo-jaas.xml
|
||||
basehome:modules/demo.d/ee10-demo-login.conf|etc/ee10-demo-login.conf
|
||||
basehome:modules/demo.d/ee10-demo-login.properties|etc/ee10-demo-login.properties
|
||||
maven://org.eclipse.jetty.ee10.demos/jetty-ee10-demo-jaas-webapp/${jetty.version}/war|webapps/ee10-demo-jaas.war
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
xyz {
|
||||
ee10-xyz {
|
||||
org.eclipse.jetty.ee10.jaas.spi.PropertyFileLoginModule required
|
||||
debug="true"
|
||||
file="${jetty.base}/etc/ee10-demo-login.properties";
|
|
@ -26,13 +26,6 @@
|
|||
It uses a simple login module that stores its configuration in a properties file.
|
||||
</p>
|
||||
|
||||
<h2>Preparation</h2>
|
||||
<p>To use JAAS in a base jetty instance enable the <code>jaas</code> module:
|
||||
<pre>
|
||||
$ cd $JETTY_BASE
|
||||
$ java -jar $JETTY_HOME/start.jar --add-module=jaas
|
||||
</pre>
|
||||
|
||||
<h2>Using the Demo</h2>
|
||||
<p>
|
||||
Click on the link below to test JAAS <i>authentication</i> and role-based web security constraint <i>authorization</i>. Use
|
||||
|
|
|
@ -14,32 +14,30 @@
|
|||
<bundle-symbolic-name>${project.groupId}.jaas</bundle-symbolic-name>
|
||||
</properties>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<!-- pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<groupId>org.eclipse.jetty.ee8</groupId>
|
||||
<artifactId>jetty-ee8-maven-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<configuration>
|
||||
<scan>10</scan>
|
||||
<systemProperties>
|
||||
<!-- This is for convenience so that the src/etc/login.conf file can stay unmodified when copied to $jetty.home/etc directory -->
|
||||
<jetty.base>${basedir}/src/main/config/modules/demo.d</jetty.base>
|
||||
<!-- Mandatory. This system property tells JAAS where to find the login module configuration file -->
|
||||
<java.security.auth.login.config>${basedir}/src/main/config/modules/demo.d/ee8-demo-login.conf</java.security.auth.login.config>
|
||||
<java.security.auth.login.config>${basedir}/src/main/etc/ee8-demo-login.conf</java.security.auth.login.config>
|
||||
</systemProperties>
|
||||
<webApp>
|
||||
<contextPath>/test-jaas</contextPath>
|
||||
<securityHandler implementation="org.eclipse.jetty.security.ConstraintSecurityHandler">
|
||||
<loginService implementation="org.eclipse.jetty.jaas.JAASLoginService">
|
||||
<loginService implementation="org.eclipse.jetty.ee8.jaas.JAASLoginService">
|
||||
<name>Test JAAS Realm</name>
|
||||
<loginModuleName>xyz</loginModuleName>
|
||||
<loginModuleName>ee8-xyz</loginModuleName>
|
||||
</loginService>
|
||||
</securityHandler>
|
||||
</webApp>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</pluginManagement -->
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<Set name="loginService">
|
||||
<New class="org.eclipse.jetty.ee8.jaas.JAASLoginService">
|
||||
<Set name="name">Demo JAAS Realm</Set>
|
||||
<Set name="loginModuleName">xyz</Set>
|
||||
<Set name="loginModuleName">ee8-xyz</Set>
|
||||
</New>
|
||||
</Set>
|
||||
</New>
|
||||
|
|
|
@ -11,6 +11,7 @@ demo
|
|||
webapp
|
||||
|
||||
[depends]
|
||||
demo-jaas
|
||||
ee8-deploy
|
||||
ee8-jaas
|
||||
jdbc
|
||||
|
@ -21,7 +22,6 @@ ext
|
|||
[files]
|
||||
basehome:modules/demo.d/ee8-demo-jaas.xml|webapps/ee8-demo-jaas.xml
|
||||
basehome:modules/demo.d/ee8-demo-jaas.properties|webapps/ee8-demo-jaas.properties
|
||||
basehome:modules/demo.d/ee8-demo-login.conf|etc/ee8-demo-login.conf
|
||||
basehome:modules/demo.d/ee8-demo-login.properties|etc/ee8-demo-login.properties
|
||||
maven://org.eclipse.jetty.ee8.demos/jetty-ee8-demo-jaas-webapp/${jetty.version}/war|webapps/ee8-demo-jaas.war
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
xyz {
|
||||
ee8-xyz {
|
||||
org.eclipse.jetty.ee8.jaas.spi.PropertyFileLoginModule required
|
||||
debug="true"
|
||||
file="${jetty.base}/etc/ee8-demo-login.properties";
|
|
@ -13,32 +13,30 @@
|
|||
<bundle-symbolic-name>${project.groupId}.jaas</bundle-symbolic-name>
|
||||
</properties>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<!-- pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<groupId>org.eclipse.jetty.ee9</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<configuration>
|
||||
<scan>10</scan>
|
||||
<systemProperties>
|
||||
<!-- This is for convenience so that the src/etc/login.conf file can stay unmodified when copied to $jetty.home/etc directory -->
|
||||
<jetty.base>${basedir}/src/main/config/modules/demo.d</jetty.base>
|
||||
<!-- Mandatory. This system property tells JAAS where to find the login module configuration file -->
|
||||
<java.security.auth.login.config>${basedir}/src/main/config/modules/demo.d/ee9-demo-login.conf</java.security.auth.login.config>
|
||||
<java.security.auth.login.config>${basedir}/src/main/etc/ee9-demo-login.conf</java.security.auth.login.config>
|
||||
</systemProperties>
|
||||
<webApp>
|
||||
<contextPath>/test-jaas</contextPath>
|
||||
<securityHandler implementation="org.eclipse.jetty.security.ConstraintSecurityHandler">
|
||||
<loginService implementation="org.eclipse.jetty.jaas.JAASLoginService">
|
||||
<loginService implementation="org.eclipse.jetty.ee9.jaas.JAASLoginService">
|
||||
<name>Test JAAS Realm</name>
|
||||
<loginModuleName>xyz</loginModuleName>
|
||||
<loginModuleName>ee9-xyz</loginModuleName>
|
||||
</loginService>
|
||||
</securityHandler>
|
||||
</webApp>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</pluginManagement -->
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<Set name="loginService">
|
||||
<New class="org.eclipse.jetty.ee9.jaas.JAASLoginService">
|
||||
<Set name="name">Demo JAAS Realm</Set>
|
||||
<Set name="loginModuleName">xyz</Set>
|
||||
<Set name="loginModuleName">ee9-xyz</Set>
|
||||
</New>
|
||||
</Set>
|
||||
</New>
|
||||
|
|
|
@ -11,6 +11,7 @@ demo
|
|||
webapp
|
||||
|
||||
[depends]
|
||||
demo-jaas
|
||||
ee9-deploy
|
||||
ee9-jaas
|
||||
jdbc
|
||||
|
@ -21,7 +22,6 @@ ext
|
|||
[files]
|
||||
basehome:modules/demo.d/ee9-demo-jaas.xml|webapps/ee9-demo-jaas.xml
|
||||
basehome:modules/demo.d/ee9-demo-jaas.properties|webapps/ee9-demo-jaas.properties
|
||||
basehome:modules/demo.d/ee9-demo-login.conf|etc/ee9-demo-login.conf
|
||||
basehome:modules/demo.d/ee9-demo-login.properties|etc/ee9-demo-login.properties
|
||||
maven://org.eclipse.jetty.ee9.demos/jetty-ee9-demo-jaas-webapp/${jetty.version}/war|webapps/ee9-demo-jaas.war
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
xyz {
|
||||
ee9-xyz {
|
||||
org.eclipse.jetty.ee9.jaas.spi.PropertyFileLoginModule required
|
||||
debug="true"
|
||||
file="${jetty.base}/etc/ee9-demo-login.properties";
|
|
@ -25,13 +25,6 @@
|
|||
|
||||
It uses a simple login module that stores its configuration in a properties file.
|
||||
</p>
|
||||
|
||||
<h2>Preparation</h2>
|
||||
<p>To use JAAS in a base jetty instance enable the <code>jaas</code> module:
|
||||
<pre>
|
||||
$ cd $JETTY_BASE
|
||||
$ java -jar $JETTY_HOME/start.jar --add-module=jaas
|
||||
</pre>
|
||||
|
||||
<h2>Using the Demo</h2>
|
||||
<p>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# DO NOT EDIT - See: https://www.eclipse.org/jetty/documentation/current/startup-modules.html
|
||||
|
||||
[description]
|
||||
Setup for jaas demos.
|
||||
|
||||
[environment]
|
||||
core
|
||||
|
||||
[tags]
|
||||
demo
|
||||
|
||||
[files]
|
||||
basehome:modules/demo.d/demo-login.conf|etc/demo-login.conf
|
|
@ -0,0 +1,17 @@
|
|||
ee10-xyz {
|
||||
org.eclipse.jetty.ee10.jaas.spi.PropertyFileLoginModule required
|
||||
debug="true"
|
||||
file="${jetty.base}/etc/ee10-demo-login.properties";
|
||||
};
|
||||
|
||||
ee9-xyz {
|
||||
org.eclipse.jetty.ee9.jaas.spi.PropertyFileLoginModule required
|
||||
debug="true"
|
||||
file="${jetty.base}/etc/ee9-demo-login.properties";
|
||||
};
|
||||
|
||||
ee8-xyz {
|
||||
org.eclipse.jetty.ee8.jaas.spi.PropertyFileLoginModule required
|
||||
debug="true"
|
||||
file="${jetty.base}/etc/ee8-demo-login.properties";
|
||||
};
|
|
@ -139,6 +139,56 @@ public class DemoModulesTests extends AbstractJettyHomeTest
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideEnvironmentsToTest")
|
||||
public void testJaasDemo(String env) throws Exception
|
||||
{
|
||||
Path jettyBase = newTestJettyBaseDirectory();
|
||||
String jettyVersion = System.getProperty("jettyVersion");
|
||||
JettyHomeTester distribution = JettyHomeTester.Builder.newInstance()
|
||||
.jettyVersion(jettyVersion)
|
||||
.jettyBase(jettyBase)
|
||||
.mavenLocalRepository(System.getProperty("mavenRepoPath"))
|
||||
.build();
|
||||
|
||||
int httpPort = distribution.freePort();
|
||||
int httpsPort = distribution.freePort();
|
||||
assertThat("httpPort != httpsPort", httpPort, is(not(httpsPort)));
|
||||
|
||||
String[] argsConfig = {
|
||||
"--add-modules=http," + toEnvironment("demos", env)
|
||||
};
|
||||
|
||||
String baseURI = "http://localhost:%d/%s-test-jaas".formatted(httpPort, env);
|
||||
|
||||
try (JettyHomeTester.Run runConfig = distribution.start(argsConfig))
|
||||
{
|
||||
assertTrue(runConfig.awaitFor(START_TIMEOUT, TimeUnit.SECONDS));
|
||||
assertEquals(0, runConfig.getExitValue());
|
||||
|
||||
String[] argsStart =
|
||||
{
|
||||
"jetty.http.port=" + httpPort,
|
||||
"jetty.httpConfig.port=" + httpsPort,
|
||||
"jetty.ssl.port=" + httpsPort
|
||||
};
|
||||
|
||||
try (JettyHomeTester.Run runStart = distribution.start(argsStart))
|
||||
{
|
||||
assertTrue(runStart.awaitConsoleLogsFor("Started oejs.Server@", START_TIMEOUT, TimeUnit.SECONDS));
|
||||
|
||||
startHttpClient();
|
||||
ContentResponse response = client.GET(baseURI + "/auth.html");
|
||||
Fields fields = new Fields();
|
||||
fields.put("j_username", "me");
|
||||
fields.put("j_password", "me");
|
||||
response = client.FORM(baseURI + "/j_security_check", fields);
|
||||
assertEquals(HttpStatus.OK_200, response.getStatus(), new ResponseDetails(response));;
|
||||
assertThat(response.getContentAsString(), containsString("SUCCESS!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideEnvironmentsToTest")
|
||||
|
|
Loading…
Reference in New Issue