List of usage examples for org.apache.shiro.crypto.hash Sha256Hash fromBase64String
public static Sha256Hash fromBase64String(String base64)
From source file:com.tensorwrench.shiro.realm.MongoUserPasswordRealm.java
License:Apache License
/** * Does the actual mechanics of creating the Authentication info object from the database. *///from w w w . j a v a 2 s. com public AuthenticationInfo findPasswordForUsername(String username) { DBObject obj = collection.findOne(new BasicDBObject(DEFAULT_NAME_FIELD, username)); if (obj == null) { throw new UnknownAccountException("Unkown user " + username); } String password = MongoUtils.getPath(String.class, obj, passwordPath); String salt = MongoUtils.getPath(String.class, obj, saltPath); return new SimpleAuthenticationInfo(obj.get("_id"), password, Sha256Hash.fromBase64String(salt), getName()); }
From source file:no.priv.bang.ukelonn.db.derbytest.UkelonnDatabaseProviderTest.java
License:Apache License
private SimpleAuthenticationInfo createAuthenticationInfo(String principal, String hashedPassword, String salt) {/*from w w w. j a va2 s. c om*/ Object decodedPassword = Sha256Hash.fromBase64String(hashedPassword); ByteSource decodedSalt = Util.bytes(Base64.getDecoder().decode(salt)); SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(principal, decodedPassword, decodedSalt, "ukelonn"); return authenticationInfo; }