Thanks for your reply, I really appreciate the help and advice.
One question I have concerning the following code:
Code:
interface AccountManager{
activateAccount(long accountId);
resetPassword(long accountId, String newPassword);
}
class AccountManagerImpl implements AccountManager{
activateAccount(long accountId){
Account account = accountDao.load(accountId);
account.activate();
}
resetPassword(long accountId, String newPassword){
Account account = accountDao.load(accountId);
account.resetPassword(newPassword);
}
}
The domain object - Account, would then have a dependency on the AccountDao, correct? Is this a good approach? Is there a better approach or design pattern? If that domain object is dependent upon this dao, does it make it harder to remote as a service? For example: if the AccountManager contained:
Code:
Account findAccountByUserId(String userId)
the activate() and resetPassword() methods exposed from Account would be dependent upon a dao implementation contained on the remote server.
You could do that yourself, but you also could have a look at Acegi. Acegi is a security framework for Spring that allows you to protect objects with AOP.
I've been wanting to look at Acegi, to see how it could help in implementing the security requirements I have but as I have tried to use the Spring AOP interfaces, I have struggled with enforcing the different restraints depending on the method or function being performed. For example in order for a user to activate his account they need to provide: userId, pin, dob. But in order for a user to reset his password they must provide: userId, pin, dob, and answer to challenge question.
So for example, say a user wants to change his challenge question, he must first be authenticated (logged in). If he is logged in he is able to change his challenge question. But if a user has forgotten his password he is not able to login, but instead needs to verify his identity by providing his userId, pin, dob, and challenge answer. So before resetPassword() can be called his identity must be verified.
A simple approach to this would be to have resetPassword take those as parameters and enforce the requirements itself.
Code:
public void activate(String userId, String pin, String dob)throws SecurityException
public void resetPassword(String userId, int pin, Date dob, String answer, String newPassword) throws SecurityException
public void changeChallengeQuestion(String userId, String currentPassword, String newQuestion, String newPassword) throws SecurityException
But this seems to push those security requirements into the domain object. Especially when that information is not needed to actually perform the function. It also has a bad side effect of if a user has already authenticated or verified his identity during the session, he must do so again if he wishes to perform one of these functions. Can Acegi offer this type of protection to my objects? If so can you point me to some examples?
Thanks again, any help is appreciated.