|
Clearspace API (1.10.16) Core Javadocs | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jivesoftware.base.AuthFactory
public abstract class AuthFactory
An abstract class that defines a framework for providing authentication services in Jive. The static getAuthToken(String, String), getAuthToken(HttpServletRequest, HttpServletResponse), and getAnonymousAuthToken() methods should be called directly from applications using Jive in order to obtain an AuthToken.
Users of Jive that wish to change the AuthFactory implementation used to generate tokens can set theAuthFactory.className Jive property. For example, if you have altered Jive to
use LDAP for user information, you'd want to write a custom implementation of AuthFactory to make
LDAP authToken queries. After changing the AuthFactory.className Jive property, you
must restart your application server.
The getAuthToken method that takes servlet request and response objects as arguments can be used
to implement single sign-on. Additionally, two helper methods are provided for securely
encrypting and decrypting login information so that it can be stored as a cookie value to
implement auto-login.
| Nested Class Summary | |
|---|---|
static class |
AuthFactory.SystemAuthToken
|
| Field Summary | |
|---|---|
static long |
ANONYMOUS_USER_ID
Defines the id used for anonymous users. |
static java.lang.String |
AUTH_PROVIDER_KEY
|
protected static com.jivesoftware.util.EncryptionUtil |
cipher
|
static java.lang.String |
COOKIE_AUTOLOGIN
Name of the cookie used to store user info for auto-login purposes. |
static java.lang.String |
COOKIE_JIVE_SERVER_INFO
Cookie used for things like akamai to tell information about a specific server. |
static java.lang.String |
COOKIE_LOGGED_IN
Cookie used to show that the current user is logged in. |
static java.lang.String |
KEY_AUTO_LOGIN
Name of the user property key used to auto login random key. |
static java.lang.String |
KEY_LAST_LOGGED_IN
Name of the user property key used to store the last logged in date of a user |
static java.lang.String |
SESSION_AUTHORIZATION
Name of the key in a user's session that AuthToken tokens are customarily stored at. |
| Constructor Summary | |
|---|---|
AuthFactory()
|
|
| Method Summary | |
|---|---|
protected void |
addLoginCookie(AuthToken auth,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
protected void |
addServerInfoCookie(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
static void |
checkAuthorization(AuthToken authToken,
javax.servlet.http.HttpServletRequest request)
Checks if the specified AuthToken is authorized. |
protected void |
clearSessionUserInfo(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Concrete subclasses may wish to override this method to destroy session info as appropriate. |
static void |
copyAuthProviderConfigToLDAP()
|
static void |
copyLdapConfigToAuthProvider()
|
protected AuthToken |
createAnonymousAuthToken()
Creates anonymous AuthToken tokens. |
protected AuthToken |
createAuthToken(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Creates AuthToken tokens based on information from servlet request and response objects. |
protected AuthToken |
createAuthToken(java.lang.String username,
java.lang.String password)
Creates AuthToken tokens based on a username. |
protected AuthToken |
createSessionUserInfo(java.lang.String username,
java.lang.String password,
boolean autoLogin,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Concrete subclasses may wish to override this method to create session info as appropriate. |
static java.lang.String[] |
decryptAuthInfo(java.lang.String value)
Utility method that decrypts a String built by the encryptAuthInfo method containing a username and password. |
static void |
destroyAuthFactory()
Method used internally by Jive. |
static java.lang.String |
encryptAuthInfo(java.lang.String username,
java.lang.String password)
Utility method that builds an encrypted String containing a username and password, which is useful for storing as a cookie. |
static void |
forceReload()
|
static AuthToken |
getAnonymousAuthToken()
Returns an anonymous user AuthToken. |
AuthenticationProvider |
getAuthenticationProvider()
|
static AuthToken |
getAuthToken(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Returns the AuthToken token associated with the information in a servlet request and response object. |
static AuthToken |
getAuthToken(java.lang.String username,
java.lang.String password)
Returns the AuthToken token associated with the specified username and password. |
protected static java.lang.String |
getServerInfoCookieProperty(javax.naming.InitialContext ctx,
java.lang.String property,
java.lang.String defaultVal)
This method will see if a property for the jive.server.info cookie is on the initial context under java:comp/env/jive/{myprop} if not found there it will check jive local properties for the property under jive.server.info. |
static AuthToken |
getSessionAuthToken(javax.servlet.http.HttpServletRequest request)
Returns the authToken in the session, if one does not exist an anonymous authToken will be returned. |
static User |
getSessionUser(javax.servlet.http.HttpServletRequest request)
Returns the currently logged in user. |
static AuthToken |
getSystemAuthToken()
|
protected User |
getUser(AuthToken authToken)
|
static AuthToken |
loginUser(java.lang.String username,
java.lang.String password,
boolean autoLogin,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
This method is a method for logging a user in and creating the appropriate session variables and/or cookies to keep state. |
static void |
logoutUser(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
This method is a method for logging a user out and destroying or resetting the appropriate session variables and/or cookies to keep state. |
protected void |
updateLoginTimestamp(AuthToken authToken)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final long ANONYMOUS_USER_ID
public static final java.lang.String SESSION_AUTHORIZATION
public static final java.lang.String COOKIE_AUTOLOGIN
public static final java.lang.String COOKIE_LOGGED_IN
public static final java.lang.String COOKIE_JIVE_SERVER_INFO
public static final java.lang.String KEY_LAST_LOGGED_IN
public static final java.lang.String KEY_AUTO_LOGIN
public static final java.lang.String AUTH_PROVIDER_KEY
protected static com.jivesoftware.util.EncryptionUtil cipher
| Constructor Detail |
|---|
public AuthFactory()
| Method Detail |
|---|
public static AuthToken getAuthToken(java.lang.String username,
java.lang.String password)
throws UnauthorizedException
When using most implementations of this class, authToken tokens should be cached. A convenient place to store a token is often in the HttpSession.
username - the username to create an AuthToken with.password - the password to create an AuthToken with.
UnauthorizedException - if the username and password do not match any existing user.
public static AuthToken getAuthToken(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws UnauthorizedException
request - a HttpServletRequest object.response - a HttpServletResponse object.
UnauthorizedException - if no authToken information is found.public static AuthToken getAnonymousAuthToken()
public static AuthToken getSystemAuthToken()
public static java.lang.String encryptAuthInfo(java.lang.String username,
java.lang.String password)
username - the username to encode.password - the password to encode.
public static java.lang.String[] decryptAuthInfo(java.lang.String value)
throws javax.crypto.IllegalBlockSizeException
value - the encrypted String.
{
null, null } if value equals null or the empty string.
javax.crypto.IllegalBlockSizeException - if a decryption error occurs
protected AuthToken createAuthToken(java.lang.String username,
java.lang.String password)
username - the usernamepassword - the password
UnauthorizedException - if no authToken information is found.
protected AuthToken createAuthToken(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws UnauthorizedException
If this method is not overwriten by a concrete subclass of AuthFactory, then the following default behavior will be used to search for login information:
request - a HttpServletRequest object.response - a HttpServletResponse object.
UnauthorizedException - if no authToken information is found.protected void updateLoginTimestamp(AuthToken authToken)
protected void addLoginCookie(AuthToken auth,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
protected void addServerInfoCookie(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
protected AuthToken createAnonymousAuthToken()
public static AuthToken loginUser(java.lang.String username,
java.lang.String password,
boolean autoLogin,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws UnauthorizedException
username - the username to create an AuthToken with.password - the password to create an AuthToken with.autoLogin - whether autoLogin capability is requested or not.request - a HttpServletRequest object.response - a HttpServletResponse object.
UnauthorizedException - if the username and password do not match any existing user.
protected AuthToken createSessionUserInfo(java.lang.String username,
java.lang.String password,
boolean autoLogin,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws UnauthorizedException
username - the username to create an AuthToken with.password - the password to create an AuthToken with.autoLogin - whether autoLogin capability is requested or not.request - a HttpServletRequest object.response - a HttpServletResponse object.
UnauthorizedException - if the username and password do not match any existing user.
protected User getUser(AuthToken authToken)
throws UserNotFoundException
UserNotFoundException
public static void checkAuthorization(AuthToken authToken,
javax.servlet.http.HttpServletRequest request)
throws UnauthorizedException
authToken - the auth token to checkrequest - the current request
UnauthorizedException - if the auth token is not authorized
public static void logoutUser(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
request - a HttpServletRequest object.response - a HttpServletResponse object.public static AuthToken getSessionAuthToken(javax.servlet.http.HttpServletRequest request)
request - The current servlet request.
public static User getSessionUser(javax.servlet.http.HttpServletRequest request)
request - The request of the user.
protected void clearSessionUserInfo(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
request - a HttpServletRequest object.response - a HttpServletResponse object.public static void destroyAuthFactory()
public AuthenticationProvider getAuthenticationProvider()
public static void copyLdapConfigToAuthProvider()
public static void copyAuthProviderConfigToLDAP()
protected static java.lang.String getServerInfoCookieProperty(javax.naming.InitialContext ctx,
java.lang.String property,
java.lang.String defaultVal)
ctx - used to look up values in the jndi contextproperty - The property to lookupdefaultVal - The default value if no values is found
public static void forceReload()
|
Clearspace Project Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||