本文整理匯總了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;
}
示例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;
}
示例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;
}