public class AuthKeyAuthenticationHandler extends AuthenticationHandler
The Authentication key parameter name can be configured by changing
property "auth-mgr.authkey-name"
, see getAuthKeyName()
.
Default duration of AuthenticationKey can be configured by changing
property "auth-mgr.authkey-duration"
, see getDefaultAuthKeyDuration()
.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AUTHENTICATION_FROM_AUTHKEY
Name of request attribute indicating that this request was authenticated using AuthKey
|
static int |
ORDER_AUTHKEY_HANDLER
Order used by the AuthKeyAuthenticationHandler
|
static java.lang.String |
REVISION |
channel, GENERIC_BAD_AUTHENTICATION_MSG
Modifier and Type | Method and Description |
---|---|
static Member |
checkAuthenticationFromAuthKey(javax.servlet.http.HttpServletRequest request)
Returns the member corresponding to the credentials given in the authkey parameter, if any.
|
static java.lang.String |
getAuthKeyName()
Retrieves the authentication key parameter name.
|
static java.lang.String |
getAuthKeyServerSeed()
Retrieves the server seed used in auth key digest.
|
static java.lang.String |
getAuthKeyValue(java.lang.String url,
Member member)
Retrieves a valid authentication key parameter value for the specified URL.
|
static java.lang.String |
getAuthKeyValue(java.lang.String url,
Member member,
AuthKeyHints hints)
Retrieves a valid authentication key parameter value for the specified URL.
|
static java.lang.String |
getAuthKeyValue(java.lang.String url,
Member member,
long duration)
Retrieves a valid authentication key parameter value for the specified URL.
|
static long |
getDefaultAuthKeyDuration()
Retrieves the default authentication key duration (expiration time) to
be used when no expiration duration as been specified.
|
static AuthKeyAuthenticationHandler |
getInstance() |
static java.lang.String |
getUrlWithAddedAuthKeyParam(javax.servlet.http.HttpServletRequest request,
Member member)
Retrieve the absolute url of the specified request with a valid authentication key parameter name/value appended.
|
static java.lang.String |
getUrlWithAddedAuthKeyParam(javax.servlet.http.HttpServletRequest request,
Member member,
long duration)
Retrieve the absolute url of the specified request with a valid authentication key parameter name/value appended.
|
static java.lang.String |
getUrlWithAddedAuthKeyParam(java.lang.String url,
Member member)
Append a valid authentication key parameter name/value to the specified URL.
|
static java.lang.String |
getUrlWithAddedAuthKeyParam(java.lang.String url,
Member member,
AuthKeyHints hints,
boolean escapeAmpersand)
Append a valid authentication key parameter name/value to the specified URL.
|
static java.lang.String |
getUrlWithAddedAuthKeyParam(java.lang.String url,
Member member,
long duration)
Append a valid authentication key parameter name/value to the specified URL.
|
static java.lang.String |
getUrlWithAddedAuthKeyParam(java.lang.String url,
Member member,
long duration,
boolean escapeAmpersand)
Append a valid authentication key parameter name/value to the specified URL.
|
static boolean |
isAuthenticatedWithAuthKey(javax.servlet.http.HttpServletRequest request)
Check if the specified request was authenticated using an AuthKey
|
static Member |
isValidAuthKey(java.lang.String url,
java.lang.String authKey,
javax.servlet.http.HttpServletRequest request)
Checks if the given auth key is valid and if it is, returns the member to login.
|
void |
loadProperties()
This method will be called by the AuthenticationManager each time the
Channel properties are loaded/reloaded.
|
void |
login(AuthenticationContext ctxt)
Authenticate a member.
|
public static final java.lang.String REVISION
public static final java.lang.String AUTHENTICATION_FROM_AUTHKEY
isAuthenticatedWithAuthKey(HttpServletRequest)
,
Constant Field Valuespublic static final int ORDER_AUTHKEY_HANDLER
public static final AuthKeyAuthenticationHandler getInstance()
public void loadProperties()
AuthenticationHandler
loadProperties
in class AuthenticationHandler
public void login(AuthenticationContext ctxt) throws java.io.IOException
AuthenticationHandler
AuthenticationContext
object (request, response, login.. etc) AuthenticationContext.setLoggedMember(com.jalios.jcms.Member)
AuthenticationContext.doChain()
,AuthenticationContext
.login
in class AuthenticationHandler
ctxt
- the AuthenticationContext
used for this loginjava.io.IOException
public static boolean isAuthenticatedWithAuthKey(javax.servlet.http.HttpServletRequest request)
request
- the current HttpServletRequest, may be nullpublic static final Member checkAuthenticationFromAuthKey(javax.servlet.http.HttpServletRequest request)
request
- the request where to look for authkey parampublic static final java.lang.String getUrlWithAddedAuthKeyParam(javax.servlet.http.HttpServletRequest request, Member member)
If the specified member is null, the url of the request is returned.
If there are existing parameter(s) to the specified request, the html entity & will be used for the ampersand required to append the parameter.
request
- the request for which an authentication key will be computedmember
- the member that will be allowed to access the resource of the specified urljava.lang.IllegalArgumentException
- if request is nullpublic static final java.lang.String getUrlWithAddedAuthKeyParam(javax.servlet.http.HttpServletRequest request, Member member, long duration)
If the specified member is null, the url of the request is returned.
If there are existing parameter(s) to the specified request, the html entity & will be used for the ampersand required to append the parameter.
request
- the request for which an authentication key will be computedmember
- the member that will be allowed to access the resource of the specified urlduration
- a duration (in millisecond) after which the returned authkey will be expired (no longer valid).
If set to 0, no expiration is used, if set to -1 (or any negative number) default expiration time is used.java.lang.IllegalArgumentException
- if request is nullpublic static final java.lang.String getUrlWithAddedAuthKeyParam(java.lang.String url, Member member)
If the specified member is null, the url is returned untouched.
If there are existing parameter(s) to the specified url, the html entity & will be used for the ampersand required to append the parameter.
url
- the absolute URL for which an authentication key will be computedmember
- the member that will be allowed to access the resource of the specified urljava.lang.IllegalArgumentException
- if url is nullpublic static final java.lang.String getUrlWithAddedAuthKeyParam(java.lang.String url, Member member, long duration)
If the specified member is null, the url is returned untouched.
If there are existing parameter(s) to the specified url, the html entity & will be used for the ampersand required to append the parameter.
url
- the absolute URL for which an authentication key will be computedmember
- the member that will be allowed to access the resource of the specified urlduration
- a duration (in millisecond) after which the returned authkey will be expired (no longer valid).
If set to 0, no expiration is used, if set to -1 (or any negative number) default expiration time is used.java.lang.IllegalArgumentException
- if url is nullpublic static final java.lang.String getUrlWithAddedAuthKeyParam(java.lang.String url, Member member, long duration, boolean escapeAmpersand)
If the specified member is null, the url is returned untouched.
url
- the absolute URL for which an authentication key will be computedmember
- the member that will be allowed to access the resource of the specified urlduration
- a duration (in millisecond) after which the returned authkey will be expired (no longer valid).
If set to 0, no expiration is used, if set to -1 (or any negative number) default expiration time is used.escapeAmpersand
- will use "&" if true, "&" if falsejava.lang.IllegalArgumentException
- if url is nullpublic static final java.lang.String getUrlWithAddedAuthKeyParam(java.lang.String url, Member member, AuthKeyHints hints, boolean escapeAmpersand)
If the specified member is null, the url is returned untouched.
url
- the absolute URL for which an authentication key will be computedmember
- the member that will be allowed to access the resource of the specified urlhints
- the specific parametersescapeAmpersand
- will use "&" if true, "&" if falsejava.lang.IllegalArgumentException
- if url is nullpublic static final long getDefaultAuthKeyDuration()
"auth-mgr.authkey-duration"
.public static final java.lang.String getAuthKeyName()
"authKey"
and can be changed using property "auth-mgr.authkey-name"
.public static final java.lang.String getAuthKeyServerSeed()
""
and can be changed using property "auth-mgr.authkey-server-seed"
.public static final java.lang.String getAuthKeyValue(java.lang.String url, Member member)
url
- the absolute URL for which an authentication key will be computedmember
- the member that will be allowed to access the resource of the specified url, MUST NOT be nulljava.lang.IllegalArgumentException
- if url or member is nullpublic static final java.lang.String getAuthKeyValue(java.lang.String url, Member member, long duration)
url
- the absolute URL for which an authentication key will be computed, MUST NOT be nullmember
- the member that will be allowed to access the resource of the specified url, MUST NOT be nullduration
- a duration (in millisecond) after which the returned authkey will be expired (no longer valid).
If set to 0, no expiration is used, if set to -1 (or any negative number) default expiration time is used.java.lang.IllegalArgumentException
- if url or member is nullpublic static final java.lang.String getAuthKeyValue(java.lang.String url, Member member, AuthKeyHints hints)
url
- the absolute URL for which an authentication key will be computed, MUST NOT be nullmember
- the member that will be allowed to access the resource of the specified url, MUST NOT be nullhints
- additional parameter set in this javabeanjava.lang.IllegalArgumentException
- if url or member is nullpublic static final Member isValidAuthKey(java.lang.String url, java.lang.String authKey, javax.servlet.http.HttpServletRequest request)
url
- the absolute url against which the auth key will be checkedauthKey
- the authentication key to checksrequest
- the current requestCopyright © 2001-2010 Jalios SA. All Rights Reserved.