mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Heinous merge from HEAD. Seems to basically work. Be on guard however.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4137 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -25,219 +25,359 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
/**
|
||||
* An authority DAO that has no implementation and should not be called.
|
||||
* An authority DAO that has no implementation.
|
||||
*
|
||||
* By default it will throw an exception if any method is called.
|
||||
*
|
||||
* Any of the getter/setter methods can be enabled with a no action implementation.
|
||||
*
|
||||
* This can support deleting users via the UI for LDAP and NTLM. The Alfresco person object is deleted from the UI.
|
||||
* The call to delete the user will return with no action.
|
||||
*
|
||||
* The following methods will always fail.
|
||||
*
|
||||
* getMD4HashedPassword(String userName)
|
||||
* loadUserByUsername(String arg0)
|
||||
* getSalt(UserDetails user)
|
||||
*
|
||||
* @author Andy Hind
|
||||
*/
|
||||
public class DefaultMutableAuthenticationDao implements MutableAuthenticationDao
|
||||
{
|
||||
|
||||
private boolean allowCreateUser = false;
|
||||
|
||||
private boolean allowUpdateUser = false;
|
||||
|
||||
private boolean allowDeleteUser = false;
|
||||
|
||||
private boolean allowSetEnabled = false;
|
||||
|
||||
private boolean allowGetEnabled = false;
|
||||
|
||||
private boolean allowSetAccountExpires = false;
|
||||
|
||||
private boolean allowGetAccountHasExpired = false;
|
||||
|
||||
private boolean allowSetCredentialsExpire = false;
|
||||
|
||||
private boolean allowGetCredentialsExpire = false;
|
||||
|
||||
private boolean allowGetCredentialsHaveExpired = false;
|
||||
|
||||
private boolean allowSetAccountLocked = false;
|
||||
|
||||
private boolean allowGetAccountLocked = false;
|
||||
|
||||
private boolean allowSetAccountExpiryDate = false;
|
||||
|
||||
private boolean allowGetAccountExpiryDate = false;
|
||||
|
||||
private boolean allowSetCredentialsExpiryDate = false;
|
||||
|
||||
private boolean allowGetCredentialsExpiryDate = false;
|
||||
|
||||
/**
|
||||
* Create a user with the given userName and password
|
||||
*
|
||||
* If enabled does nothing.
|
||||
*
|
||||
* @param userName
|
||||
* @param rawPassword
|
||||
* @throws AuthenticationException
|
||||
*/
|
||||
public void createUser(String userName, char[] rawPassword) throws AuthenticationException
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
if (!allowCreateUser)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Create User is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update a user's password.
|
||||
*
|
||||
* If enabled does nothing.
|
||||
*
|
||||
* @param userName
|
||||
* @param rawPassword
|
||||
* @throws AuthenticationException
|
||||
*/
|
||||
public void updateUser(String userName, char[] rawPassword) throws AuthenticationException
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
if (!allowUpdateUser)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Update user is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a user.
|
||||
*
|
||||
* If enabled does nothing.
|
||||
*
|
||||
* @param userName
|
||||
* @throws AuthenticationException
|
||||
*/
|
||||
public void deleteUser(String userName) throws AuthenticationException
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
if (!allowDeleteUser)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Delete user is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check is a user exists.
|
||||
*
|
||||
* If enabled returns true.
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
public boolean userExists(String userName)
|
||||
{
|
||||
// All users may exist
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enable/disable a user.
|
||||
*
|
||||
* If enabled does nothing.
|
||||
*
|
||||
* @param userName
|
||||
* @param enabled
|
||||
*/
|
||||
public void setEnabled(String userName, boolean enabled)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
if (!allowSetEnabled)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Set enabled is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Getter for user enabled
|
||||
*
|
||||
* If enabled returns true.
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
public boolean getEnabled(String userName)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
|
||||
if (!allowGetEnabled)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Get enabled is not supported");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set if the account should expire
|
||||
*
|
||||
* If enabled does nothing.
|
||||
*
|
||||
* @param userName
|
||||
* @param expires
|
||||
*/
|
||||
public void setAccountExpires(String userName, boolean expires)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
if (!allowSetAccountExpires)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Set account expires is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Does the account expire?
|
||||
*
|
||||
* If enabled returns false.
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
|
||||
|
||||
public boolean getAccountExpires(String userName)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
if (!allowSetAccountExpires)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Get account expires is not supported");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Has the account expired?
|
||||
*
|
||||
* If enabled returns false.
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
public boolean getAccountHasExpired(String userName)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
if (!allowGetAccountHasExpired)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Get account has expired is not supported");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set if the password expires.
|
||||
*
|
||||
* If enabled does nothing.
|
||||
*
|
||||
* @param userName
|
||||
* @param expires
|
||||
*/
|
||||
public void setCredentialsExpire(String userName, boolean expires)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
if (!allowSetCredentialsExpire)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Set credentials expire is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Do the credentials for the user expire?
|
||||
*
|
||||
* If enabled returns false.
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
public boolean getCredentialsExpire(String userName)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
if (!allowGetCredentialsExpire)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Get credentials expire is not supported");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Have the credentials for the user expired?
|
||||
*
|
||||
* If enabled returns false.
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
public boolean getCredentialsHaveExpired(String userName)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
if (!allowGetCredentialsHaveExpired)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Get credentials have expired is not supported");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set if the account is locked.
|
||||
*
|
||||
* If enabled does nothing.
|
||||
*
|
||||
* @param userName
|
||||
* @param locked
|
||||
*/
|
||||
public void setLocked(String userName, boolean locked)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
if (!allowSetAccountLocked)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Set account locked is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is the account locked?
|
||||
*
|
||||
* If enabled returns false.
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
public boolean getAccountlocked(String userName)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
if (!allowGetAccountLocked)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Get account locked is not supported");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the date on which the account expires
|
||||
*
|
||||
* If enabled does nothing.
|
||||
*
|
||||
* @param userName
|
||||
* @param exipryDate
|
||||
*/
|
||||
public void setAccountExpiryDate(String userName, Date exipryDate)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
if (!allowSetAccountExpiryDate)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Set account expiry date is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Get the date when this account expires.
|
||||
*
|
||||
* If enabled returns null.
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
public Date getAccountExpiryDate(String userName)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
if (!allowGetAccountExpiryDate)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Get account expiry date is not supported");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the date when credentials expire.
|
||||
*
|
||||
* If enabled does nothing.
|
||||
*
|
||||
* @param userName
|
||||
* @param exipryDate
|
||||
*/
|
||||
public void setCredentialsExpiryDate(String userName, Date exipryDate)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
if (!allowSetCredentialsExpiryDate)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Set credentials expiry date is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the date when the credentials/password expire.
|
||||
*
|
||||
* If enabled returns null.
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
public Date getCredentialsExpiryDate(String userName)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
if (!allowGetCredentialsExpiryDate)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Get credentials expiry date is not supported");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the MD4 password hash
|
||||
*
|
||||
* Always throws an exception.
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
@@ -249,7 +389,10 @@ public class DefaultMutableAuthenticationDao implements MutableAuthenticationDao
|
||||
/**
|
||||
* Return the user details for the specified user
|
||||
*
|
||||
* @param user String
|
||||
* Always throws an exception.
|
||||
*
|
||||
* @param user
|
||||
* String
|
||||
* @return UserDetails
|
||||
* @exception UsernameNotFoundException
|
||||
* @exception DataAccessException
|
||||
@@ -262,11 +405,99 @@ public class DefaultMutableAuthenticationDao implements MutableAuthenticationDao
|
||||
/**
|
||||
* Return salt for user
|
||||
*
|
||||
* @param user UserDetails
|
||||
* Always throws an exception.
|
||||
*
|
||||
* @param user
|
||||
* UserDetails
|
||||
* @return Object
|
||||
*/
|
||||
public Object getSalt(UserDetails user)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Not implemented");
|
||||
}
|
||||
|
||||
|
||||
// -------- //
|
||||
// Bean IOC //
|
||||
// -------- //
|
||||
|
||||
public void setAllowCreateUser(boolean allowCreateUser)
|
||||
{
|
||||
this.allowCreateUser = allowCreateUser;
|
||||
}
|
||||
|
||||
public void setAllowDeleteUser(boolean allowDeleteUser)
|
||||
{
|
||||
this.allowDeleteUser = allowDeleteUser;
|
||||
}
|
||||
|
||||
public void setAllowGetAccountExpiryDate(boolean allowGetAccountExpiryDate)
|
||||
{
|
||||
this.allowGetAccountExpiryDate = allowGetAccountExpiryDate;
|
||||
}
|
||||
|
||||
public void setAllowGetAccountHasExpired(boolean allowGetAccountHasExpired)
|
||||
{
|
||||
this.allowGetAccountHasExpired = allowGetAccountHasExpired;
|
||||
}
|
||||
|
||||
public void setAllowGetAccountLocked(boolean allowGetAccountLocked)
|
||||
{
|
||||
this.allowGetAccountLocked = allowGetAccountLocked;
|
||||
}
|
||||
|
||||
public void setAllowGetCredentialsExpire(boolean allowGetCredentialsExpire)
|
||||
{
|
||||
this.allowGetCredentialsExpire = allowGetCredentialsExpire;
|
||||
}
|
||||
|
||||
public void setAllowGetCredentialsExpiryDate(boolean allowGetCredentialsExpiryDate)
|
||||
{
|
||||
this.allowGetCredentialsExpiryDate = allowGetCredentialsExpiryDate;
|
||||
}
|
||||
|
||||
public void setAllowGetCredentialsHaveExpired(boolean allowGetCredentialsHaveExpired)
|
||||
{
|
||||
this.allowGetCredentialsHaveExpired = allowGetCredentialsHaveExpired;
|
||||
}
|
||||
|
||||
public void setAllowGetEnabled(boolean allowGetEnabled)
|
||||
{
|
||||
this.allowGetEnabled = allowGetEnabled;
|
||||
}
|
||||
|
||||
public void setAllowSetAccountExpires(boolean allowSetAccountExpires)
|
||||
{
|
||||
this.allowSetAccountExpires = allowSetAccountExpires;
|
||||
}
|
||||
|
||||
public void setAllowSetAccountExpiryDate(boolean allowSetAccountExpiryDate)
|
||||
{
|
||||
this.allowSetAccountExpiryDate = allowSetAccountExpiryDate;
|
||||
}
|
||||
|
||||
public void setAllowSetAccountLocked(boolean allowSetAccountLocked)
|
||||
{
|
||||
this.allowSetAccountLocked = allowSetAccountLocked;
|
||||
}
|
||||
|
||||
public void setAllowSetCredentialsExpire(boolean allowSetCredentialsExpire)
|
||||
{
|
||||
this.allowSetCredentialsExpire = allowSetCredentialsExpire;
|
||||
}
|
||||
|
||||
public void setAllowSetCredentialsExpiryDate(boolean allowSetCredentialsExpiryDate)
|
||||
{
|
||||
this.allowSetCredentialsExpiryDate = allowSetCredentialsExpiryDate;
|
||||
}
|
||||
|
||||
public void setAllowSetEnabled(boolean allowSetEnabled)
|
||||
{
|
||||
this.allowSetEnabled = allowSetEnabled;
|
||||
}
|
||||
|
||||
public void setAllowUpdateUser(boolean allowUpdateUser)
|
||||
{
|
||||
this.allowUpdateUser = allowUpdateUser;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user