|
||||||||||
| 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(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,
String password)
Creates new user account with specified attributes. |
void |
changePassword(User user,
String oldPassword,
String newPassword)
Change the password for an User. |
boolean |
checkPassword(String checkpw,
String encpw)
Checks if a supplied password matches the encrypted password |
String |
encryptPassword(String password)
This method provides client-side encryption of passwords. |
String |
encryptPassword(String password,
String salt)
This method provides client-side encryption of passwords. |
void |
forcePassword(User user,
String password)
Forcibly sets new password for an User. |
Class |
getAclClass()
Return a Class object representing the system's chosen implementation of of ACL interface. |
AccessControlList |
getAclInstance(Map roles,
Map permissions)
Construct a new ACL object. |
abstract GroupSet |
getAllGroups()
Retrieves all groups defined in the system. |
abstract PermissionSet |
getAllPermissions()
Retrieves all permissions defined in the system. |
abstract 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(String username,
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 |
getGroupById(int id)
Retrieve a Group object with specified Id. |
Group |
getGroupByName(String name)
Retrieve a Group object with specified name. |
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(String groupName)
Construct a blank Group object. |
Permission |
getPermissionById(int id)
Retrieve a Permission object with specified Id. |
Permission |
getPermissionByName(String name)
Retrieve a Permission object with specified name. |
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(String permName)
Construct a blank Permission object. |
Role |
getRoleById(int id)
Retrieve a Role object with specified Id. |
Role |
getRoleByName(String name)
Retrieve a Role object with specified name. |
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(String roleName)
Construct a blank Role object. |
User |
getUser(String username)
Constructs an User object to represent a registered user of the application. |
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(String userName)
Construct a blank User object. |
UserManager |
getUserManager()
Returns the configured UserManager. |
void |
init()
Initializes the SecurityService, locating the apropriate UserManager This is a zero parameter variant which queries the Turbine Servlet for its config. |
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, 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, getUserList, 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 String encryptPassword(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 SecurityServicepassword - the password to process
public String encryptPassword(String password,
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 SecurityServicepassword - the password to processsalt - algorithms that needs a salt can provide one here
public boolean checkPassword(String checkpw,
String encpw)
checkPassword in interface SecurityServicecheckpw - The clear text password supplied by the userencpw - The current, encrypted password
public void init()
throws InitializationException
init in interface Initableinit in class TurbineBaseServiceInitializationException - Something went wrong in the init stage
public Class getUserClass()
throws UnknownEntityException
getUserClass in interface SecurityServiceUnknownEntityException - if the implementation of User interface
could not be determined, or does not exist.
public User getUserInstance()
throws UnknownEntityException
getUserInstance in interface SecurityServiceUnknownEntityException - if the object could not be instantiated.
public User getUserInstance(String userName)
throws UnknownEntityException
getUserInstance in interface SecurityServiceuserName - The name of the user.
UnknownEntityException - if the object could not be instantiated.
public Class getGroupClass()
throws UnknownEntityException
getGroupClass in interface SecurityServiceUnknownEntityException - if the implementation of Group interface
could not be determined, or does not exist.
public Group getGroupInstance()
throws UnknownEntityException
getGroupInstance in interface SecurityServiceUnknownEntityException - if the object could not be instantiated.
public Group getGroupInstance(String groupName)
throws UnknownEntityException
getGroupInstance in interface SecurityServicegroupName - The name of the Group
UnknownEntityException - if the object could not be instantiated.
public Class getPermissionClass()
throws UnknownEntityException
getPermissionClass in interface SecurityServiceUnknownEntityException - if the implementation of Permission interface
could not be determined, or does not exist.
public Permission getPermissionInstance()
throws UnknownEntityException
getPermissionInstance in interface SecurityServiceUnknownEntityException - if the object could not be instantiated.
public Permission getPermissionInstance(String permName)
throws UnknownEntityException
getPermissionInstance in interface SecurityServicepermName - The name of the permission.
UnknownEntityException - if the object could not be instantiated.
public Class getRoleClass()
throws UnknownEntityException
getRoleClass in interface SecurityServiceUnknownEntityException - if the implementation of Role interface
could not be determined, or does not exist.
public Role getRoleInstance()
throws UnknownEntityException
getRoleInstance in interface SecurityServiceUnknownEntityException - if the object could not be instantiated.
public Role getRoleInstance(String roleName)
throws UnknownEntityException
getRoleInstance in interface SecurityServiceroleName - The name of the role.
UnknownEntityException - if the object could not be instantiated.
public Class getAclClass()
throws UnknownEntityException
getAclClass in interface SecurityServiceUnknownEntityException - if the implementation of ACL interface
could not be determined, or does not exist.
public AccessControlList getAclInstance(Map roles,
Map permissions)
throws UnknownEntityException
getAclInstance in interface SecurityServiceroles - 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 SecurityServicepublic void setUserManager(UserManager userManager)
setUserManager in interface SecurityServiceuserManager - An UserManager object
public boolean accountExists(User user)
throws DataBackendException
accountExists in interface SecurityServiceuser - The user to be checked.
DataBackendException - if there was an error accessing the data
backend.
public boolean accountExists(String userName)
throws DataBackendException
accountExists in interface SecurityServiceuserName - The name of the user to be checked.
DataBackendException - if there was an error accessing the data
backend.
public User getAuthenticatedUser(String username,
String password)
throws DataBackendException,
UnknownEntityException,
PasswordMismatchException
getAuthenticatedUser in interface SecurityServiceusername - 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(String username)
throws DataBackendException,
UnknownEntityException
getUser in interface SecurityServiceusername - The user name.
UnknownEntityException - if the user's account does not exist
DataBackendException - if there is a problem accessing the storage.
public User getAnonymousUser()
throws UnknownEntityException
getAnonymousUser in interface SecurityServiceUnknownEntityException - if the implementation of User interface
could not be determined, or does not exist.public boolean isAnonymousUser(User user)
isAnonymousUser in interface SecurityServiceuser - An user object
public void saveUser(User user)
throws UnknownEntityException,
DataBackendException
saveUser in interface SecurityServiceuser - 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 SecurityServiceUnknownEntityException - 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,
String password)
throws DataBackendException,
EntityExistsException
addUser in interface SecurityServiceuser - 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 SecurityServiceuser - 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,
String oldPassword,
String newPassword)
throws PasswordMismatchException,
UnknownEntityException,
DataBackendException
changePassword in interface SecurityServiceuser - 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,
String password)
throws UnknownEntityException,
DataBackendException
forcePassword in interface SecurityServiceuser - 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 getGroupByName(String name)
throws DataBackendException,
UnknownEntityException
getGroupByName in interface SecurityServicename - 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 SecurityServiceid - 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 getRoleByName(String name)
throws DataBackendException,
UnknownEntityException
getRoleByName in interface SecurityServicename - 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 SecurityServiceid - 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 getPermissionByName(String name)
throws DataBackendException,
UnknownEntityException
getPermissionByName in interface SecurityServicename - 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 SecurityServiceid - 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 abstract GroupSet getAllGroups()
throws DataBackendException
getAllGroups in interface SecurityServiceDataBackendException - if there was an error accessing the
data backend.
public abstract RoleSet getAllRoles()
throws DataBackendException
getAllRoles in interface SecurityServiceDataBackendException - if there was an error accessing the
data backend.
public abstract PermissionSet getAllPermissions()
throws DataBackendException
getAllPermissions in interface SecurityServiceDataBackendException - if there was an error accessing the
data backend.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||