Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.RuntimeCollective.permission.bean
Class SimplePermissionRule  view SimplePermissionRule download SimplePermissionRule.java

java.lang.Object
  extended bycom.RuntimeCollective.permission.bean.SimplePermissionRule
All Implemented Interfaces:
com.RuntimeCollective.webapps.bean.EntityBean, PermissionRule, java.io.Serializable
Direct Known Subclasses:
UserGroupPermissionRule

public class SimplePermissionRule
extends java.lang.Object
implements PermissionRule

A very simple implementation of PermissionRule. It only uses permission criteria from the Webapps module, that is, for now:
- whether the user has logged in

One can extend this class and adds a Role criterion when we have decided on how we're going to do that Role mechanism.

Version:
$Id: SimplePermissionRule.java,v 1.14 2003/09/30 15:12:49 joe Exp $

Field Summary
static java.lang.String DATABASE_TABLE
          The name of the database table for this bean type.
protected  int id
          This object's id
protected  java.lang.String Key
          The Key identifier
protected  boolean NeedLogin
          Whether the User has to be logged in
 
Fields inherited from interface com.RuntimeCollective.webapps.bean.EntityBean
INTERFACE_BEAN, NULL_ID
 
Constructor Summary
SimplePermissionRule()
          Construct a new blank SimplePermissionRule, giving it a new unique ID.
SimplePermissionRule(int id)
          Get a current SimplePermissionRule from the RuntimeDataSource, given an id.
 
Method Summary
 boolean accepts(com.RuntimeCollective.webapps.bean.User user)
          Checks whether a User is accepted by this PermissionRule.
 void delete()
          Delete this bean from the database.
 java.lang.String getAuthorisationPath(javax.servlet.http.HttpSession session, java.lang.String returnPath)
          Deprecated. This method was modified not to refer to Client Tier classes (HttpSession). Use instead: getAuthorisationPath((User) session.getAttribute(RuntimeParameters.get("logonUserKey")), (Session) session.getAttribute(Session.SESSION_KEY), new HttpSessionReturnPathContainer(session), returnPath)
protected  java.lang.String getAuthorisationPath(com.RuntimeCollective.webapps.bean.User user)
          Get the path of the page where the user should be sent in order to (maybe) get authorised.
 java.lang.String getAuthorisationPath(com.RuntimeCollective.webapps.bean.User user, com.RuntimeCollective.webapps.bean.Session session, com.RuntimeCollective.webapps.ReturnPathContainer rpContainer, java.lang.String returnPath)
          Get the path of the page where a User should be sent in order to (maybe) get authorised.
 int getId()
          Get the unique id of this bean instance.
 java.lang.String getKey()
          Get the key, which will be an identifier of what kind of PermissionRule this one is.
 boolean getNeedLogin()
          Get whether the User has to be logged in
protected static java.lang.String getPathToLogon()
          Get the path to the logon page.
protected static java.lang.String getPathToRelogon()
          Get the path to the logon-again page.
 void save()
          Save this bean to the database.
 void setId(int id)
          Set the unique id of this bean instance.
 void setKey(java.lang.String key)
          Set the key, which will be an identifier of what kind of PermissionRule this one is.
 void setNeedLogin(boolean needLogin)
          Set whether the User has to be logged in
protected static void setReturnUrl(javax.servlet.http.HttpSession session, java.lang.String returnPath)
          Deprecated. This method was modified not to refer to Client Tier classes (HttpSession). Use instead: setReturnUrl((ReturnPathContainer) new HttpSessionReturnPathContainer(session), returnPath)
protected static void setReturnUrl(com.RuntimeCollective.webapps.ReturnPathContainer rpContainer, java.lang.String returnPath)
          Set the return url in the session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATABASE_TABLE

public static final java.lang.String DATABASE_TABLE
The name of the database table for this bean type.

See Also:
Constant Field Values

id

protected int id
This object's id


Key

protected java.lang.String Key
The Key identifier


NeedLogin

protected boolean NeedLogin
Whether the User has to be logged in

Constructor Detail

SimplePermissionRule

public SimplePermissionRule()
Construct a new blank SimplePermissionRule, giving it a new unique ID.


SimplePermissionRule

public SimplePermissionRule(int id)
Get a current SimplePermissionRule from the RuntimeDataSource, given an id.

Method Detail

setId

public void setId(int id)
Set the unique id of this bean instance.

Specified by:
setId in interface PermissionRule

getId

public int getId()
Get the unique id of this bean instance.

Specified by:
getId in interface PermissionRule

save

public void save()
Save this bean to the database.

Specified by:
save in interface PermissionRule

delete

public void delete()
Delete this bean from the database.

Specified by:
delete in interface PermissionRule

setKey

public void setKey(java.lang.String key)
Set the key, which will be an identifier of what kind of PermissionRule this one is. This is particularly intended for when a User has to choose one of many PermissionRule prototype in a checkbox list. Thanks to this key, we can later recognise which one he chose, and let him chose a different one. This can be kept to null if judged not necessary.

Specified by:
setKey in interface PermissionRule

getKey

public java.lang.String getKey()
Get the key, which will be an identifier of what kind of PermissionRule this one is.

Specified by:
getKey in interface PermissionRule

accepts

public boolean accepts(com.RuntimeCollective.webapps.bean.User user)
Checks whether a User is accepted by this PermissionRule.

Override this method in subclasses, to add further permission criteria.

Specified by:
accepts in interface PermissionRule

getAuthorisationPath

protected java.lang.String getAuthorisationPath(com.RuntimeCollective.webapps.bean.User user)
Get the path of the page where the user should be sent in order to (maybe) get authorised.

On submission of that page, the user should be checked again, as there may be more than one page to go to.

Override this method in subclasses, to redirect the user to more relevent places depending on why he was not accepted.


getAuthorisationPath

public java.lang.String getAuthorisationPath(javax.servlet.http.HttpSession session,
                                             java.lang.String returnPath)
Deprecated. This method was modified not to refer to Client Tier classes (HttpSession). Use instead: getAuthorisationPath((User) session.getAttribute(RuntimeParameters.get("logonUserKey")), (Session) session.getAttribute(Session.SESSION_KEY), new HttpSessionReturnPathContainer(session), returnPath)

Get the path of the page where the session should be sent in order to (maybe) get authorised. Also sets required attributes in the Session.

On submission of that page, the session should be checked again, as there may be more than one page to go to.

This method should not be overridden, override getAuthorisationPath(User) instead.

Specified by:
getAuthorisationPath in interface PermissionRule

getAuthorisationPath

public java.lang.String getAuthorisationPath(com.RuntimeCollective.webapps.bean.User user,
                                             com.RuntimeCollective.webapps.bean.Session session,
                                             com.RuntimeCollective.webapps.ReturnPathContainer rpContainer,
                                             java.lang.String returnPath)
Get the path of the page where a User should be sent in order to (maybe) get authorised.

On submission of that resulting page, the user should be checked again, as there may be more than one page to go to before he/she is authorised.

The session parameter is only checked/verified (not null, not timed out, correct user) if the permissionRuleChecksSession parameter is set to true in web.xml, for backwards compatibility.

Specified by:
getAuthorisationPath in interface PermissionRule

setNeedLogin

public void setNeedLogin(boolean needLogin)
Set whether the User has to be logged in


getNeedLogin

public boolean getNeedLogin()
Get whether the User has to be logged in


getPathToLogon

protected static java.lang.String getPathToLogon()
Get the path to the logon page.


getPathToRelogon

protected static java.lang.String getPathToRelogon()
Get the path to the logon-again page.


setReturnUrl

protected static void setReturnUrl(javax.servlet.http.HttpSession session,
                                   java.lang.String returnPath)
Deprecated. This method was modified not to refer to Client Tier classes (HttpSession). Use instead: setReturnUrl((ReturnPathContainer) new HttpSessionReturnPathContainer(session), returnPath)

Set the return url in the session.


setReturnUrl

protected static void setReturnUrl(com.RuntimeCollective.webapps.ReturnPathContainer rpContainer,
                                   java.lang.String returnPath)
Set the return url in the session.