|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.arsdigita.kernel.security.UserContext
Provides methods for logging in and logging out the current user and accessing the user ID.
| Field Summary | |
static String |
REGISTER_LOGIN_CONTEXT
Name of the register login context. |
static String |
REQUEST_LOGIN_CONTEXT
Name of the per-request login context. |
static String |
RETURN_URL_PARAM_NAME
Deprecated. Use com.arsdigita.ui.login.LoginHelper.RETURN_URL_PARAM_NAME instead |
static String |
versionId
|
| Constructor Summary | |
UserContext(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Creates a user context from an HTTP request. |
|
| Method Summary | |
static String |
encodeReturnURL(javax.servlet.http.HttpServletRequest req)
Deprecated. This should be moved to a more appropriate class. |
SessionContext |
getSessionContext()
Returns the SessionContext associated with this UserContext. |
User |
getUser()
Returns a User object for the current user. |
BigDecimal |
getUserID()
Returns the current user's ID. |
boolean |
isLoggedIn()
Determines whether the user is logged in. |
boolean |
isRecovering()
Determines whether the user is recovering a forgotten password. |
void |
login(BigDecimal userID)
Logs in as the User with the given user ID. |
void |
login(String username)
Logs in as the User with the given username. |
void |
login(String username,
char[] password,
boolean forever)
Logs in the user. |
void |
login(User target)
Logs in as the given User. |
void |
logout()
Logs out the user. |
static void |
redirectToLoginPage(javax.servlet.http.HttpServletRequest req)
Creates a URL to send the user to the login page and then return to the current page. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String versionId
public static final String REQUEST_LOGIN_CONTEXT
public static final String REGISTER_LOGIN_CONTEXT
public static final String RETURN_URL_PARAM_NAME
| Constructor Detail |
public UserContext(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws RedirectException
KernelHelper.getKernelRequestContext(req).getUserContext().
RedirectException - if the user should be redirected to the
login page.| Method Detail |
public void login(String username)
throws javax.security.auth.login.LoginException
username - the username of the target User
AccountNotFoundException - if the target user does not exist.
javax.security.auth.login.LoginException - if login(User) fails.
public void login(BigDecimal userID)
throws javax.security.auth.login.LoginException
userID - the ID of the target User
AccountNotFoundException - if the target user does not exist.
javax.security.auth.login.LoginException - if login(User) fails.
public void login(User target)
throws javax.security.auth.login.LoginException
target - the User to become
javax.security.auth.login.FailedLoginException - if the current user is not logged in,
doesn't exist, or doesn't have admin privileges on the target user.
javax.security.auth.login.LoginException - if an error occurs.public SessionContext getSessionContext()
public boolean isLoggedIn()
true if the user is logged in,
false otherwise.public boolean isRecovering()
true if the user is recovering,
false otherwise.public BigDecimal getUserID()
IllegalStateException - if the user is not logged in.public User getUser()
logout method is called.
IllegalStateException - if the user is not logged in.public static void redirectToLoginPage(javax.servlet.http.HttpServletRequest req)
LoginSignalpublic static String encodeReturnURL(javax.servlet.http.HttpServletRequest req)
URLencode(returnURL) where returnURL is
returnURI?key=URLencode(val)&.... The original
parameter values are doubly-encoded so that they are decoded
appropriately.
req - the request to encode
public void login(String username,
char[] password,
boolean forever)
throws javax.security.auth.login.LoginException
SessionContext.
username - the user's usernamepassword - the user's passwordforever - true if the user requests permanent login
javax.security.auth.login.LoginException - if login fails.
public void logout()
throws javax.security.auth.login.LoginException
SessionContext.
javax.security.auth.login.LoginException - if logout fails.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||