|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.turbine.services.BaseInitable
org.apache.turbine.services.BaseService
org.apache.turbine.services.TurbineBaseService
org.apache.turbine.services.security.BaseSecurityService
public abstract class BaseSecurityService
This is a common subset of SecurityService implementation. Provided functionality includes:
Field Summary |
---|
Fields inherited from class org.apache.turbine.services.BaseService |
---|
configuration, name, serviceBroker |
Fields inherited from class org.apache.turbine.services.BaseInitable |
---|
initableBroker, isInitialized |
Fields inherited from interface org.apache.turbine.services.security.SecurityService |
---|
ACL_CLASS_DEFAULT, ACL_CLASS_KEY, GROUP_CLASS_DEFAULT, GROUP_CLASS_KEY, PERMISSION_CLASS_DEFAULT, PERMISSION_CLASS_KEY, ROLE_CLASS_DEFAULT, ROLE_CLASS_KEY, SECURE_PASSWORDS_ALGORITHM_DEFAULT, SECURE_PASSWORDS_ALGORITHM_KEY, SECURE_PASSWORDS_DEFAULT, SECURE_PASSWORDS_KEY, SERVICE_NAME, USER_CLASS_DEFAULT, USER_CLASS_KEY, USER_MANAGER_DEFAULT, USER_MANAGER_KEY |
Constructor Summary | |
---|---|
BaseSecurityService()
|
Method Summary | |
---|---|
boolean |
accountExists(java.lang.String userName)
Check whether a specified user's account exists. |
boolean |
accountExists(User user)
Check whether a specified user's account exists. |
void |
addUser(User user,
java.lang.String password)
Creates new user account with specified attributes. |
void |
changePassword(User user,
java.lang.String oldPassword,
java.lang.String newPassword)
Change the password for an User. |
boolean |
checkPassword(java.lang.String checkpw,
java.lang.String encpw)
Checks if a supplied password matches the encrypted password |
java.lang.String |
encryptPassword(java.lang.String password)
This method provides client-side encryption of passwords. |
java.lang.String |
encryptPassword(java.lang.String password,
java.lang.String salt)
This method provides client-side encryption of passwords. |
void |
forcePassword(User user,
java.lang.String password)
Forcibly sets new password for an User. |
java.lang.Class |
getAclClass()
Return a Class object representing the system's chosen implementation of of ACL interface. |
AccessControlList |
getAclInstance(java.util.Map roles,
java.util.Map permissions)
Construct a new ACL object. |
GroupSet |
getAllGroups()
Retrieves all groups defined in the system. |
PermissionSet |
getAllPermissions()
Retrieves all permissions defined in the system. |
RoleSet |
getAllRoles()
Retrieves all roles defined in the system. |
User |
getAnonymousUser()
Constructs an User object to represent an anonymous user of the application. |
User |
getAuthenticatedUser(java.lang.String username,
java.lang.String password)
Authenticates an user, and constructs an User object to represent him/her. |
Group |
getGlobalGroup()
Provides a reference to the Group object that represents the global group. |
Group |
getGroup(java.lang.String name)
Deprecated. Use getGroupByName instead. |
Group |
getGroupById(int id)
Retrieve a Group object with specified Id. |
Group |
getGroupByName(java.lang.String name)
Retrieve a Group object with specified name. |
java.lang.Class |
getGroupClass()
Return a Class object representing the system's chosen implementation of of Group interface. |
Group |
getGroupInstance()
Construct a blank Group object. |
Group |
getGroupInstance(java.lang.String groupName)
Construct a blank Group object. |
Group |
getNewGroup(java.lang.String groupName)
Deprecated. Use getGroupInstance(String name) instead. |
Permission |
getNewPermission(java.lang.String permissionName)
Deprecated. Use getPermissionInstance(String name) instead. |
Role |
getNewRole(java.lang.String roleName)
Deprecated. Use getRoleInstance(String name) instead. |
Permission |
getPermission(java.lang.String name)
Deprecated. Use getPermissionByName instead. |
Permission |
getPermissionById(int id)
Retrieve a Permission object with specified Id. |
Permission |
getPermissionByName(java.lang.String name)
Retrieve a Permission object with specified name. |
java.lang.Class |
getPermissionClass()
Return a Class object representing the system's chosen implementation of of Permission interface. |
Permission |
getPermissionInstance()
Construct a blank Permission object. |
Permission |
getPermissionInstance(java.lang.String permName)
Construct a blank Permission object. |
Role |
getRole(java.lang.String name)
Deprecated. Use getRoleByName instead. |
Role |
getRoleById(int id)
Retrieve a Role object with specified Id. |
Role |
getRoleByName(java.lang.String name)
Retrieve a Role object with specified name. |
java.lang.Class |
getRoleClass()
Return a Class object representing the system's chosen implementation of of Role interface. |
Role |
getRoleInstance()
Construct a blank Role object. |
Role |
getRoleInstance(java.lang.String roleName)
Construct a blank Role object. |
User |
getUser(java.lang.String username)
Constructs an User object to represent a registered user of the application. |
java.lang.Class |
getUserClass()
Return a Class object representing the system's chosen implementation of of User interface. |
User |
getUserInstance()
Construct a blank User object. |
User |
getUserInstance(java.lang.String userName)
Construct a blank User object. |
java.util.List |
getUserList(org.apache.torque.util.Criteria criteria)
Retrieve a set of users that meet the specified criteria. |
UserManager |
getUserManager()
Returns the configured UserManager. |
User[] |
getUsers(org.apache.torque.util.Criteria criteria)
Deprecated. Use getUserList instead. |
void |
init()
Initializes the SecurityService, locating the apropriate UserManager This is a zero parameter variant which queries the Turbine Servlet for its config. |
void |
init(javax.servlet.ServletConfig config)
Deprecated. use init() instead. |
boolean |
isAnonymousUser(User user)
Checks whether a passed user object matches the anonymous user pattern according to the configured user manager |
protected void |
lockExclusive()
Acquire an exclusive lock on the security information repository. |
protected void |
lockShared()
Acquire a shared lock on the security information repository. |
void |
removeUser(User user)
Removes an user account from the system. |
void |
saveOnSessionUnbind(User user)
Saves User data when the session is unbound. |
void |
saveUser(User user)
Saves User's data in the permanent storage. |
void |
setUserManager(UserManager userManager)
Configure a new user Manager. |
protected void |
unlockExclusive()
Release an exclusive lock on the security information repository. |
protected void |
unlockShared()
Release a shared lock on the security information repository. |
Methods inherited from class org.apache.turbine.services.TurbineBaseService |
---|
init, init, shutdown |
Methods inherited from class org.apache.turbine.services.BaseService |
---|
getConfiguration, getName, getProperties, getServiceBroker, setName, setServiceBroker |
Methods inherited from class org.apache.turbine.services.BaseInitable |
---|
getInit, getInitableBroker, setInit, setInitableBroker |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.turbine.services.security.SecurityService |
---|
addGroup, addPermission, addRole, getACL, getGroups, getPermissions, getPermissions, getRoles, grant, grant, removeGroup, removePermission, removeRole, renameGroup, renamePermission, renameRole, revoke, revoke, revokeAll, revokeAll, saveGroup, savePermission, saveRole |
Methods inherited from interface org.apache.turbine.services.Service |
---|
getConfiguration, getName, getProperties, setName, setServiceBroker |
Methods inherited from interface org.apache.turbine.services.Initable |
---|
getInit, init, setInitableBroker, shutdown |
Constructor Detail |
---|
public BaseSecurityService()
Method Detail |
---|
public java.lang.String encryptPassword(java.lang.String password)
secure.passwords
are enabled in TurbineResources,
the password will be encrypted, if not, it will be returned unchanged.
The secure.passwords.algorithm
property can be used
to chose which digest algorithm should be used for performing the
encryption. SHA
is used by default.
encryptPassword
in interface SecurityService
password
- the password to process
public java.lang.String encryptPassword(java.lang.String password, java.lang.String salt)
secure.passwords
are enabled in TurbineResources,
the password will be encrypted, if not, it will be returned unchanged.
The secure.passwords.algorithm
property can be used
to chose which digest algorithm should be used for performing the
encryption. SHA
is used by default.
The used algorithms must be prepared to accept null as a
valid parameter for salt. All algorithms in the Fulcrum Cryptoservice
accept this.
encryptPassword
in interface SecurityService
password
- the password to processsalt
- algorithms that needs a salt can provide one here
public boolean checkPassword(java.lang.String checkpw, java.lang.String encpw)
checkPassword
in interface SecurityService
checkpw
- The clear text password supplied by the userencpw
- The current, encrypted password
public void init() throws InitializationException
init
in interface Initable
init
in class TurbineBaseService
InitializationException
- Something went wrong in the init stagepublic void init(javax.servlet.ServletConfig config) throws InitializationException
init
in class TurbineBaseService
config
- a ServletConfig, to enforce early initialization
InitializationException
- Something went wrong in the init stagepublic java.lang.Class getUserClass() throws UnknownEntityException
getUserClass
in interface SecurityService
UnknownEntityException
- if the implementation of User interface
could not be determined, or does not exist.public User getUserInstance() throws UnknownEntityException
getUserInstance
in interface SecurityService
UnknownEntityException
- if the object could not be instantiated.public User getUserInstance(java.lang.String userName) throws UnknownEntityException
getUserInstance
in interface SecurityService
userName
- The name of the user.
UnknownEntityException
- if the object could not be instantiated.public java.lang.Class getGroupClass() throws UnknownEntityException
getGroupClass
in interface SecurityService
UnknownEntityException
- if the implementation of Group interface
could not be determined, or does not exist.public Group getGroupInstance() throws UnknownEntityException
getGroupInstance
in interface SecurityService
UnknownEntityException
- if the object could not be instantiated.public Group getGroupInstance(java.lang.String groupName) throws UnknownEntityException
getGroupInstance
in interface SecurityService
groupName
- The name of the Group
UnknownEntityException
- if the object could not be instantiated.public java.lang.Class getPermissionClass() throws UnknownEntityException
getPermissionClass
in interface SecurityService
UnknownEntityException
- if the implementation of Permission interface
could not be determined, or does not exist.public Permission getPermissionInstance() throws UnknownEntityException
getPermissionInstance
in interface SecurityService
UnknownEntityException
- if the object could not be instantiated.public Permission getPermissionInstance(java.lang.String permName) throws UnknownEntityException
getPermissionInstance
in interface SecurityService
permName
- The name of the permission.
UnknownEntityException
- if the object could not be instantiated.public java.lang.Class getRoleClass() throws UnknownEntityException
getRoleClass
in interface SecurityService
UnknownEntityException
- if the implementation of Role interface
could not be determined, or does not exist.public Role getRoleInstance() throws UnknownEntityException
getRoleInstance
in interface SecurityService
UnknownEntityException
- if the object could not be instantiated.public Role getRoleInstance(java.lang.String roleName) throws UnknownEntityException
getRoleInstance
in interface SecurityService
roleName
- The name of the role.
UnknownEntityException
- if the object could not be instantiated.public java.lang.Class getAclClass() throws UnknownEntityException
getAclClass
in interface SecurityService
UnknownEntityException
- if the implementation of ACL interface
could not be determined, or does not exist.public AccessControlList getAclInstance(java.util.Map roles, java.util.Map permissions) throws UnknownEntityException
getAclInstance
in interface SecurityService
roles
- The roles that this ACL should containpermissions
- The permissions for this ACL
UnknownEntityException
- if the object could not be instantiated.public UserManager getUserManager()
getUserManager
in interface SecurityService
public void setUserManager(UserManager userManager)
setUserManager
in interface SecurityService
userManager
- An UserManager objectpublic boolean accountExists(User user) throws DataBackendException
accountExists
in interface SecurityService
user
- The user to be checked.
DataBackendException
- if there was an error accessing the data
backend.public boolean accountExists(java.lang.String userName) throws DataBackendException
accountExists
in interface SecurityService
userName
- The name of the user to be checked.
DataBackendException
- if there was an error accessing the data
backend.public User getAuthenticatedUser(java.lang.String username, java.lang.String password) throws DataBackendException, UnknownEntityException, PasswordMismatchException
getAuthenticatedUser
in interface SecurityService
username
- The user name.password
- The user password.
PasswordMismatchException
- if the supplied password was incorrect.
UnknownEntityException
- if the user's account does not
exist in the database.
DataBackendException
- if there is a problem accessing the storage.public User getUser(java.lang.String username) throws DataBackendException, UnknownEntityException
getUser
in interface SecurityService
username
- The user name.
UnknownEntityException
- if the user's account does not exist
DataBackendException
- if there is a problem accessing the storage.public User[] getUsers(org.apache.torque.util.Criteria criteria) throws DataBackendException
User
interface, plus the names
of the custom attributes you added to your user representation
in the data storage. Use verbatim names of the attributes -
without table name prefix in case of DB implementation.
getUsers
in interface SecurityService
criteria
- The criteria of selection.
DataBackendException
- if there is a problem accessing the
storage.public java.util.List getUserList(org.apache.torque.util.Criteria criteria) throws DataBackendException
User
interface, plus the names
of the custom attributes you added to your user representation
in the data storage. Use verbatim names of the attributes -
without table name prefix in case of DB implementation.
getUserList
in interface SecurityService
criteria
- The criteria of selection.
DataBackendException
- if there is a problem accessing the
storage.public User getAnonymousUser() throws UnknownEntityException
getAnonymousUser
in interface SecurityService
UnknownEntityException
- if the implementation of User interface
could not be determined, or does not exist.public boolean isAnonymousUser(User user)
isAnonymousUser
in interface SecurityService
user
- An user object
public void saveUser(User user) throws UnknownEntityException, DataBackendException
saveUser
in interface SecurityService
user
- the User object to save
UnknownEntityException
- if the user's account does not
exist in the database.
DataBackendException
- if there is a problem accessing the storage.public void saveOnSessionUnbind(User user) throws UnknownEntityException, DataBackendException
saveOnSessionUnbind
in interface SecurityService
UnknownEntityException
- if the user's account does not
exist in the database.
DataBackendException
- if there is a problem accessing the
storage.public void addUser(User user, java.lang.String password) throws DataBackendException, EntityExistsException
addUser
in interface SecurityService
user
- the object describing account to be created.password
- The password to use for the account.
DataBackendException
- if there was an error accessing the
data backend.
EntityExistsException
- if the user account already exists.public void removeUser(User user) throws DataBackendException, UnknownEntityException
removeUser
in interface SecurityService
user
- the object describing the account to be removed.
DataBackendException
- if there was an error accessing the data
backend.
UnknownEntityException
- if the user account is not present.public void changePassword(User user, java.lang.String oldPassword, java.lang.String newPassword) throws PasswordMismatchException, UnknownEntityException, DataBackendException
changePassword
in interface SecurityService
user
- an User to change password for.oldPassword
- the current password supplied by the user.newPassword
- the current password requested by the user.
PasswordMismatchException
- if the supplied password was incorrect.
UnknownEntityException
- if the user's record does not
exist in the database.
DataBackendException
- if there is a problem accessing the storage.public void forcePassword(User user, java.lang.String password) throws UnknownEntityException, DataBackendException
forcePassword
in interface SecurityService
user
- an User to change password for.password
- the new password.
UnknownEntityException
- if the user's record does not
exist in the database.
DataBackendException
- if there is a problem accessing the storage.protected void lockShared()
protected void unlockShared()
protected void lockExclusive()
synchronized
themselves!
protected void unlockExclusive()
synchronized
!
public Group getGlobalGroup()
getGlobalGroup
in interface SecurityService
public Group getGroup(java.lang.String name) throws DataBackendException, UnknownEntityException
getGroup
in interface SecurityService
name
- the name of the Group.
DataBackendException
- if there was an error accessing the
data backend.
UnknownEntityException
- if the group does not exist.public Group getGroupByName(java.lang.String name) throws DataBackendException, UnknownEntityException
getGroupByName
in interface SecurityService
name
- the name of the Group.
DataBackendException
- if there was an error accessing the
data backend.
UnknownEntityException
- if the group does not exist.public Group getGroupById(int id) throws DataBackendException, UnknownEntityException
getGroupById
in interface SecurityService
id
- the id of the Group.
UnknownEntityException
- if the permission does not
exist in the database.
DataBackendException
- if there is a problem accessing the
storage.public Role getRole(java.lang.String name) throws DataBackendException, UnknownEntityException
getRole
in interface SecurityService
name
- the name of the Role.
DataBackendException
- if there was an error accessing the
data backend.
UnknownEntityException
- if the role does not exist.public Role getRoleByName(java.lang.String name) throws DataBackendException, UnknownEntityException
getRoleByName
in interface SecurityService
name
- the name of the Role.
DataBackendException
- if there was an error accessing the
data backend.
UnknownEntityException
- if the role does not exist.public Role getRoleById(int id) throws DataBackendException, UnknownEntityException
getRoleById
in interface SecurityService
id
- the id of the Role.
UnknownEntityException
- if the permission does not
exist in the database.
DataBackendException
- if there is a problem accessing the
storage.public Permission getPermission(java.lang.String name) throws DataBackendException, UnknownEntityException
getPermission
in interface SecurityService
name
- the name of the Permission.
DataBackendException
- if there was an error accessing the
data backend.
UnknownEntityException
- if the permission does not exist.public Permission getPermissionByName(java.lang.String name) throws DataBackendException, UnknownEntityException
getPermissionByName
in interface SecurityService
name
- the name of the Permission.
DataBackendException
- if there was an error accessing the
data backend.
UnknownEntityException
- if the permission does not exist.public Permission getPermissionById(int id) throws DataBackendException, UnknownEntityException
getPermissionById
in interface SecurityService
id
- the id of the Permission.
UnknownEntityException
- if the permission does not
exist in the database.
DataBackendException
- if there is a problem accessing the
storage.public GroupSet getAllGroups() throws DataBackendException
getAllGroups
in interface SecurityService
DataBackendException
- if there was an error accessing the
data backend.public RoleSet getAllRoles() throws DataBackendException
getAllRoles
in interface SecurityService
DataBackendException
- if there was an error accessing the
data backend.public PermissionSet getAllPermissions() throws DataBackendException
getAllPermissions
in interface SecurityService
DataBackendException
- if there was an error accessing the
data backend.public Group getNewGroup(java.lang.String groupName)
getNewGroup
in interface SecurityService
public Role getNewRole(java.lang.String roleName)
getNewRole
in interface SecurityService
public Permission getNewPermission(java.lang.String permissionName)
getNewPermission
in interface SecurityService
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |