1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| public class AuthenticationService implements LoginCommand{
@Override
public Principal doAuthentication(String login, Object credentials) {
String password = "";
String msg = "Not a valid username or password";
Session session = HibernateUtil.currentSession();
User user = (User) session.createCriteria(User.class).add(
Restrictions.eq("login", login)).add(
Restrictions.eq("password", hashPassword(password))).setMaxResults(1)
.uniqueResult();
if(user ==null){
throw new SecurityException(msg);
}
?????????
return null;
}
@Override
public boolean doAuthorization(Principal arg0, List arg1) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean logout(Principal arg0) {
// TODO Auto-generated method stub
return false;
}
@Override
public void start(ServletConfig arg0) {
// TODO Auto-generated method stub
}
@Override
public void stop() {
// TODO Auto-generated method stub
}
} |
Partager