|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jalios.jcms.authentication.AuthenticationHandler
com.jalios.jcms.authentication.handlers.HttpDigestAuthenticationHandler
public class HttpDigestAuthenticationHandler
Authenticates user using HTTP Authorization.
In order to use this handler YOU MUST perform the following operation :
Member mbr = ...;
Member updated = (Member) mbr.getUpdateInstance();
updated.setExtraDataMap(Util.getHashMap(mbr.getExtraDataMap()));
HttpDigestAuthenticationHandler.putHA1InMemberExtraData(updated, "MyRealm", "The member's clear text password");
updated.performUpdate(admin);
Note : building the HA1 requires the clear text password of the user but the password is NOT saved (see explanation below).
setHttpDigestAuthorizationHeader(HttpSession, HttpServletResponse, String).<%@ include file="/jcore/doInitPage.jsp" %><%
%><%@ page import="com.jalios.jcms.authentication.handlers.HttpDigestAuthenticationHandler" %><%
if (loggedMember == null) {
HttpDigestAuthenticationHandler.setHttpDigestAuthorizationHeader(session, response, "MyRealm");
return;
}
%>
HA1 explanation: : HTTP Digest authentication requires either
the password in clear text form (we definitely do not want that)
or the hash HA1 (md5(user:realm:clear-text-password)) on the server side.
That's why the HA1 MUST be saved from the clear text password of the Member
when it's available (for example using a DataController when editing its profile).
| Field Summary | |
|---|---|
static int |
ORDER_DIGEST_HTTP_HANDLER
Order used by the HttpDigestAuthenticationHandler |
static String |
REVISION
|
| Fields inherited from class com.jalios.jcms.authentication.AuthenticationHandler |
|---|
channel, GENERIC_BAD_AUTHENTICATION_MSG |
| Method Summary | |
|---|---|
static Member |
checkAuthenticationFromHTTPAuthorization(javax.servlet.http.HttpServletRequest request)
Returns the member corresponding to the HTTP Authorization header available in the request. |
static String |
getDefaultRealm()
Retrieve the default REALM used for HTTP Digest authentication. |
static String |
getExtraDataKey(String realm)
Retrieve the ExtraData key used to store the HASH HA1 for the specified realm |
static String |
getHA1(Member member,
String realm,
String clearTextPassword)
Compute and retrieve the HASH key HA1 for the specified parameters |
static String |
getHA1FromMemberExtraData(Member member,
String realm)
Retrieve the previously stored HASH key HA1 frm the member's ExtraData (or ExtraDBData for DBMember) |
static String |
getHA2(javax.servlet.http.HttpServletRequest request)
Compute and retrieve the HASH key HA2 for the specified request |
static HttpDigestAuthenticationHandler |
getInstance()
|
void |
loadProperties()
This method will be called by the AuthenticationManager each time the Channel properties are loaded/reloaded. You can use it to reload properties that might have been changed. This method is called during initialization of the AuthenticationManager |
void |
login(AuthenticationContext ctxt)
Authenticate a member. |
static void |
putHA1InMemberExtraData(Member member,
String realm,
String clearTextPassword)
Compute and add the HASH key HA1 in the member's ExtraData (or ExtraDBData for DBMember) |
static String |
removeSurroundingQuote(String str)
|
static void |
setHttpDigestAuthorizationHeader(javax.servlet.http.HttpSession session,
javax.servlet.http.HttpServletResponse response,
String realm)
Set a 401 status code (UNAUTHORIZED) and add the "WWW-Authenticate" header to the given response using the given realm. |
| Methods inherited from class com.jalios.jcms.authentication.AuthenticationHandler |
|---|
compareTo, equals, getOrder, init, logout, setOrder |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String REVISION
public static final int ORDER_DIGEST_HTTP_HANDLER
| Method Detail |
|---|
public static final HttpDigestAuthenticationHandler getInstance()
public void loadProperties()
AuthenticationHandler
loadProperties in class AuthenticationHandler
public void login(AuthenticationContext ctxt)
throws IOException
AuthenticationHandlerAuthenticationContext object (request, response, login.. etc) AuthenticationContext.setLoggedMember(com.jalios.jcms.Member)AuthenticationContext.doChain(),AuthenticationContext.
login in class AuthenticationHandlerctxt - the AuthenticationContext used for this login
IOException
public static final Member checkAuthenticationFromHTTPAuthorization(javax.servlet.http.HttpServletRequest request)
throws IOException
request - the request where to look for HTTP Authorization header
IOException - if the underneath login operation with the userId/password could not be performedpublic static String removeSurroundingQuote(String str)
public static final void setHttpDigestAuthorizationHeader(javax.servlet.http.HttpSession session,
javax.servlet.http.HttpServletResponse response,
String realm)
session - the current session being used for authenticationresponse - the HttpServletResponse of which to set status and add headerrealm - the Realm to set in the response
public static String getHA1(Member member,
String realm,
String clearTextPassword)
member - the member for which the HASH is generatedrealm - the HASH realmclearTextPassword - the member's clear text password
public static void putHA1InMemberExtraData(Member member,
String realm,
String clearTextPassword)
member - the member for which hash is setrealm - the HASH realmclearTextPassword - the clear text password of the user, REQUIRED
public static String getHA1FromMemberExtraData(Member member,
String realm)
member - the member for which hash is retrievedrealm - the HASH realm
public static String getExtraDataKey(String realm)
realm - the realm
public static String getHA2(javax.servlet.http.HttpServletRequest request)
request - the HttpServletRequest for which the HA2 is being generated
public static String getDefaultRealm()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||