DefaultHashService hashService = new DefaultHashService(); hashService.setHashIterations(HASH_ITERATIONS); // 500000 hashService.setHashAlgorithmName(Sha256Hash.ALGORITHM_NAME); hashService.setPrivateSalt(new SimpleByteSource(PRIVATE_SALT)); // Same salt as in shiro.ini, but NOT base64-encoded. hashService.setGeneratePublicSalt(true); DefaultPasswordService passwordService = new DefaultPasswordService(); passwordService.setHashService(hashService); String encryptedPassword = passwordService.encryptPassword("PasswordForThisUser");
@Inject public DefaultSecurityPasswordService(@Named("legacy") final PasswordService legacyPasswordService) { this.passwordService = new DefaultPasswordService(); this.legacyPasswordService = checkNotNull(legacyPasswordService); //Create and set a hash service according to our hashing policies DefaultHashService hashService = new DefaultHashService(); hashService.setHashAlgorithmName(DEFAULT_HASH_ALGORITHM); hashService.setHashIterations(DEFAULT_HASH_ITERATIONS); hashService.setGeneratePublicSalt(true); this.passwordService.setHashService(hashService); }
@Inject public DefaultSecurityPasswordService(SecurityConfigurationManager securityConfiguration, @Named("legacy") PasswordService legacyPasswordService) { this.securityConfiguration = securityConfiguration; this.passwordService = new DefaultPasswordService(); this.legacyPasswordService = legacyPasswordService; //Create and set a hash service according to our hashing policies DefaultHashService hashService = new DefaultHashService(); hashService.setHashAlgorithmName(DEFAULT_HASH_ALGORITHM); hashService.setHashIterations(this.securityConfiguration.getHashIterations()); hashService.setGeneratePublicSalt(true); this.passwordService.setHashService(hashService); }
public LegacyNexusPasswordService() { //Initialize and configure sha1 password service this.sha1PasswordService = new DefaultPasswordService(); DefaultHashService sha1HashService = new DefaultHashService(); sha1HashService.setHashAlgorithmName("SHA-1"); sha1HashService.setHashIterations(1); sha1HashService.setGeneratePublicSalt(false); this.sha1PasswordService.setHashService(sha1HashService); this.sha1PasswordService.setHashFormat(new HexFormat()); //Initialize and configure md5 password service this.md5PasswordService = new DefaultPasswordService(); DefaultHashService md5HashService = new DefaultHashService(); md5HashService.setHashAlgorithmName("MD5"); md5HashService.setHashIterations(1); md5HashService.setGeneratePublicSalt(false); this.md5PasswordService.setHashService(md5HashService); this.md5PasswordService.setHashFormat(new HexFormat()); }
public LegacyNexusPasswordService() { //Initialize and configure sha1 password service this.sha1PasswordService = new DefaultPasswordService(); DefaultHashService sha1HashService = new DefaultHashService(); sha1HashService.setHashAlgorithmName("SHA-1"); sha1HashService.setHashIterations(1); sha1HashService.setGeneratePublicSalt(false); this.sha1PasswordService.setHashService(sha1HashService); this.sha1PasswordService.setHashFormat(new HexFormat()); //Initialize and configure md5 password service this.md5PasswordService = new DefaultPasswordService(); DefaultHashService md5HashService = new DefaultHashService(); md5HashService.setHashAlgorithmName("MD5"); md5HashService.setHashIterations(1); md5HashService.setGeneratePublicSalt(false); this.md5PasswordService.setHashService(md5HashService); this.md5PasswordService.setHashFormat(new HexFormat()); }
passwordService.setHashService(hashService);