You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jd...@apache.org on 2010/12/28 12:25:31 UTC

svn commit: r1053310 - in /wicket/trunk: wicket-auth-roles/src/main/java/org/apache/wicket/authentication/ wicket-examples/src/main/java/org/apache/wicket/examples/authentication3/

Author: jdonnerstag
Date: Tue Dec 28 11:25:31 2010
New Revision: 1053310

URL: http://svn.apache.org/viewvc?rev=1053310&view=rev
Log:
WICKET-2971 fixed Refactor AuthenticatedWebSession class, introduce DefaultAuthenticatedWebSession class

Added:
    wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authentication/AbstractAuthenticatedWebSession.java
Modified:
    wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authentication/AuthenticatedWebApplication.java
    wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authentication/AuthenticatedWebSession.java
    wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/authentication3/MyAuthenticatedWebApplication.java

Added: wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authentication/AbstractAuthenticatedWebSession.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authentication/AbstractAuthenticatedWebSession.java?rev=1053310&view=auto
==============================================================================
--- wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authentication/AbstractAuthenticatedWebSession.java (added)
+++ wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authentication/AbstractAuthenticatedWebSession.java Tue Dec 28 11:25:31 2010
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.authentication;
+
+import org.apache.wicket.Session;
+import org.apache.wicket.authorization.strategies.role.Roles;
+import org.apache.wicket.protocol.http.WebSession;
+import org.apache.wicket.request.Request;
+
+
+/**
+ * Authenticated web session. Subclasses must provide a method that gets a User object, a method
+ * that gets User authentication status and a method that returns the Roles for current User.
+ * 
+ * @author Jonathan Locke
+ * @author Leonid Bogdanov
+ */
+public abstract class AbstractAuthenticatedWebSession extends WebSession
+{
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * @return Current authenticated web session
+	 */
+	public static AbstractAuthenticatedWebSession get()
+	{
+		return (AbstractAuthenticatedWebSession)Session.get();
+	}
+
+	/**
+	 * Construct.
+	 * 
+	 * @param request
+	 *            The current request object
+	 */
+	public AbstractAuthenticatedWebSession(final Request request)
+	{
+		super(request);
+	}
+
+	/**
+	 * @return Get the roles that this session can play
+	 */
+	public abstract Roles getRoles();
+
+	/**
+	 * @return True if the user is signed in to this session
+	 */
+	public abstract boolean isSignedIn();
+}

Modified: wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authentication/AuthenticatedWebApplication.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authentication/AuthenticatedWebApplication.java?rev=1053310&r1=1053309&r2=1053310&view=diff
==============================================================================
--- wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authentication/AuthenticatedWebApplication.java (original)
+++ wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authentication/AuthenticatedWebApplication.java Tue Dec 28 11:25:31 2010
@@ -45,7 +45,7 @@ public abstract class AuthenticatedWebAp
 		IUnauthorizedComponentInstantiationListener
 {
 	/** Subclass of authenticated web session to instantiate */
-	private final WeakReference<Class<? extends AuthenticatedWebSession>> webSessionClassRef;
+	private final WeakReference<Class<? extends AbstractAuthenticatedWebSession>> webSessionClassRef;
 
 	/**
 	 * Constructor
@@ -53,7 +53,7 @@ public abstract class AuthenticatedWebAp
 	public AuthenticatedWebApplication()
 	{
 		// Get web session class to instantiate
-		webSessionClassRef = new WeakReference<Class<? extends AuthenticatedWebSession>>(
+		webSessionClassRef = new WeakReference<Class<? extends AbstractAuthenticatedWebSession>>(
 			getWebSessionClass());
 	}
 
@@ -117,8 +117,7 @@ public abstract class AuthenticatedWebAp
 	}
 
 	/**
-	 * @see org.apache.wicket.protocol.http.WebApplication#newSession(org.apache.wicket.request.Request,
-	 *      org.apache.wicket.request.Response)
+	 * {@inheritDoc}
 	 */
 	@Override
 	public Session newSession(final Request request, final Response response)
@@ -137,9 +136,9 @@ public abstract class AuthenticatedWebAp
 	}
 
 	/**
-	 * @return AuthenticatedWebSession subclass to use in this authenticated web application.
+	 * @return BaseAuthenticatedWebSession subclass to use in this authenticated web application.
 	 */
-	protected abstract Class<? extends AuthenticatedWebSession> getWebSessionClass();
+	protected abstract Class<? extends AbstractAuthenticatedWebSession> getWebSessionClass();
 
 	/**
 	 * @return Subclass of sign-in page

Modified: wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authentication/AuthenticatedWebSession.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authentication/AuthenticatedWebSession.java?rev=1053310&r1=1053309&r2=1053310&view=diff
==============================================================================
--- wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authentication/AuthenticatedWebSession.java (original)
+++ wicket/trunk/wicket-auth-roles/src/main/java/org/apache/wicket/authentication/AuthenticatedWebSession.java Tue Dec 28 11:25:31 2010
@@ -18,7 +18,6 @@ package org.apache.wicket.authentication
 
 import org.apache.wicket.Session;
 import org.apache.wicket.authorization.strategies.role.Roles;
-import org.apache.wicket.protocol.http.WebSession;
 import org.apache.wicket.request.Request;
 
 
@@ -28,7 +27,7 @@ import org.apache.wicket.request.Request
  * 
  * @author Jonathan Locke
  */
-public abstract class AuthenticatedWebSession extends WebSession
+public abstract class AuthenticatedWebSession extends AbstractAuthenticatedWebSession
 {
 	private static final long serialVersionUID = 1L;
 
@@ -55,8 +54,9 @@ public abstract class AuthenticatedWebSe
 	}
 
 	/**
-	 * @return Get the roles that this session can play
+	 * {@inheritDoc}
 	 */
+	@Override
 	public abstract Roles getRoles();
 
 	/**
@@ -92,6 +92,7 @@ public abstract class AuthenticatedWebSe
 	/**
 	 * @return true, if user is signed in
 	 */
+	@Override
 	public final boolean isSignedIn()
 	{
 		return signedIn;
@@ -108,8 +109,6 @@ public abstract class AuthenticatedWebSe
 	/**
 	 * Call signOut() and remove the logon data from where ever they have been persisted (e.g.
 	 * Cookies)
-	 * 
-	 * @see org.apache.wicket.Session#invalidate()
 	 */
 	@Override
 	public void invalidate()

Modified: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/authentication3/MyAuthenticatedWebApplication.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/authentication3/MyAuthenticatedWebApplication.java?rev=1053310&r1=1053309&r2=1053310&view=diff
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/authentication3/MyAuthenticatedWebApplication.java (original)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/authentication3/MyAuthenticatedWebApplication.java Tue Dec 28 11:25:31 2010
@@ -18,7 +18,7 @@ package org.apache.wicket.examples.authe
 
 import org.apache.wicket.Page;
 import org.apache.wicket.authentication.AuthenticatedWebApplication;
-import org.apache.wicket.authentication.AuthenticatedWebSession;
+import org.apache.wicket.authentication.AbstractAuthenticatedWebSession;
 import org.apache.wicket.markup.html.WebPage;
 
 
@@ -42,7 +42,7 @@ public class MyAuthenticatedWebApplicati
 	 * @see org.apache.wicket.authentication.AuthenticatedWebApplication#getWebSessionClass()
 	 */
 	@Override
-	protected Class<? extends AuthenticatedWebSession> getWebSessionClass()
+	protected Class<? extends AbstractAuthenticatedWebSession> getWebSessionClass()
 	{
 		return MyAuthenticatedWebSession.class;
 	}