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 AbstractUserBase

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.AbstractUserBase
All Implemented Interfaces:
java.io.Serializable, JDOMable, INameable, INamed
Direct Known Subclasses:
User

public abstract class AbstractUserBase
extends AbstractAccessControlObject

abstract base for User containing all utility methods.

Version:
$Revision: 1822 $
Author:
Thomas Weber, Daniel Dietz
See Also:
Serialized Form

Field Summary
static java.lang.String EVERYBODY
          name of the everybody role.
protected static java.lang.String PASSWORD_CHARACTERS
          The characters for auto-generated passwords.
 
Constructor Summary
AbstractUserBase()
           
 
Method Summary
static java.lang.String generatePassword()
          Returns a generated password of 12 characters.
static java.lang.String generateToken()
          generates a base-62 encoded 16 byte token using Lifecycle.getRandom().
protected  java.util.Set<CommandMatcher> getCommandMatchers()
           
protected  java.lang.Long getEveryBodyId()
          returns the id of the ~Everybody role.
static Role getEverybodyRole(org.hibernate.Session sess)
          retrieves the Everybody role.
static User getSuperUser(HibernateDataSource dataSrc)
          Returns the superuser or creates one, if none exists.
static User getUser(ServiceSession session)
          creates a User, if a User id is found in the ServiceSession.
static User getUser(java.lang.String usrName)
          Returns the User named usrName or the Everybody , if no such user exists.
static void initEverybodyRole(HibernateDataSource ds)
          initialises the "~EVERYBODY" Group.
 
Methods inherited from class org.torweg.pulse.accesscontrol.AbstractAccessControlObject
getAssociatedAbstractAccessControlObjects, getLoadCriteriaForClassWithAlias, toJSON
 
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.bundle.JDOMable
deserializeToJDOM
 
Methods inherited from interface org.torweg.pulse.util.INamed
getName
 

Field Detail

PASSWORD_CHARACTERS

protected static final java.lang.String PASSWORD_CHARACTERS
The characters for auto-generated passwords.

See Also:
Constant Field Values

EVERYBODY

public static final java.lang.String EVERYBODY
name of the everybody role.

See Also:
Constant Field Values
Constructor Detail

AbstractUserBase

public AbstractUserBase()
Method Detail

getCommandMatchers

protected final java.util.Set<CommandMatcher> getCommandMatchers()
Returns:
Returns the commandMatchers.

getEveryBodyId

protected final java.lang.Long getEveryBodyId()
returns the id of the ~Everybody role.

Returns:
the id

getUser

public static final User getUser(ServiceSession session)
creates a User, if a User id is found in the ServiceSession. If not, the Everybody is returned.

Parameters:
session - the ServiceSession
Returns:
the initialised User

getUser

public static final User getUser(java.lang.String usrName)
Returns the User named usrName or the Everybody , if no such user exists.

Parameters:
usrName - the name of the User
Returns:
the User named usrName or Everybody, if no such User exists.

getSuperUser

public static final User getSuperUser(HibernateDataSource dataSrc)
Returns the superuser or creates one, if none exists.

The superuser will get a random password, which will be logged at info level. Make sure to change the password after your first login!

Parameters:
dataSrc - the HibernateDataSource to be used
Returns:
the superuser

getEverybodyRole

public static final Role getEverybodyRole(org.hibernate.Session sess)
retrieves the Everybody role.

Parameters:
sess - the session to load the role with
Returns:
the ~Everybody role

initEverybodyRole

public static final void initEverybodyRole(HibernateDataSource ds)
initialises the "~EVERYBODY" Group.

If the group does not exist already, it is created.

Parameters:
ds - the HibernateDataSource to be used

generatePassword

public static final java.lang.String generatePassword()
Returns a generated password of 12 characters.

Returns:
a generated password of 12 characters

generateToken

public static final java.lang.String generateToken()
generates a base-62 encoded 16 byte token using Lifecycle.getRandom().

Returns:
the token