Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.1.x

This commit is contained in:
Jan Bartel 2024-05-01 15:27:49 +10:00
commit 53bb51a69d
10 changed files with 20 additions and 130 deletions

View File

@ -1,15 +0,0 @@
<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://eclipse.dev/jetty/configure_9_3.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- Bind the jetty-web-decorate.xml to every deployed webapp -->
<Ref refid="DeploymentManager">
<Call name="addLifeCycleBinding">
<Arg>
<New class="org.eclipse.jetty.ee11.deployer.GlobalWebappConfigBinding">
<Set name="jettyXml"><Property name="jetty.home" default="." />/etc/jetty-web-decorate.xml
</Set>
</New>
</Arg>
</Call>
</Ref>
</Configure>

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://eclipse.dev/jetty/configure_9_3.dtd">
<Configure class="org.eclipse.jetty.ee9.webapp.WebAppContext" id="context">
<Get class="org.eclipse.jetty.ee9.webapp.DecoratingListener" name="DECORATOR_ATTRIBUTE" id="decoratorAttribute"/>
<!-- Add the DecoratingListener to the webapp to look for dynamic decorators -->
<Call name="addEventListener">
<Arg>
<New class="org.eclipse.jetty.ee9.webapp.DecoratingListener">
<Arg><Ref refid="context" /></Arg>
<Arg type="String"><Ref refid="decoratorAttribute"/></Arg>
</New>
</Arg>
</Call>
</Configure>

View File

@ -1,15 +0,0 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
[description]
Jetty setup to support Decoration of Listeners, Filters and Servlets within a deployed webapp.
This module uses DecoratingListener to register an object set as a context attribute
as a dynamic decorator.
This module sets the "org.eclipse.jetty.ee9.webapp.DecoratingListener"
context attribute with the name of the context attribute that will be listened to.
By default the attribute is "org.eclipse.jetty.ee9.webapp.decorator".
[depend]
deploy
[xml]
etc/jetty-decorate.xml

View File

@ -1,19 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Ref refid="DeploymentManager">
<Call name="addLifeCycleBinding">
<Arg>
<New class="org.eclipse.jetty.ee11.deployer.GlobalWebappConfigBinding">
<Set name="jettyXml">
<Call name="resolvePath" class="org.eclipse.jetty.xml.XmlConfiguration">
<Arg><Property name="jetty.base"/></Arg>
<Arg><Property name="jetty.deploy.webappCommonConfig" default="etc/webapp-common.xml"/></Arg>
</Call>
</Set>
</New>
</Arg>
</Call>
</Ref>
</Configure>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://eclipse.dev/jetty/configure_10_0.dtd">
<Configure class="org.eclipse.jetty.ee9.webapp.WebAppContext">
<!-- ===================================== -->
<!-- Add common setup for all webapps here -->
<!-- ===================================== -->
</Configure>

View File

@ -1,19 +0,0 @@
# DO NOT EDIT THIS FILE - See: https://eclipse.dev/jetty/documentation/
[description]
Enables Deployer to apply common configuration to all webapp deployments.
[depend]
deploy
[xml]
etc/global-webapp-common.xml
[files]
basehome:modules/global-webapp-common.d/global-webapp-common.xml|etc/global-webapp-common.xml
basehome:modules/global-webapp-common.d/webapp-common.xml|etc/webapp-common.xml
[ini-template]
# Location of webapp xml config file to apply after context xml
# jetty.deploy.webappCommonConfig=${jetty.base}/etc/webapp-common.xml

View File

@ -41,29 +41,13 @@ public class TestHandler extends Handler.Abstract
@Override
public boolean handle(Request request, Response response, Callback callback) throws Exception
{
if (_hasRoles == null && _hasntRoles == null)
{
try
{
// TODO this is wrong
AuthenticationState.authenticate(request, response, callback);
}
catch (Throwable e)
{
//TODO: an Exception should only be thrown here if the response has
//not been set, but currently it seems that the ServletException is thrown
//anyway by ServletContextRequest.ServletApiRequest.authenticate.
}
}
else
{
testHasRoles(request, response);
testHasntRoles(request, response);
testHasRoles(request, response);
testHasntRoles(request, response);
response.setStatus(200);
response.getHeaders().put(HttpHeader.CONTENT_TYPE, "text/plain");
Content.Sink.write(response, true, "All OK\nrequestURI=" + request.getHttpURI(), callback);
response.setStatus(200);
response.getHeaders().put(HttpHeader.CONTENT_TYPE, "text/plain");
Content.Sink.write(response, true, "All OK\nrequestURI=" + request.getHttpURI(), callback);
}
return true;
}

View File

@ -14,23 +14,27 @@
package org.eclipse.jetty.security.jaas.spi;
import java.io.File;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collections;
import javax.security.auth.login.AppConfigurationEntry;
import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
import javax.security.auth.login.Configuration;
import org.eclipse.jetty.security.Constraint;
import org.eclipse.jetty.security.DefaultIdentityService;
import org.eclipse.jetty.security.PropertyUserStore;
import org.eclipse.jetty.security.SecurityHandler;
import org.eclipse.jetty.security.authentication.BasicAuthenticator;
import org.eclipse.jetty.security.jaas.JAASLoginService;
import org.eclipse.jetty.security.jaas.PropertyUserStoreManager;
import org.eclipse.jetty.security.jaas.TestHandler;
import org.eclipse.jetty.server.LocalConnector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static java.nio.charset.StandardCharsets.ISO_8859_1;
@ -62,7 +66,6 @@ public class PropertyFileLoginModuleTest
}
@Test
@Disabled //TODO
public void testPropertyFileLoginModule() throws Exception
{
//configure for PropertyFileLoginModule
@ -81,24 +84,21 @@ public class PropertyFileLoginModuleTest
ContextHandler context = new ContextHandler();
context.setContextPath("/ctx");
/* TODO
context.setHandler(new TestHandler(Arrays.asList("role1", "role2", "role3"), Arrays.asList("role4")), "/");
SecurityHandler.PathMapped securityHandler = new SecurityHandler.PathMapped();
securityHandler.setAuthenticator(new BasicAuthenticator());
securityHandler.put("/*", Constraint.from("role1", "role2", "role3"));
context.setHandler(securityHandler);
securityHandler.setHandler(new TestHandler(Arrays.asList("role1", "role2", "role3"), Arrays.asList("role4")));
_server.setHandler(context);
ConstraintSecurityHandler security = new ConstraintSecurityHandler();
security.setAuthenticator(new BasicAuthenticator());
context.setSecurityHandler(security);
*/
JAASLoginService ls = new JAASLoginService("foo");
ls.setCallbackHandlerClass("org.eclipse.jetty.ee10.jaas.callback.DefaultCallbackHandler");
ls.setCallbackHandlerClass("org.eclipse.jetty.security.jaas.callback.DefaultCallbackHandler");
ls.setIdentityService(new DefaultIdentityService());
ls.setConfiguration(testConfig);
_server.addBean(ls, true);
_server.start();
//test that the manager is created when the JAASLoginService starts
PropertyUserStoreManager mgr = ls.getBean(PropertyUserStoreManager.class);
assertThat(mgr, notNullValue());

View File

@ -11,7 +11,7 @@
// ========================================================================
//
package org.eclipse.jetty.ee10.test;
package org.eclipse.jetty.ee9.test;
import java.io.IOException;

View File

@ -8,7 +8,7 @@
<servlet>
<servlet-name>BadInit</servlet-name>
<servlet-class>org.eclipse.jetty.ee10.test.BadServletInit</servlet-class>
<servlet-class>org.eclipse.jetty.ee9.test.BadServletInit</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>