當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleAuthenticationInfo.setCredentialsSalt方法代碼示例

本文整理匯總了Java中org.apache.shiro.authc.SimpleAuthenticationInfo.setCredentialsSalt方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleAuthenticationInfo.setCredentialsSalt方法的具體用法?Java SimpleAuthenticationInfo.setCredentialsSalt怎麽用?Java SimpleAuthenticationInfo.setCredentialsSalt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.shiro.authc.SimpleAuthenticationInfo的用法示例。


在下文中一共展示了SimpleAuthenticationInfo.setCredentialsSalt方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doGetAuthenticationInfo

import org.apache.shiro.authc.SimpleAuthenticationInfo; //導入方法依賴的package包/類
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
    String username = "liu";
    //隨機數
    String salt2 = "0072273a5d87322163795118fdd7c45e";
    //加密後的密碼
    String password = "be320beca57748ab9632c4121ccac0db";

    SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(username, password, getName());
    authenticationInfo.setCredentialsSalt(ByteSource.Util.bytes(username + salt2));
    return authenticationInfo;
}
 
開發者ID:l81893521,項目名稱:shiro-demo,代碼行數:12,代碼來源:MyRealm2.java

示例2: doGetAuthenticationInfo

import org.apache.shiro.authc.SimpleAuthenticationInfo; //導入方法依賴的package包/類
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
      UsernamePasswordToken upToken = (UsernamePasswordToken) token;

     /* if (Strings.isBlank(upToken.getCaptcha()))
          throw new AuthenticationException("驗證碼不能為空");
      String _captcha = Strings.sBlank(SecurityUtils.getSubject().getSession(true).getAttribute(Toolkit.captcha_attr));
      if (!upToken.getCaptcha().equalsIgnoreCase(_captcha))
          throw new AuthenticationException("驗證碼錯誤");*/

      User user = dao().fetch(User.class, Cnd.where("name", "=", upToken.getUsername()));
      if (user == null)
          return null;
      if (user.isLocked()) 
          throw new LockedAccountException("Account [" + upToken.getUsername() + "] is locked.");
      ByteSource salt = ByteSource.Util.bytes(user.getSalt());
SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user, user.getPassword(), getName());
info.setCredentialsSalt(salt);
return info;
  }
 
開發者ID:strictnerd,項目名稱:windows-file-change,代碼行數:20,代碼來源:NutDaoRealm.java

示例3: doGetAuthenticationInfo

import org.apache.shiro.authc.SimpleAuthenticationInfo; //導入方法依賴的package包/類
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
  UsernamePasswordToken upToken = (UsernamePasswordToken) token;
  String username = upToken.getUsername();

  // Null username is invalid
  if(username == null) {
    throw new AccountException("Null usernames are not allowed by this realm.");
  }

  User user = userService.findActiveUser(username);
  if(user == null) user = userService.findActiveUserByEmail(username);
  if(user == null || !user.isEnabled() || !user.getRealm().equals(AGATE_REALM))
    throw new UnknownAccountException("No account found for user [" + username + "]");

  username = user.getName();
  UserCredentials userCredentials = userService.findUserCredentials(username);
  if(userCredentials == null) throw new UnknownAccountException("No account found for user [" + username + "]");

  SimpleAuthenticationInfo authInfo = new SimpleAuthenticationInfo(username, userCredentials.getPassword(), getName());
  authInfo.setCredentialsSalt(new SimpleByteSource(salt));
  return authInfo;
}
 
開發者ID:obiba,項目名稱:agate,代碼行數:24,代碼來源:AgateUserRealm.java


注:本文中的org.apache.shiro.authc.SimpleAuthenticationInfo.setCredentialsSalt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。