public PasswordMatcher() { this.passwordService = new DefaultPasswordService(); }
public PasswordMatcher() { this.passwordService = new DefaultPasswordService(); }
public class CustomEnvironmentLoaderListener extends EnvironmentLoaderListener { @Inject private JpaRealm jpaRealm; @Override protected WebEnvironment createEnvironment(ServletContext pServletContext) { WebEnvironment environment = super.createEnvironment(pServletContext); RealmSecurityManager rsm = (RealmSecurityManager) environment.getSecurityManager(); PasswordService passwordService = new DefaultPasswordService(); PasswordMatcher passwordMatcher = new PasswordMatcher(); passwordMatcher.setPasswordService(passwordService); jpaRealm.setCredentialsMatcher(passwordMatcher); rsm.setRealm(jpaRealm); ((DefaultWebEnvironment) environment).setSecurityManager(rsm); return environment; } }
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");
@Bean(name = "passwordService") public DefaultPasswordService passwordService() { return new DefaultPasswordService(); }
PasswordService service = new DefaultPasswordService(); // or use injection or shiro.ini to populate this private User createUserWithHashedPassword(String inName, String inFirstName, String inLastName, String inPassword){ String hashedPasswordBase64 = service.encryptPassword(inPassword); return new User(inName,inFirstName,inLastName,hashedPasswordBase64,strSalt); }
@Produces @ShiroIni @Named public PasswordService passwordService() { return new DefaultPasswordService(); }
DefaultPasswordService passwordService = new DefaultPasswordService(); String encytptedPwd= passwordService.encryptPassword("your password");
public class App { public static void main(String[] args) { PasswordService psd = new DefaultPasswordService(); String password = "333"; String enc = psd.encryptPassword(password); Locale.setDefault(Locale.ENGLISH); System.out.println(Locale.getDefault()); System.out.print(psd.passwordsMatch(password, enc)); } }
@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); }
private static final DefaultPasswordService defaultPasswordService = new DefaultPasswordService();
public PasswordRealmMixin() { super(); passwordService = new DefaultPasswordService(); PasswordMatcher matcher = new PasswordMatcher(); matcher.setPasswordService( passwordService ); setCredentialsMatcher( matcher ); }
public PasswordRealmMixin() { super(); passwordService = new DefaultPasswordService(); PasswordMatcher matcher = new PasswordMatcher(); matcher.setPasswordService( passwordService ); setCredentialsMatcher( matcher ); }
@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 MyRealmMixin() { super(); passwordService = new DefaultPasswordService(); PasswordMatcher matcher = new PasswordMatcher(); matcher.setPasswordService( passwordService ); setCredentialsMatcher( matcher ); }
public MyRealmMixin() { super(); passwordService = new DefaultPasswordService(); PasswordMatcher matcher = new PasswordMatcher(); matcher.setPasswordService( passwordService ); setCredentialsMatcher( matcher ); }
@Configuration public class SecurityConfiguration { private static final String PRIVATE_SALT = "ourprivatesalt"; private PasswordService passwordService; private PasswordMatcher credentialsMatcher = new PasswordAndSystemCredentialsMatcher(); private AuthenticatingSecurityManager securityManager; @Bean public PasswordService passwordService() { if (passwordService == null) { DefaultPasswordService defaultPasswordService = new DefaultPasswordService(); passwordService = defaultPasswordService; DefaultHashService defaultHashService = (DefaultHashService) defaultPasswordService.getHashService(); defaultHashService.setPrivateSalt(new SimpleByteSource(PRIVATE_SALT)); } return passwordService; } @Bean public CredentialsMatcher credentialsMatcher() { credentialsMatcher.setPasswordService(passwordService()); return credentialsMatcher; }
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()); }
if (isNotBlank(exists) || hasProperty) { final DefaultPasswordService passwordService = new DefaultPasswordService();