forked from akhikhl/gretty
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework single-sign-on to cope with Jetty 11
Sharing the session handler between contexts leads to an NPE, because startup of the first context now reaches into the lifecycle of the second webapp, which has not started yet. SessionHandler objects, which carry context-specific lifecycle information, must not be shared between contexts.
- Loading branch information
Showing
2 changed files
with
34 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...retty-runner-jetty11/src/main/groovy/org/akhikhl/gretty/SingleSignOnSessionHandler.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.akhikhl.gretty | ||
|
||
import org.eclipse.jetty.server.session.Session | ||
import org.eclipse.jetty.server.session.SessionHandler | ||
|
||
class SingleSignOnSessionHandler extends SessionHandler { | ||
|
||
@Override | ||
Session getSession(String id) { | ||
Session session = getLocalSession(id) | ||
if (session == null) { | ||
for (SessionHandler handler : getSessionIdManager().getSessionHandlers()) { | ||
|
||
if (handler == this || !(handler instanceof SingleSignOnSessionHandler)) { | ||
continue | ||
} | ||
|
||
session = ((SingleSignOnSessionHandler) handler).getLocalSession(id) | ||
if (session != null) { | ||
break | ||
} | ||
} | ||
} | ||
|
||
return session | ||
} | ||
|
||
private Session getLocalSession(String id) { | ||
return super.getSession(id) | ||
} | ||
} |