pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.accesscontrol
Class Permission

java.lang.Object
  extended by org.torweg.pulse.util.entity.AbstractBasicEntity
      extended by org.torweg.pulse.util.entity.AbstractNamedEntity
          extended by org.torweg.pulse.util.entity.AbstractNamableEntity
              extended by org.torweg.pulse.accesscontrol.AbstractAccessControlObject
                  extended by org.torweg.pulse.accesscontrol.Permission
All Implemented Interfaces:
java.io.Serializable, JDOMable, INameable, INamed

@Entity
public class Permission
extends AbstractAccessControlObject
implements INameable

A Permission is an entity used to restrict the excecution of Commands.

This is done by linking Permissions with CommandMatchers, Groups and Users. In order to find out if a User has the allowance for a Command, his Permissions (including those he gains through his associated Groups) have to be compared to the Permissions of the CommandMatchers matching the Command. If the CommandMatchers' set of Permissions is a subset of the User's set of Permissions, the User has the allowance for the Command.

Version:
$Revision: 1479 $
Author:
Christian Schatt, Daniel Dietz
See Also:
Serialized Form

Constructor Summary
protected Permission()
          Deprecated. 
  Permission(java.lang.String newName)
          The Constructor that sets the name of the Permission.
 
Method Summary
protected  boolean addCommandMatcher(CommandMatcher matcher)
          Adds a CommandMatcher to the Permission's Set of CommandMatchers.
 org.jdom.Element deserializeToJDOM()
          Serializes the state of the Permission as a JDOM Element.
 java.util.Set<CommandMatcher> getCommandMatchers()
          Returns a shallow copy of the Permission's Collection of CommandMatchers.
 java.lang.String getDescription()
          returns the description.
 java.util.List<Group> getGroups(org.hibernate.Session s)
          Returns the Groups associated with the Permission ordered by name.
 java.util.List<Role> getRoles(org.hibernate.Session s)
          Returns the Roles associated with the Permission ordered by name.
 java.util.List<User> getUsers(org.hibernate.Session s)
          Returns the Users associated with the Permission ordered by name.
 boolean removeCommandMatcher(CommandMatcher matcher)
          Removes a CommandMatcher from the Permission's Set of CommandMatchers if it is part of it.
 void setDescription(java.lang.String d)
          sets the description.
 net.sf.json.JSONObject toJSON()
          Serializes the state of the Permission as a JSONObject.
 net.sf.json.JSONObject toJSON(org.hibernate.Session s)
          Serializes the state of the Permission as a JSONObject.
 
Methods inherited from class org.torweg.pulse.accesscontrol.AbstractAccessControlObject
getAssociatedAbstractAccessControlObjects, getLoadCriteriaForClassWithAlias
 
Methods inherited from class org.torweg.pulse.util.entity.AbstractNamableEntity
setName
 
Methods inherited from class org.torweg.pulse.util.entity.AbstractNamedEntity
getName
 
Methods inherited from class org.torweg.pulse.util.entity.AbstractBasicEntity
compareTo, equals, getFullQualifiedClassNameJAXB, getId, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.torweg.pulse.util.INameable
setName
 
Methods inherited from interface org.torweg.pulse.util.INamed
getName
 

Constructor Detail

Permission

@Deprecated
protected Permission()
Deprecated. 

used for HibernateTM.


Permission

public Permission(java.lang.String newName)
The Constructor that sets the name of the Permission.

Parameters:
newName - the name of the Permission
Method Detail

getDescription

public final java.lang.String getDescription()
returns the description.

Returns:
the description.

setDescription

public final void setDescription(java.lang.String d)
sets the description.

Parameters:
d - the description to set

getCommandMatchers

public final java.util.Set<CommandMatcher> getCommandMatchers()
Returns a shallow copy of the Permission's Collection of CommandMatchers.

Attention: Since the returned Set is not a reference to the Permission's internal Collection, any modifications to its state will get lost. However, modifications to the state of the Set's elements will be consistent.

For example: Adding/Deleting a CommandMatcher to/from the Set will not have any effect, when the Permission is saved. On the other hand, modifications to a CommandMatcher in the Set will be made persistent, when the CommandMatcher is saved.

Returns:
the CommandMatchers associated with the Permission

addCommandMatcher

protected final boolean addCommandMatcher(CommandMatcher matcher)
Adds a CommandMatcher to the Permission's Set of CommandMatchers. If it already is part of the Set, it will not be added.

Parameters:
matcher - the CommandMatcher to be added
Returns:
true if the Set changed as a result of the call

removeCommandMatcher

public final boolean removeCommandMatcher(CommandMatcher matcher)
Removes a CommandMatcher from the Permission's Set of CommandMatchers if it is part of it.

Parameters:
matcher - the CommandMatcher to be removed
Returns:
true if the Set changed as a result of the call

getGroups

public final java.util.List<Group> getGroups(org.hibernate.Session s)
Returns the Groups associated with the Permission ordered by name.

Parameters:
s - the hibernateTM-Session
Returns:
the Groups associated with the Permission

getRoles

public final java.util.List<Role> getRoles(org.hibernate.Session s)
Returns the Roles associated with the Permission ordered by name.

Parameters:
s - the hibernateTM-Session
Returns:
the Roles associated with the Permission

getUsers

public final java.util.List<User> getUsers(org.hibernate.Session s)
Returns the Users associated with the Permission ordered by name.

Parameters:
s - the hibernateTM-Session
Returns:
the Users associated with the Permission

deserializeToJDOM

public final org.jdom.Element deserializeToJDOM()
Serializes the state of the Permission as a JDOM Element.

Specified by:
deserializeToJDOM in interface JDOMable
Returns:
the state of the Permission as a JDOM Element

toJSON

public final net.sf.json.JSONObject toJSON()
Serializes the state of the Permission as a JSONObject.

Overrides:
toJSON in class AbstractAccessControlObject
Returns:
the state of the Permission as a JSONObject

toJSON

public final net.sf.json.JSONObject toJSON(org.hibernate.Session s)
Serializes the state of the Permission as a JSONObject.

If a Session is given the number of Users, Groups and Roles associated with the Permission will be added to the JSON.

Parameters:
s - the hibernateTM-Session
Returns:
the state of the Permission as a JSONObject