|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.xmlserv.security.SecurityManager | +--com.xmlserv.security.RoleSecurityManager
A role based SecurityManager.
This class does not define where to store user information. A subclass should implement
the abtract methods through which user information is read.
It fills the framework outlined in SecurityManager, but relies on subclasses
to provide access to a storage method (LDAP, RDBMS, filebased, ...).
Inner classes inherited from class com.xmlserv.security.SecurityManager |
SecurityManager.AccessRight, SecurityManager.Authorization, SecurityManager.Resource, SecurityManager.Role, SecurityManager.User |
Fields inherited from class com.xmlserv.security.SecurityManager |
DELETE, INSERT, SELECT, UPDATE |
Constructor Summary | |
RoleSecurityManager()
Create empty object. init() must be called before it is usable. |
Method Summary | |
SecurityManager.User |
authenticate(java.lang.String username,
java.lang.String password)
Authenticate a user. |
SecurityManager.Authorization |
authorize(SecurityManager.User user,
SecurityManager.Resource resource,
java.lang.String access)
Authorize an access method on a resource. |
protected abstract void |
checkAuth(SecurityManager.User user,
SecurityManager.Resource resource,
java.lang.String access)
This method must be implemented in a subclass for each storage type supported. |
protected abstract java.lang.String |
checkUser(java.lang.String user,
java.lang.String password)
This method must be implemented for each storage type supported. |
void |
destroy()
Free resources. |
java.lang.String |
doLogin(javax.servlet.ServletContext context,
javax.servlet.http.HttpServletRequest req)
Handle login. |
protected java.lang.String |
errorPage(java.lang.String msg)
Create am HTML error page. |
protected abstract java.lang.String |
getEmail(java.lang.String username)
Return the users email address. |
protected abstract int |
getId(java.lang.String username)
Return the users numeric id. |
protected abstract java.lang.String |
getRoleGroup(java.lang.String username)
Get the RoleGroup the given user belongs to. |
protected abstract int |
getRoleGroupId(java.lang.String username)
Get the numerical RoleGroup id the given user belongs to. |
java.lang.String |
getUser(javax.servlet.http.HttpServletRequest req)
Return the uid of the authenticated user. |
SecurityManager.User |
getUserObj(javax.servlet.http.HttpServletRequest req)
Return the SecurityManager.User object of the authenticated user. |
java.lang.String |
getUserRoleGroup(javax.servlet.http.HttpServletRequest req)
Get the RoleGroup for the logged in user. |
int |
getUserRoleGroupId(javax.servlet.http.HttpServletRequest req)
Get numeric RoleGroup ID. |
void |
init()
Initialize object. |
protected java.lang.String |
loginPage(java.lang.String target,
javax.servlet.http.HttpServletRequest req)
Create a login page pointing to the given target. |
protected java.lang.String |
loginPage(java.lang.String target,
javax.servlet.http.HttpServletRequest req,
java.lang.String status)
Create an HTML login page with a status message. |
void |
logout(javax.servlet.http.HttpServletRequest req)
Remove login information from the session context and invalidate the session. |
void |
signout(SecurityManager.Authorization authorization)
Remove login information from the session context. |
boolean |
validate(SecurityManager.Authorization authorization)
Check whether this Authorization object was actually created by this SecurityManager and is still valid. |
boolean |
validate(SecurityManager.User userobj)
Check whether this User object was actually created by this SecurityManager. |
Methods inherited from class com.xmlserv.security.SecurityManager |
addACL, getResource, getUserById, getUserID, getUserStatus, hasAuth, isAnon, toUserStatus |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RoleSecurityManager()
Method Detail |
public void init() throws SecurityManagerException
init
in class SecurityManager
public void destroy()
destroy
in class SecurityManager
public java.lang.String doLogin(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest req)
doLogin
in class SecurityManager
context
- The servlet context.req
- The client request.public SecurityManager.User authenticate(java.lang.String username, java.lang.String password) throws SecurityManagerException
authenticate
in class SecurityManager
username
- The username.password
- The password.SecurityManagerException
- If the account is invalid.protected abstract int getRoleGroupId(java.lang.String username) throws SecurityManagerException
protected abstract java.lang.String getRoleGroup(java.lang.String username) throws SecurityManagerException
protected abstract java.lang.String checkUser(java.lang.String user, java.lang.String password) throws SecurityManagerException
user
- The username. Must be lowercasepassword
- The password.SecurityManagerException
- Thrown if the given useraccount is not valid.protected abstract java.lang.String getEmail(java.lang.String username) throws SecurityManagerException
username
- The username to search for.protected abstract int getId(java.lang.String username) throws SecurityManagerException
username
- The username to search for.public SecurityManager.Authorization authorize(SecurityManager.User user, SecurityManager.Resource resource, java.lang.String access) throws SecurityManagerException
authorize
in class SecurityManager
user
- The SecurityManager.User object.resource
- The named resource.access
- The access method string as defined in SecurityManager.SecurityManagerException
- Thrown if the given useraccount is not valid.protected abstract void checkAuth(SecurityManager.User user, SecurityManager.Resource resource, java.lang.String access) throws SecurityManagerException
user
- The SecurityManager.User object.resource
- The named resource.access
- The access method string as defined in SecurityManager.SecurityManagerException
- Thrown if the requested authorization
is not granted.public boolean validate(SecurityManager.User userobj)
validate
in class SecurityManager
userobj
- The SecurityManager.User object to check.public boolean validate(SecurityManager.Authorization authorization)
validate
in class SecurityManager
authorization
- The SecurityManager.Authorization object to test.public java.lang.String getUser(javax.servlet.http.HttpServletRequest req) throws SecurityManagerException
getUser
in class SecurityManager
req
- The client request.SecurityManagerException
- In case the user is not authenticated.public SecurityManager.User getUserObj(javax.servlet.http.HttpServletRequest req) throws SecurityManagerException
getUserObj
in class SecurityManager
req
- The client request.SecurityManagerException
- In case the user is not authenticated.public java.lang.String getUserRoleGroup(javax.servlet.http.HttpServletRequest req) throws SecurityManagerException
getUserRoleGroup
in class SecurityManager
public int getUserRoleGroupId(javax.servlet.http.HttpServletRequest req) throws SecurityManagerException
getUserRoleGroupId
in class SecurityManager
public void signout(SecurityManager.Authorization authorization)
signout
in class SecurityManager
authorization
- The authorization object to invalidate.public void logout(javax.servlet.http.HttpServletRequest req)
logout
in class SecurityManager
req
- The client request.protected java.lang.String errorPage(java.lang.String msg)
msg
- The error message.protected java.lang.String loginPage(java.lang.String target, javax.servlet.http.HttpServletRequest req)
target
- The target to use as the action of the login page.req
- The client request.protected java.lang.String loginPage(java.lang.String target, javax.servlet.http.HttpServletRequest req, java.lang.String status)
target
- The target to use as the action of the login page.req
- The client request.status
- The status strign to include.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |