Esempio n. 1
0
 /** 认证回调函数,登录时调用. */
 @Override
 protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken)
     throws AuthenticationException {
   UsernamePasswordToken token = (UsernamePasswordToken) authcToken;
   User user = accountService.findUserByLoginName(token.getUsername());
   if (user != null) {
     byte[] salt = Encodes.decodeHex(user.getSalt());
     return new SimpleAuthenticationInfo(
         new ShiroUser(user.getId(), user.getLoginName(), user.getName()),
         user.getPassword(),
         ByteSource.Util.bytes(salt),
         getName());
   } else {
     return null;
   }
 }
Esempio n. 2
0
 @Test
 public void hexEncode() {
   String input = "haha,i am a very long message";
   String result = Encodes.encodeHex(input.getBytes());
   assertEquals(input, new String(Encodes.decodeHex(result)));
 }