net.databinder.auth
Class AuthDataSessionBase

java.lang.Object
  extended by org.apache.wicket.Session
      extended by org.apache.wicket.protocol.http.WebSession
          extended by net.databinder.auth.AuthDataSessionBase
All Implemented Interfaces:
java.io.Serializable, AuthSession, org.apache.wicket.IClusterable
Direct Known Subclasses:
AuthDataSession, AuthDataSession

public abstract class AuthDataSessionBase
extends org.apache.wicket.protocol.http.WebSession
implements AuthSession

Base class for Databinder implementations providing an implementation for authentication cookies and current user lookup.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.wicket.Session
org.apache.wicket.Session.IPageMapVisitor, org.apache.wicket.Session.PageMapAccessMetaData
 
Field Summary
 
Fields inherited from class org.apache.wicket.Session
PAGEMAP_ACCESS_MDK, SESSION_ATTRIBUTE_NAME
 
Constructor Summary
AuthDataSessionBase(org.apache.wicket.Request request)
          Initialize new session.
 
Method Summary
protected  boolean cookieSignIn()
          Attempts cookie sign in, which will set usename field but not user.
abstract  org.apache.wicket.model.IModel createUserModel(DataUser user)
           
protected  void detach()
          Detach userModel manually, as it isnt' attached to any component.
static AuthDataSessionBase get()
           
protected static AuthApplication getApp()
           
static java.lang.String getAuthCookieName()
           
protected  org.apache.wicket.util.time.Duration getSignInCookieMaxAge()
           
 DataUser getUser()
           
protected  DataUser getUser(java.lang.String username)
          Looks for a persisted DataUser object matching the given username.
static java.lang.String getUserCookieName()
           
 org.apache.wicket.model.IModel getUserModel()
           
 boolean isSignedIn()
          Determine if user is signed in, or can be via cookie.
protected  void setCookie()
          Sets cookie to remember the currently signed-in user.
 void signIn(DataUser user, boolean setCookie)
          Sign in a user whose credentials have been validated elsewhere.
 boolean signIn(java.lang.String username, java.lang.String password)
          Sign in without setting cookie.
 boolean signIn(java.lang.String username, java.lang.String password, boolean setCookie)
           
 void signOut()
          Nullifies userModel and clears authentication cookies.
 
Methods inherited from class org.apache.wicket.protocol.http.WebSession
cleanupFeedbackMessages, isCurrentRequestValid
 
Methods inherited from class org.apache.wicket.Session
attach, bind, clear, createAutoPageMap, createAutoPageMapName, currentCreateAutoPageMapCounter, dirty, error, exists, findOrCreate, findOrCreate, getApplication, getAttribute, getAttributeNames, getAuthorizationStrategy, getAutoPageMapNamePrefix, getAutoPageMapNameSuffix, getClassResolver, getClientInfo, getDefaultPageMap, getFeedbackMessages, getId, getLocale, getMetaData, getPage, getPage, getPageFactory, getPageFactory, getPageMaps, getSessionStore, getSizeInBytes, getStyle, incrementCreateAutoPageMapCounter, info, invalidate, invalidateNow, isSessionInvalidated, isTemporary, newPageMap, nextPageId, nextSequenceValue, pageMapForName, removeAttribute, removePageMap, set, setApplication, setAttribute, setClientInfo, setLocale, setMetaData, setStyle, touch, unset, untouch, update, visitPageMaps, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuthDataSessionBase

public AuthDataSessionBase(org.apache.wicket.Request request)
Initialize new session.

See Also:
WebApplication
Method Detail

getApp

protected static AuthApplication getApp()

get

public static AuthDataSessionBase get()

getUser

public DataUser getUser()
Specified by:
getUser in interface AuthSession
Returns:
DataUser object for current user, or null if none signed in.

getUserModel

public org.apache.wicket.model.IModel getUserModel()
Specified by:
getUserModel in interface AuthSession

createUserModel

public abstract org.apache.wicket.model.IModel createUserModel(DataUser user)
Returns:
model for current user

getSignInCookieMaxAge

protected org.apache.wicket.util.time.Duration getSignInCookieMaxAge()
Returns:
length of time sign-in cookie should persist, defined here as one month

isSignedIn

public boolean isSignedIn()
Determine if user is signed in, or can be via cookie.

Specified by:
isSignedIn in interface AuthSession
Returns:
true if signed in or cookie sign in is possible and successful

signIn

public boolean signIn(java.lang.String username,
                      java.lang.String password)
Description copied from interface: AuthSession
Sign in without setting cookie.

Specified by:
signIn in interface AuthSession
Returns:
true if signed in, false if credentials incorrect

signIn

public boolean signIn(java.lang.String username,
                      java.lang.String password,
                      boolean setCookie)
Specified by:
signIn in interface AuthSession
Parameters:
setCookie - if true, sets cookie to remember user
Returns:
true if signed in, false if credentials incorrect

signIn

public void signIn(DataUser user,
                   boolean setCookie)
Sign in a user whose credentials have been validated elsewhere. The user object must exist, and already have been saved, in the current request's Hibernate session.

Specified by:
signIn in interface AuthSession
Parameters:
user - validated and persisted user, must be in current Hibernate session
setCookie - if true, sets cookie to remember user

cookieSignIn

protected boolean cookieSignIn()
Attempts cookie sign in, which will set usename field but not user.

Returns:
true if signed in, false if credentials incorrect or unavailable

getUser

protected DataUser getUser(java.lang.String username)
Looks for a persisted DataUser object matching the given username. Uses the user class and criteria builder returned from the application subclass implementing AuthApplication.

Parameters:
username -
Returns:
user object from persistent storage
See Also:
AuthApplication

getUserCookieName

public static java.lang.String getUserCookieName()

getAuthCookieName

public static java.lang.String getAuthCookieName()

setCookie

protected void setCookie()
Sets cookie to remember the currently signed-in user. Sets max age to value from getSignInCookieMaxAge().

See Also:
getSignInCookieMaxAge()

detach

protected void detach()
Detach userModel manually, as it isnt' attached to any component.

Overrides:
detach in class org.apache.wicket.Session

signOut

public void signOut()
Nullifies userModel and clears authentication cookies.

Specified by:
signOut in interface AuthSession


Copyright © 2005-2008 Nathan Hamblen. All Rights Reserved.