Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Basic Authentication with RAP 1.5 and Jetty 8
Basic Authentication with RAP 1.5 and Jetty 8 [message #900288] Mon, 06 August 2012 11:28 Go to next message
Peter Kullmann is currently offline Peter Kullmann
Messages: 199
Registered: July 2009
Senior Member
Hi, I'm trying to use BASIC Authentication with a RAP 1.5 application on Jetty 8. I was following the advice in http://wiki.eclipse.org/RAP/FAQ#How_can_I_use_Jetty_basic_authentication_in_my_application.3F For Jetty 8 this must be changed. I ended up with:
    @Override
    public Object customizeContext(Object o, Dictionary<String, ?> settings) {
        Constraint constraint = new Constraint();
        constraint.setName(Constraint.__BASIC_AUTH);
        constraint.setRoles(new String[] { "admin" });
        constraint.setAuthenticate(true);

        ConstraintMapping mapping = new ConstraintMapping();
        mapping.setConstraint(constraint);
        mapping.setPathSpec("/*");

        HashLoginService loginService = new HashLoginService("MyRealm");
        loginService.setConfig("/tmp/users.properties");

        ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
        securityHandler.setLoginService(loginService);
        securityHandler
                .setConstraintMappings(new ConstraintMapping[] { mapping });

        ServletContextHandler context = (ServletContextHandler) o;
        context.setSecurityHandler(securityHandler);

        return o;
    }


The problem is that the rap application is no longer working. I'm getting the following error:

13:23:45.248 [qtp2041731356-32] WARN  o.e.j.server.AbstractHttpConnection - /pc/rwt-resources/rap-org.eclipse.swt.theme.Custom_c072efd1-6e45cccf.js
java.lang.IllegalStateException: null
	at org.eclipse.jetty.server.session.AbstractSession.checkValid(AbstractSession.java:91) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.session.HashedSession.checkValid(HashedSession.java:55) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.session.AbstractSession.getAttributeNames(AbstractSession.java:135) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.security.authentication.LoginAuthenticator.renewSessionOnAuthentication(LoginAuthenticator.java:70) ~[na:na]
	at org.eclipse.jetty.security.authentication.BasicAuthenticator.validateRequest(BasicAuthenticator.java:86) ~[na:na]
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:456) ~[na:na]
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413) ~[na:na]
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.Server.handle(Server.java:350) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630) [org.eclipse.jetty.http_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230) [org.eclipse.jetty.http_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606) [org.eclipse.jetty.io_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46) [org.eclipse.jetty.io_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603) [org.eclipse.jetty.util_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538) [org.eclipse.jetty.util_8.1.3.v20120522.jar:8.1.3.v20120522]
	at java.lang.Thread.run(Thread.java:680) [na:1.6.0_33]
13:23:45.249 [qtp2041731356-33] WARN  o.e.j.server.AbstractHttpConnection - /pc/rwt-resources/resources-ec84389.js
java.lang.IllegalStateException: null
	at org.eclipse.jetty.server.session.AbstractSession.checkValid(AbstractSession.java:91) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.session.HashedSession.checkValid(HashedSession.java:55) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.session.AbstractSession.getAttributeNames(AbstractSession.java:135) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.security.authentication.LoginAuthenticator.renewSessionOnAuthentication(LoginAuthenticator.java:70) ~[na:na]
	at org.eclipse.jetty.security.authentication.BasicAuthenticator.validateRequest(BasicAuthenticator.java:86) ~[na:na]
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:456) ~[na:na]
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413) ~[na:na]
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.Server.handle(Server.java:350) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630) [org.eclipse.jetty.http_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230) [org.eclipse.jetty.http_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606) [org.eclipse.jetty.io_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46) [org.eclipse.jetty.io_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603) [org.eclipse.jetty.util_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538) [org.eclipse.jetty.util_8.1.3.v20120522.jar:8.1.3.v20120522]
	at java.lang.Thread.run(Thread.java:680) [na:1.6.0_33]
13:23:45.257 [qtp2041731356-31] WARN  o.e.j.server.AbstractHttpConnection - /pc/rwt-resources/rap-org.eclipse.swt.theme.Fallback-361cffdf.js
java.lang.IllegalStateException: null
	at org.eclipse.jetty.server.session.AbstractSession.checkValid(AbstractSession.java:91) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.session.HashedSession.checkValid(HashedSession.java:55) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.session.AbstractSession.getAttributeNames(AbstractSession.java:135) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.security.authentication.LoginAuthenticator.renewSessionOnAuthentication(LoginAuthenticator.java:70) ~[na:na]
	at org.eclipse.jetty.security.authentication.BasicAuthenticator.validateRequest(BasicAuthenticator.java:86) ~[na:na]
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:456) ~[na:na]
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413) ~[na:na]
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.Server.handle(Server.java:350) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630) [org.eclipse.jetty.http_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230) [org.eclipse.jetty.http_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606) [org.eclipse.jetty.io_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46) [org.eclipse.jetty.io_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603) [org.eclipse.jetty.util_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538) [org.eclipse.jetty.util_8.1.3.v20120522.jar:8.1.3.v20120522]
	at java.lang.Thread.run(Thread.java:680) [na:1.6.0_33]
13:23:45.260 [qtp2041731356-34] WARN  o.e.j.server.AbstractHttpConnection - /pc/rwt-resources/themes/images/ee7d83c5
java.lang.IllegalStateException: null
	at org.eclipse.jetty.server.session.AbstractSession.checkValid(AbstractSession.java:91) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.session.HashedSession.checkValid(HashedSession.java:55) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.session.AbstractSession.getAttributeNames(AbstractSession.java:135) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.security.authentication.LoginAuthenticator.renewSessionOnAuthentication(LoginAuthenticator.java:70) ~[na:na]
	at org.eclipse.jetty.security.authentication.BasicAuthenticator.validateRequest(BasicAuthenticator.java:86) ~[na:na]
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:456) ~[na:na]
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413) ~[na:na]
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.Server.handle(Server.java:350) ~[org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630) [org.eclipse.jetty.http_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230) [org.eclipse.jetty.http_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77) [org.eclipse.jetty.server_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606) [org.eclipse.jetty.io_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46) [org.eclipse.jetty.io_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603) [org.eclipse.jetty.util_8.1.3.v20120522.jar:8.1.3.v20120522]
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538) [org.eclipse.jetty.util_8.1.3.v20120522.jar:8.1.3.v20120522]
	at java.lang.Thread.run(Thread.java:680) [na:1.6.0_33]
13:23:45.590 [qtp2041731356-34] WARN  o.e.jetty.servlet.ServletHandler - /pc/standard;jsessionid=1998n1rrnihvn1s6suny66agym
java.lang.NullPointerException: null
	at org.eclipse.rwt.SessionSingletonBase.getInstance(SessionSingletonBase.java:56) ~[org.eclipse.rap.rwt_1.5.0.20120529-1205.jar:na]
	at org.eclipse.rwt.internal.uicallback.UICallBackManager.getInstance(UICallBackManager.java:35) ~[org.eclipse.rap.rwt_1.5.0.20120529-1205.jar:na]
	at org.eclipse.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:287) ~[org.eclipse.rap.rwt_1.5.0.20120529-1205.jar:na]
	at java.lang.Thread.run(Thread.java:680) ~[na:1.6.0_33]
	at org.eclipse.rwt.internal.lifecycle.UIThread.run(UIThread.java:101) ~[org.eclipse.rap.rwt_1.5.0.20120529-1205.jar:na]


Am I doing something wrong?

Thanks for advice
Peter
Re: Basic Authentication with RAP 1.5 and Jetty 8 [message #972201 is a reply to message #900288] Mon, 05 November 2012 12:42 Go to previous messageGo to next message
Stefan M is currently offline Stefan M
Messages: 29
Registered: September 2012
Junior Member
I'm having the same problem, did you get a solution for it?
Re: Basic Authentication with RAP 1.5 and Jetty 8 [message #972218 is a reply to message #972201] Mon, 05 November 2012 12:56 Go to previous messageGo to next message
Peter Kullmann is currently offline Peter Kullmann
Messages: 199
Registered: July 2009
Senior Member
No, nothing yet. I'm still having the problem,
Re: Basic Authentication with RAP 1.5 and Jetty 8 [message #986000 is a reply to message #900288] Sat, 17 November 2012 10:45 Go to previous message
Peter Kullmann is currently offline Peter Kullmann
Messages: 199
Registered: July 2009
Senior Member
The problem was that jetty renews the session after the user is authenticated by default. This can be switched off, though:

       ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
        securityHandler.setLoginService(loginService);
        securityHandler
                .setConstraintMappings(new ConstraintMapping[] { mapping });
        securityHandler.setSessionRenewedOnAuthentication(false);
Previous Topic:CTabFolder strange border
Next Topic:[ANN] RAP 2.0 M3 is available
Goto Forum:
  


Current Time: Tue Oct 21 18:32:19 GMT 2014

Powered by FUDForum. Page generated in 0.03157 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software