Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/jetty-12.0.x' into fix/jetty-12.…
Browse files Browse the repository at this point in the history
…0.x/improve-ThreadLimitHandler
  • Loading branch information
lorban committed May 2, 2024
2 parents e871b3b + d7e66dd commit 9d06f46
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 128 deletions.
15 changes: 0 additions & 15 deletions jetty-core/jetty-deploy/src/main/config/etc/jetty-decorate.xml

This file was deleted.

16 changes: 0 additions & 16 deletions jetty-core/jetty-deploy/src/main/config/etc/jetty-web-decorate.xml

This file was deleted.

15 changes: 0 additions & 15 deletions jetty-core/jetty-deploy/src/main/config/modules/decorate.mod

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,13 @@ public TestHandler(List<String> hasRoles, List<String> hasntRoles)
@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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -62,7 +66,6 @@ public void tearDown() throws Exception
}

@Test
@Disabled //TODO
public void testPropertyFileLoginModule() throws Exception
{
//configure for PropertyFileLoginModule
Expand All @@ -81,24 +84,21 @@ public AppConfigurationEntry[] getAppConfigurationEntry(String name)

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());
Expand Down

0 comments on commit 9d06f46

Please sign in to comment.