List of usage examples for org.apache.shiro.crypto.hash Sha256Hash ALGORITHM_NAME
String ALGORITHM_NAME
To view the source code for org.apache.shiro.crypto.hash Sha256Hash ALGORITHM_NAME.
Click Source Link
From source file:annis.security.ANNISUserRealm.java
License:Apache License
public ANNISUserRealm() { // define a default credentials matcher HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(Sha256Hash.ALGORITHM_NAME); matcher.setHashIterations(1);//from w w w . j a v a2 s . co m setCredentialsMatcher(matcher); }
From source file:au.org.theark.core.security.ArkLdapRealm.java
License:Open Source License
public ArkLdapRealm() { setName("arkLdapRealm"); // This name must match the name in the User class's getPrincipals() method HashedCredentialsMatcher hashedCredentialsMatcher = new HashedCredentialsMatcher(); hashedCredentialsMatcher.setHashAlgorithmName(Sha256Hash.ALGORITHM_NAME); setCredentialsMatcher(hashedCredentialsMatcher); }
From source file:com.aegeus.core.AuthenticationConfiguration.java
License:Apache License
@Bean public JdbcRealm realm() { ConfigObject config = config();/* w w w . jav a 2 s . c o m*/ String uri = String.format("jdbc:%s://%s:%d/%s", config.getWorkflow().getMetaStore().getType(), config.getWorkflow().getMetaStore().getHost(), config.getWorkflow().getMetaStore().getPort(), config.getWorkflow().getMetaStore().getDb()); // initialize meta store database connection JdbcDataSource ds = new JdbcDataSource(); ds.setURL(uri); ds.setUser(config.getWorkflow().getMetaStore().getUsername()); ds.setPassword(config.getWorkflow().getMetaStore().getPassword()); HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(); matcher.setHashAlgorithmName(Sha256Hash.ALGORITHM_NAME); JdbcRealm realm = new JdbcRealm(); realm.setDataSource(ds); realm.setPermissionsLookupEnabled(true); realm.setAuthenticationQuery("SELECT pass FROM users WHERE user = ?"); realm.setPermissionsQuery( "SELECT p.permission FROM permissions p INNER JOIN users u ON p.user_id = u.id WHERE u.user = ?"); realm.setUserRolesQuery( "SELECT r.role FROM roles r INNER JOIN users u ON u.id = r.user_id WHERE u.user = ?"); realm.setCredentialsMatcher(matcher); realm.init(); return realm; }
From source file:com.eheobo.samples.shiro.security.SampleRealm.java
License:Apache License
public SampleRealm() { setName("SampleRealm"); //This name must match the name in the User class's getPrincipals() method HashedCredentialsMatcher hashedCredentialsMatcher = new HashedCredentialsMatcher(); hashedCredentialsMatcher.setHashAlgorithmName(Sha256Hash.ALGORITHM_NAME); setCredentialsMatcher(hashedCredentialsMatcher); }
From source file:com.ht.scada.security.ShiroDbRealm.java
License:Apache License
public ShiroDbRealm() { setName("SampleRealm"); // This name must match the name in the User // class's getPrincipals() method //PasswordHash. setCredentialsMatcher(new HashedCredentialsMatcher(Sha256Hash.ALGORITHM_NAME)); // HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(Sha1Hash.ALGORITHM_NAME); // matcher.setHashIterations(ShiroDbRealm.HASH_INTERATIONS); // setCredentialsMatcher(matcher); }
From source file:com.ineunet.knife.security.service.DefaultRealm.java
License:Apache License
public DefaultRealm() { // This name must match the name in the User class's getPrincipals() method this.setName("defaultRealm"); this.setCredentialsMatcher(new HashedCredentialsMatcher(Sha256Hash.ALGORITHM_NAME)); }
From source file:com.mycompany.shirofaces.SHA256.java
public static void main(String args[]) { RandomNumberGenerator rng = new SecureRandomNumberGenerator(); Object salt = rng.nextBytes(); String hashedPasswordBase64 = new Sha256Hash("juancho18", salt, 1024).toBase64(); Sha256Hash sha256Hash = new Sha256Hash("juancho18"); System.out.println("Clave sin salt: " + sha256Hash.toHex()); System.out.println("Clave con salt : " + hashedPasswordBase64); DefaultHashService hashService = new DefaultHashService(); hashService.setHashIterations(50000); // 500000 hashService.setHashAlgorithmName(Sha256Hash.ALGORITHM_NAME); hashService.setPrivateSalt(new SimpleByteSource("jumarome")); hashService.setGeneratePublicSalt(true); DefaultPasswordService passwordService = new DefaultPasswordService(); passwordService.setHashService(hashService); String salte = hashService.getPrivateSalt().toBase64(); String claveMaldita = passwordService.encryptPassword("unaep"); System.out.println("Miraaa: " + claveMaldita); System.out.println("private salt= " + salte); }
From source file:com.tensorwrench.shiro.realm.MongoUserPasswordRealm.java
License:Apache License
/** * Creates a user credential suitable for use with this realm. Intended for * creating the credentials to be inserted into the collection for later use. * //w w w . j a v a 2 s .c o m */ public DBObject createUserCredentials(String username, String plainTextPassword) { ByteSource salt = rng.nextBytes(); BasicDBObject obj = new BasicDBObject(); obj.put("name", username); obj.put("password", new Sha256Hash(plainTextPassword, salt, hashIterations).toBase64()); obj.put("salt", salt.toBase64()); obj.put("algorithm", Sha256Hash.ALGORITHM_NAME); obj.put("hashIterations", hashIterations); return obj; }
From source file:edu.eci.pdsw.aeci.seguridad.ShiroLoginBean.java
/** * // ww w .j a v a2 s . co m * @param password The password to encrypt * @return the password encrypted */ public static String generateHash(String password) { DefaultHashService hashService = new DefaultHashService(); hashService.setHashIterations(500000); hashService.setHashAlgorithmName(Sha256Hash.ALGORITHM_NAME); hashService.setPrivateSalt(new SimpleByteSource("myprivatesalt")); hashService.setGeneratePublicSalt(true); DefaultPasswordService passwordService = new DefaultPasswordService(); passwordService.setHashService(hashService); String encryptedPassword = passwordService.encryptPassword(password); return encryptedPassword; }
From source file:edu.eci.pdsw.samples.managedbeans.LogginBean.java
public static String generateHash(String password) { DefaultHashService hashService = new DefaultHashService(); hashService.setHashIterations(500000); // 500000 hashService.setHashAlgorithmName(Sha256Hash.ALGORITHM_NAME); // Same salt as in shiro.ini, but NOT base64-encoded!! hashService.setPrivateSalt(new SimpleByteSource("myprivatesalt")); hashService.setGeneratePublicSalt(true); DefaultPasswordService passwordService = new DefaultPasswordService(); passwordService.setHashService(hashService); String encryptedPassword = passwordService.encryptPassword(password); return encryptedPassword; }