litesoft
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package org.litesoft.servlets;
import java.util.*;
import javax.servlet.*;
public abstract class UserAuthenticationService
{
private static UserAuthenticationService sInstance = null;
public static synchronized UserAuthenticationService getInstance( Servlet pServlet )
{
if ( sInstance != null )
{
return sInstance;
}
String zUASclassname = pServlet.getServletConfig().getServletContext().getInitParameter( "UserAuthenticationService" );
if ( zUASclassname != null )
{
try
{
Class<?> zClass = Class.forName( zUASclassname );
Object o = zClass.newInstance();
return sInstance = (UserAuthenticationService) o;
}
catch ( Exception e )
{
throw new Error( "Unacceptable" + getCommonMessage( pServlet ), e );
}
}
throw new Error( "No" + getCommonMessage( pServlet ) );
}
private static String getCommonMessage( Servlet pServlet )
{
return " web.xml servlet context init-param 'UserAuthenticationService': " + pServlet.getClass().getSimpleName();
}
private Map<String, String> mCookieUserMap = new HashMap<String, String>();
private int mNextCookieValue = 12345;
protected UserAuthenticationService()
{
}
public synchronized String getUserForCookie( String pCookieValue )
{
return mCookieUserMap.get( pCookieValue );
}
public synchronized String createCookieForUser( String pUserName )
{
String zCookieValue = "UCV" + (mNextCookieValue++);
mCookieUserMap.put( zCookieValue, pUserName );
return zCookieValue;
}
public abstract boolean isUserValid( String pUserName, String pPassword );
}
|
Revision |
Author |
Commited |
Message |
2
|
GeorgeS
|
Sun 07 Feb, 2010 12:50:58 +0000 |
|