You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by "QO) <rsanchez@qualityobjects.com>" <Roberto> on 2004/02/18 18:33:42 UTC
Adding a user with his password
Hi,
One question:
If the interface "User" hasn't a method to get the user's password, How can I add to my repository a new user with the correct password ? The interface UsersRepository has the method: "boolean addUser(User user)", the only reference to the user's data is an interface "User".
In other implementations of UserRepository, it is done a cast to "DefaultUser" to use the method "getHashedPassword()"
For example in org.apache.james.userrepository.DefaultUsersJdbcRepository#setUserForInsertStatement(User user, ...)
DefaultUser defUser = (DefaultUser)user;
...
userInsert.setString(3, defUser.getHashedPassword());
What do you think about to include the method "getHashedPassword()" in "User" interface ?
Is it correct to do a cast to a class from an interface ? I think this generate a dependency between RemoteManager and Users Repositories then the interface "UserRepository" itsn't sufficient to determine the "contract" for the Users repository implementation. Is that correct ?
Roberto.