Пример #1
0
 public User findUser(String username) {
   if ("guest".equals(username)) {
     User user = new User();
     user.setUsername(username);
     user.setPassword(Coder.encodeMd5(username + ":" + User.REALM + ":" + guestPassword));
     user.setName(username);
     user.setRole(User.GUEST);
     user.setEnabled(true);
     user.setLocale("zh");
     user.setServicePrivilege("");
     return user;
   } else if ("root".equals(username)) {
     User user = new User();
     user.setUsername(username);
     user.setPassword(Coder.encodeMd5(username + ":" + User.REALM + ":" + rootPassword));
     user.setName(username);
     user.setRole(User.ROOT);
     user.setEnabled(true);
     user.setLocale("zh");
     user.setServicePrivilege("*");
     return user;
   }
   return null;
 }