Merged branch 'jetty-11.0.x' into 'jetty-12.0.x'.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2023-10-01 22:48:58 +02:00
commit 0981c22c33
No known key found for this signature in database
GPG Key ID: 1677D141BCF3584D
3 changed files with 100 additions and 57 deletions

View File

@ -45,12 +45,15 @@ import org.eclipse.jetty.ee10.servlet.security.authentication.BasicAuthenticator
import org.eclipse.jetty.server.LocalConnector;
import org.eclipse.jetty.server.Server;
import org.junit.Test;
import org.junit.jupiter.api.condition.EnabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
import org.junit.runner.RunWith;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.startsWith;
@EnabledForJreRange(max = JRE.JAVA_17, disabledReason = "sun.security.x509.X509CertInfo.set not present in Java 21, needs a Java 21 compatible version of Apache Directory Server")
@RunWith(FrameworkRunner.class)
@CreateLdapServer(transports = {@CreateTransport(protocol = "LDAP")})
@CreateDS(allowAnonAccess = false, partitions = {
@ -170,7 +173,7 @@ public class JAASLdapLoginServiceTest
private Server _server;
private LocalConnector _connector;
private ServletContextHandler _context;
public void setUp() throws Exception
{
_server = new Server();
@ -198,14 +201,14 @@ public class JAASLdapLoginServiceTest
{
JAASLoginService ls = jaasLoginService("foo");
_server.addBean(ls, true);
_context.setServletHandler(new ServletHandler());
ServletHolder holder = new ServletHolder();
holder.setServlet(new TestServlet(hasRoles, hasntRoles));
_context.getServletHandler().addServletWithMapping(holder, "/");
_server.start();
return _connector.getResponse("GET /ctx/test HTTP/1.0\n" + "Authorization: Basic " +
Base64.getEncoder().encodeToString((username + ":" + password).getBytes(ISO_8859_1)) + "\n\n");
}
@ -218,28 +221,28 @@ public class JAASLdapLoginServiceTest
ServletHolder holder = new ServletHolder();
holder.setServlet(new TestServlet(Arrays.asList("developers", "admin"), Arrays.asList("blabla")));
_context.getServletHandler().addServletWithMapping(holder, "/");
JAASLoginService ls = new JAASLoginService("foo");
ls.setCallbackHandlerClass("org.eclipse.jetty.ee10.jaas.callback.DefaultCallbackHandler");
ls.setIdentityService(new DefaultIdentityService());
ls.setConfiguration(new TestConfiguration(false));
_server.addBean(ls, true);
_server.start();
String response = _connector.getResponse("GET /ctx/test HTTP/1.0\n" + "Authorization: Basic " +
Base64.getEncoder().encodeToString("someone:complicatedpassword".getBytes(ISO_8859_1)) + "\n\n");
assertThat(response, startsWith("HTTP/1.1 200 OK"));
_server.stop();
_context.setServletHandler(new ServletHandler());
holder = new ServletHolder();
holder.setServlet(new TestServlet(Arrays.asList("admin"), Arrays.asList("developers, blabla")));
_context.getServletHandler().addServletWithMapping(holder, "/");
_server.start();
response = _connector.getResponse("GET /ctx/test HTTP/1.0\n" + "Authorization: Basic " +
Base64.getEncoder().encodeToString("someoneelse:verycomplicatedpassword".getBytes(ISO_8859_1)) + "\n\n");
assertThat(response, startsWith("HTTP/1.1 200 OK"));
@ -259,8 +262,8 @@ public class JAASLdapLoginServiceTest
ls.setConfiguration(new TestConfiguration(true));
_server.addBean(ls, true);
_server.start();
String response = _connector.getResponse("GET /ctx/test HTTP/1.0\n" + "Authorization: Basic " +
Base64.getEncoder().encodeToString("someone:complicatedpassword".getBytes(ISO_8859_1)) + "\n\n");
assertThat(response, startsWith("HTTP/1.1 200 OK"));
@ -276,10 +279,10 @@ public class JAASLdapLoginServiceTest
if (req.getUserPrincipal() == null)
req.authenticate(resp);
}
}, "/");
_server.start();
//TODO this test shows response already committed!
response = _connector.getResponse("GET /ctx/test HTTP/1.0\n" + "Authorization: Basic " +
Base64.getEncoder().encodeToString("someone:wrongpassword".getBytes(ISO_8859_1)) + "\n\n");
@ -312,6 +315,5 @@ public class JAASLdapLoginServiceTest
String response = doLogin("ambiguousone", "barfoo", null, null);
assertThat(response, startsWith("HTTP/1.1 " + HttpServletResponse.SC_UNAUTHORIZED));
}
*/
*/
}

View File

@ -137,6 +137,13 @@ started()
local STATEFILE=$1
local PIDFILE=$2
local STARTTIMEOUT=$3
if (( DEBUG )) ; then
echo "Looking for $STATEFILE"
echo -n "State Parent Directory: "
ls -lad $(dirname $STATEFILE)
fi
# wait till timeout to see "STARTED" in state file, needs --module=state as argument
for ((T = 0; T < $STARTTIMEOUT; T++))
do
@ -162,6 +169,11 @@ started()
done
(( DEBUG )) && echo "Timeout $STARTTIMEOUT expired waiting for start state from $STATEFILE"
echo " timeout"
if running "$PIDFILE" ; then
echo "INFO: Server process is running"
else
echo "** ERROR: Server process is NOT running"
fi
return 1;
}
@ -173,7 +185,7 @@ pidKill()
if [ -r $PIDFILE ] ; then
local PID=$(tail -1 "$PIDFILE")
if [ -z "$PID" ] ; then
echo "ERROR: no pid found in $PIDFILE"
echo "** ERROR: no pid found in $PIDFILE"
return 1
fi
@ -204,7 +216,6 @@ pidKill()
fi
}
readConfig()
{
(( DEBUG )) && echo "Reading $1.."
@ -213,26 +224,25 @@ readConfig()
dumpEnv()
{
echo "JAVA = $JAVA"
echo "JAVA_OPTIONS = ${JAVA_OPTIONS[*]}"
echo "JETTY_HOME = $JETTY_HOME"
echo "JETTY_BASE = $JETTY_BASE"
echo "START_D = $START_D"
echo "START_INI = $START_INI"
echo "JETTY_START = $JETTY_START"
echo "JETTY_CONF = $JETTY_CONF"
echo "JETTY_ARGS = ${JETTY_ARGS[*]}"
echo "JETTY_RUN = $JETTY_RUN"
echo "JETTY_PID = $JETTY_PID"
echo "JETTY_START_LOG = $JETTY_START_LOG"
echo "JETTY_STATE = $JETTY_STATE"
echo "JETTY_START_TIMEOUT = $JETTY_START_TIMEOUT"
echo "JETTY_SYS_PROPS = $JETTY_SYS_PROPS"
echo "RUN_ARGS = ${RUN_ARGS[*]}"
echo "JAVA = $JAVA"
echo "JAVA_OPTIONS = ${JAVA_OPTIONS[*]}"
echo "JETTY_HOME = $JETTY_HOME"
echo "JETTY_BASE = $JETTY_BASE"
echo "START_D = $START_D"
echo "START_INI = $START_INI"
echo "JETTY_START = $JETTY_START"
echo "JETTY_CONF = $JETTY_CONF"
echo "JETTY_ARGS = ${JETTY_ARGS[*]}"
echo "JETTY_RUN = $JETTY_RUN"
echo "JETTY_PID = $JETTY_PID"
echo "JETTY_START_LOG = $JETTY_START_LOG"
echo "JETTY_STATE = $JETTY_STATE"
echo "JETTY_START_TIMEOUT = $JETTY_START_TIMEOUT"
echo "JETTY_SYS_PROPS = $JETTY_SYS_PROPS"
echo "RUN_ARGS = ${RUN_ARGS[*]}"
}
##################################################
# Get the action & configs
##################################################
@ -358,7 +368,15 @@ fi
if [ -z "$JETTY_RUN" ]
then
JETTY_RUN=$(findDirectory -w /var/run /usr/var/run $JETTY_BASE /tmp)/jetty
[ -d "$JETTY_RUN" ] || mkdir $JETTY_RUN
fi
if [ ! -d "$JETTY_RUN" ] ; then
if ! mkdir $JETTY_RUN
then
echo "** ERROR: Unable to create directory: $JETTY_RUN"
echo " Correct issues preventing the creation of \$JETTY_RUN and try again."
exit 1
fi
fi
#####################################################
@ -495,6 +513,11 @@ RUN_ARGS=($JETTY_SYS_PROPS ${JETTY_DRY_RUN[@]})
if (( DEBUG ))
then
if expr "${RUN_ARGS[*]}" : '.*/etc/console-capture.xml.*' > /dev/null
then
echo "WARNING: Disable console-capture module for best DEBUG results"
fi
echo "IDs are $(id)"
dumpEnv
fi
@ -503,13 +526,27 @@ fi
##################################################
case "$ACTION" in
start)
echo -n "Starting Jetty: "
if (( NO_START )); then
echo "Not starting ${NAME} - NO_START=1";
exit
fi
if ! touch "$JETTY_PID"
then
echo "** ERROR: Unable to touch file: $JETTY_PID"
echo " Correct issues preventing use of \$JETTY_PID and try again."
exit 1
fi
if ! touch "$JETTY_STATE"
then
echo "** ERROR: Unable to touch file: $JETTY_STATE"
echo " Correct issues preventing use of \$JETTY_STATE and try again."
exit 1
fi
echo -n "Starting Jetty: "
# Startup from a service file
if [ $UID -eq 0 ] && type start-stop-daemon > /dev/null 2>&1
then
@ -519,15 +556,16 @@ case "$ACTION" in
CH_USER="--chuid $JETTY_USER"
fi
echo ${RUN_ARGS[@]} start-log-file="$JETTY_START_LOG" | xargs start-stop-daemon \
echo ${RUN_ARGS[@]} --start-log-file="$JETTY_START_LOG" | xargs start-stop-daemon \
--start $CH_USER \
--pidfile "$JETTY_PID" \
--chdir "$JETTY_BASE" \
--background \
--output "${JETTY_RUN}/start-stop.log"
--make-pidfile \
--startas "$JAVA" \
--
(( DEBUG )) && echo "Starting: start-stop-daemon"
else
if running $JETTY_PID
@ -545,16 +583,19 @@ case "$ACTION" in
SU_SHELL="-s $JETTY_SHELL"
fi
touch "$JETTY_PID"
chown "$JETTY_USER" "$JETTY_PID"
su - "$JETTY_USER" $SU_SHELL -c "
cd \"$JETTY_BASE\"
echo ${RUN_ARGS[*]} start-log-file=\"$JETTY_START_LOG\" | xargs ${JAVA} > /dev/null &
disown \$!"
echo ${RUN_ARGS[*]} --start-log-file=\"$JETTY_START_LOG\" | xargs ${JAVA} > /dev/null &
PID=\$!
disown \$PID"
(( DEBUG )) && echo "Starting: su shell (w/user $JETTY_USER) on PID $PID"
else
# Startup if not switching users
echo ${RUN_ARGS[*]} | xargs ${JAVA} > /dev/null &
disown $!
echo ${RUN_ARGS[*]} --start-log-file="${JETTY_START_LOG}" | xargs ${JAVA} > /dev/null &
PID=$!
disown $PID
(( DEBUG )) && echo "Starting: java command on PID $PID"
fi
fi
@ -592,7 +633,7 @@ case "$ACTION" in
else
# Stop from a non-service path
if [ ! -r "$JETTY_PID" ] ; then
echo "ERROR: no pid found at $JETTY_PID"
echo "** ERROR: no pid found at $JETTY_PID"
exit 1
fi

20
pom.xml
View File

@ -34,20 +34,20 @@
<!-- dependency versions -->
<alpn.agent.version>2.0.10</alpn.agent.version>
<ant.version>1.10.14</ant.version>
<apache.avro.version>1.11.2</apache.avro.version>
<apache.avro.version>1.11.3</apache.avro.version>
<apache.httpclient.version>4.5.14</apache.httpclient.version>
<apache.httpcore.version>4.4.16</apache.httpcore.version>
<asciidoctorj-diagram.version>2.2.11</asciidoctorj-diagram.version>
<asciidoctorj-diagram.version>2.2.13</asciidoctorj-diagram.version>
<asciidoctorj.version>2.5.10</asciidoctorj.version>
<mina.core.version>2.2.2</mina.core.version>
<asm.version>9.5</asm.version>
<mina.core.version>2.2.3</mina.core.version>
<asm.version>9.6</asm.version>
<awaitility.version>4.2.0</awaitility.version>
<bndlib.version>6.4.1</bndlib.version>
<build-support.version>1.5</build-support.version>
<checkstyle.version>10.6.0</checkstyle.version>
<commons-codec.version>1.16.0</commons-codec.version>
<commons.compress.version>1.24.0</commons.compress.version>
<commons.io.version>2.13.0</commons.io.version>
<commons.io.version>2.14.0</commons.io.version>
<commons-lang3.version>3.13.0</commons-lang3.version>
<conscrypt.version>2.5.2</conscrypt.version>
<disruptor.version>3.4.2</disruptor.version>
@ -88,7 +88,7 @@
<jboss.logging.processor.version>2.2.1.Final</jboss.logging.processor.version>
<jboss.logging.version>3.5.3.Final</jboss.logging.version>
<jboss-logmanager.version>3.0.2.Final</jboss-logmanager.version>
<jboss-threads.version>3.5.0.Final</jboss-threads.version>
<jboss-threads.version>3.5.1.Final</jboss-threads.version>
<jetty-assembly-descriptors.version>1.1</jetty-assembly-descriptors.version>
<jetty.perf-helper.version>1.0.7</jetty.perf-helper.version>
<jetty-quiche-native.version>0.18.0</jetty-quiche-native.version>
@ -109,7 +109,7 @@
<maven.deps.version>3.9.4</maven.deps.version>
<maven-build-cache.version>1.0.1</maven-build-cache.version>
<maven-artifact-transfer.version>0.13.1</maven-artifact-transfer.version>
<maven.resolver.version>1.9.15</maven.resolver.version>
<maven.resolver.version>1.9.16</maven.resolver.version>
<maven.version>3.9.0</maven.version>
<mongodb.version>3.12.11</mongodb.version>
<netty.version>4.1.97.Final</netty.version>
@ -119,7 +119,7 @@
<org.osgi.util.function.version>1.2.0</org.osgi.util.function.version>
<org.osgi.util.promise.version>1.3.0</org.osgi.util.promise.version>
<osgi-version>3.18.400</osgi-version>
<osgi-version>3.18.500</osgi-version>
<!-- really used -->
<osgi-services-version>3.11.100</osgi-services-version>
<osgi-service-cm-version>1.6.1</osgi-service-cm-version>
@ -169,7 +169,7 @@
<maven.compiler.plugin.version>3.11.0</maven.compiler.plugin.version>
<maven.dependency.plugin.version>3.6.0</maven.dependency.plugin.version>
<maven.deploy.plugin.version>3.1.1</maven.deploy.plugin.version>
<maven.enforcer.plugin.version>3.4.0</maven.enforcer.plugin.version>
<maven.enforcer.plugin.version>3.4.1</maven.enforcer.plugin.version>
<maven.exec.plugin.version>3.1.0</maven.exec.plugin.version>
<maven.gpg.plugin.version>3.1.0</maven.gpg.plugin.version>
<maven.install.plugin.version>3.1.1</maven.install.plugin.version>
@ -182,7 +182,7 @@
<maven.release.plugin.version>3.0.1</maven.release.plugin.version>
<maven.remote-resources-plugin.version>3.1.0</maven.remote-resources-plugin.version>
<maven.resources.plugin.version>3.3.1</maven.resources.plugin.version>
<maven.shade.plugin.version>3.5.0</maven.shade.plugin.version>
<maven.shade.plugin.version>3.5.1</maven.shade.plugin.version>
<maven.surefire.plugin.version>3.1.2</maven.surefire.plugin.version>
<maven.source.plugin.version>3.3.0</maven.source.plugin.version>
<maven.war.plugin.version>3.4.0</maven.war.plugin.version>