ISIS-1481: ensures that all methods of AuthenticatedWebSession are synchronized, in order to avoid a race conditions, eg in SessionLoggingService when authenicating.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/bab40dc2 Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/bab40dc2 Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/bab40dc2 Branch: refs/heads/master Commit: bab40dc25d00761bd447a0aaa7305f4efea7044d Parents: 87966d8 Author: Dan Haywood <[email protected]> Authored: Wed Sep 7 14:35:47 2016 +0100 Committer: Dan Haywood <[email protected]> Committed: Wed Sep 7 14:35:47 2016 +0100 ---------------------------------------------------------------------- .../wicket/AuthenticatedWebSessionForIsis.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/isis/blob/bab40dc2/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/AuthenticatedWebSessionForIsis.java ---------------------------------------------------------------------- diff --git a/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/AuthenticatedWebSessionForIsis.java b/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/AuthenticatedWebSessionForIsis.java index 60750f0..21189a1 100644 --- a/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/AuthenticatedWebSessionForIsis.java +++ b/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/AuthenticatedWebSessionForIsis.java @@ -21,7 +21,6 @@ package org.apache.isis.viewer.wicket.viewer.integration.wicket; import java.util.Arrays; import java.util.List; -import java.util.concurrent.Callable; import org.apache.wicket.Session; import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; @@ -68,7 +67,7 @@ public class AuthenticatedWebSessionForIsis extends AuthenticatedWebSession impl } @Override - public boolean authenticate(final String username, final String password) { + public synchronized boolean authenticate(final String username, final String password) { AuthenticationRequest authenticationRequest = new AuthenticationRequestPassword(username, password); authenticationRequest.setRoles(Arrays.asList(USER_ROLE)); authenticationSession = getAuthenticationManager().authenticate(authenticationRequest); @@ -81,7 +80,7 @@ public class AuthenticatedWebSessionForIsis extends AuthenticatedWebSession impl } @Override - public void invalidateNow() { + public synchronized void invalidateNow() { // similar code in Restful Objects viewer (UserResourceServerside#logout) // this needs to be done here because Wicket will expire the HTTP session @@ -105,7 +104,7 @@ public class AuthenticatedWebSessionForIsis extends AuthenticatedWebSession impl } @Override - public void onInvalidate() { + public synchronized void onInvalidate() { super.onInvalidate(); SessionLoggingService.CausedBy causedBy = RequestCycle.get() != null @@ -120,12 +119,12 @@ public class AuthenticatedWebSessionForIsis extends AuthenticatedWebSession impl log(SessionLoggingService.Type.LOGOUT, userName, causedBy); } - public AuthenticationSession getAuthenticationSession() { + public synchronized AuthenticationSession getAuthenticationSession() { return authenticationSession; } @Override - public Roles getRoles() { + public synchronized Roles getRoles() { if (!isSignedIn()) { return null; } @@ -134,7 +133,7 @@ public class AuthenticatedWebSessionForIsis extends AuthenticatedWebSession impl } @Override - public void detach() { + public synchronized void detach() { breadcrumbModel.detach(); super.detach(); } @@ -195,7 +194,7 @@ public class AuthenticatedWebSessionForIsis extends AuthenticatedWebSession impl } @Override - public void replaceSession() { + public synchronized void replaceSession() { // do nothing here because this will lead to problems with Shiro // see https://issues.apache.org/jira/browse/ISIS-1018 }
