List of usage examples for org.apache.shiro.crypto.hash Sha512Hash Sha512Hash
public Sha512Hash(Object source)
From source file:cn.itganhuo.app.common.utils.StringUtil.java
License:Apache License
/** * Sha512/*w w w .j a va 2 s . c om*/ * <ol> * <li>shiro??</li> * </ol> * * @version 0.0.1-SNAPSHOT * @author -? * @param str * ? * @param hexEncoded * ???true??? * @return ? */ public static final String getSha512Shiro(String str, boolean hexEncoded) { if (!StringUtil.hasText(str)) return ""; if (hexEncoded) return new Sha512Hash(str).toBase64(); else return new Sha512Hash(str).toHex(); }
From source file:org.abstractj.auth.AuthenticationManager.java
License:Apache License
/** * Please, make sure to derive the passsword with Sha512Hash * @see https://shiro.apache.org/static/1.2.2/apidocs/org/apache/shiro/crypto/hash/Sha512Hash.html#Sha512Hash(java.lang.Object,%20java.lang.Object,%20int) * @param user// ww w . j a va 2s.c om */ public boolean login(User user) { UsernamePasswordToken token = new UsernamePasswordToken(user.getLoginName(), new Sha512Hash(user.getPassword()).toHex()); SecurityUtils.getSubject().login(token); if (SecurityUtils.getSubject().isAuthenticated()) { sessionId = SecurityUtils.getSubject().getSession(true).getId(); } else { throw new RuntimeException("Authentication failed"); } return true; }
From source file:org.abstractj.authz.impl.IdentityManagementImpl.java
License:Apache License
/** * Please, make sure to derive the passsword with Sha512Hash * @see https://shiro.apache.org/static/1.2.2/apidocs/org/apache/shiro/crypto/hash/Sha512Hash.html#Sha512Hash(java.lang.Object,%20java.lang.Object,%20int) * @param user/*from w w w.ja v a 2 s . c o m*/ */ @Override public void create(User user) { User newUser = new User(user.getLoginName(), new Sha512Hash(user.getPassword()).toHex()); entityManager.persist(newUser); }
From source file:org.abstractj.authz.SecurityRealm.java
License:Apache License
@Override public AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authToken) throws AuthenticationException { UsernamePasswordToken token = (UsernamePasswordToken) authToken; User user = identityManagement.findByUsername(token.getUsername()); if (user != null) { return new SimpleAuthenticationInfo(user.getId(), new Sha512Hash(user.getPassword()), getName()); //TODO new Sha512Hash(source, salt, iterations); } else {// w ww . j av a 2 s. co m throw new RuntimeException("Authentication failed"); } }
From source file:org.commonjava.web.user.data.PasswordManager.java
License:Open Source License
public boolean verifyPassword(final String digest, final String password) { return digest.equals(new Sha512Hash(password).toHex()); }
From source file:org.commonjava.web.user.data.PasswordManager.java
License:Open Source License
public String digestPassword(final String password) { return new Sha512Hash(password).toHex(); }
From source file:org.ecocean.servlet.ServletUtilities.java
License:Open Source License
public static String hashString(String hashMe) { return new Sha512Hash(hashMe).toHex(); }
From source file:org.jboss.aerogear.security.shiro.auth.AuthenticationManagerImpl.java
License:Apache License
/** * Logs in the specified User./*from w w w . j a v a2 s . c o m*/ * * @param user represents a simple implementation that holds user's credentials. * @throws org.jboss.aerogear.security.exception.AeroGearSecurityException * on login failure. */ @Override public boolean login(User user, String password) { UsernamePasswordToken token = new UsernamePasswordToken(user.getUsername(), new Sha512Hash(password).toHex()); subject.login(token); if (subject.isAuthenticated()) { sessionId = subject.getSession().getId(); } else { throw new RuntimeException("Authentication failed"); } return true; }
From source file:org.jboss.aerogear.security.shiro.authz.IdentityManagementImpl.java
License:Apache License
/** * This method creates a new User//from www .jav a 2s .c om * * @param user * @param password */ @Override public void create(User user, String password) { User newUser = new User(user.getUsername(), new Sha512Hash(password).toHex()); entityManager.persist(newUser); }
From source file:org.jboss.aerogear.security.shiro.authz.SecurityRealm.java
License:Apache License
@Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authToken) throws AuthenticationException { UsernamePasswordToken token = (UsernamePasswordToken) authToken; User user = (User) identityManagerment.findByUsername(token.getUsername()); if (user != null) { return new SimpleAuthenticationInfo(user.getId(), new Sha512Hash(user.getPassword()), getName()); } else {/*from ww w . jav a2 s. c om*/ throw new RuntimeException("Authentication failed"); } }