@Inject public ClothoRealm(CredentialStore store, RolePermissionResolver roleResolver) { super(); //XXX: up number of iterations HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(Sha256Hash.ALGORITHM_NAME); matcher.setStoredCredentialsHexEncoded(false); this.store = store; setAuthenticationTokenClass(UsernamePasswordToken.class); setCredentialsMatcher(matcher); setRolePermissionResolver(roleResolver); setUpRealm(); }
@PostConstruct public void initCredentialsMatcher() { HashedCredentialsMatcher matcher = new HashedCredentialsMatcher( Random.SHA1); matcher.setHashIterations(Random.ITERATION); setCredentialsMatcher(matcher); }
/** * realm * * @return */ @Bean(name = "shiroRealm") public ShiroRealm myAuthRealm( @Qualifier("hashedCredentialsMatcher") HashedCredentialsMatcher matcher ) { ShiroRealm shiroRealm = new ShiroRealm(); // 设置密码凭证匹配器 shiroRealm.setCredentialsMatcher(matcher); // myShiroRealm.setCredentialsMatcher(hashedCredentialsMatcher()); return shiroRealm; }
/** * 用户的登录的明文密码,先经过md5加密再和数据库比对 */ @PostConstruct public void setCredentialMatcher() { HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(); credentialsMatcher.setHashAlgorithmName("MD5"); credentialsMatcher.setHashIterations(1024); setCredentialsMatcher(credentialsMatcher); }
/** * HashCredentialsMatcher,对密码进行编码 */ @Bean(name = "hashCredentialsMatcher") public HashedCredentialsMatcher hashedCredentialsMatcher(){ HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(); credentialsMatcher.setHashAlgorithmName("MD5"); credentialsMatcher.setHashIterations(2); //散列两次 credentialsMatcher.setStoredCredentialsHexEncoded(true); return credentialsMatcher; }
/** * 设定密码校验的Hash算法与迭代次数 */ @PostConstruct public void initCredentialsMatcher() { HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(MD5Util.HASH_ALGORITHM); matcher.setHashIterations(MD5Util.HASH_INTERATIONS); setCredentialsMatcher(matcher); }
/** * 设定密码校验的Hash算法与迭代次数 */ @PostConstruct public void initCredentialsMatcher() { HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(SystemService.HASH_ALGORITHM); matcher.setHashIterations(SystemService.HASH_INTERATIONS); setCredentialsMatcher(matcher); }
/** * 设定Password校验的Hash算法与迭代次数. */ @PostConstruct public void initCredentialsMatcher() { HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(AccountService.HASH_ALGORITHM); matcher.setHashIterations(AccountService.HASH_INTERATIONS); setCredentialsMatcher(matcher); }
public AuthorizingRealm buildRealm(UserService userService, ConfigurationService configService) { JdbcSaltedRealm realm = new JdbcSaltedRealm(userService, configService); HashedCredentialsMatcher matcher = new HashedCredentialsMatcher("SHA-256"); matcher.setHashIterations(1024); matcher.setStoredCredentialsHexEncoded(false); realm.setCredentialsMatcher(matcher); return realm; }
@Override protected WebEnvironment createEnvironment(ServletContext sc) { WebEnvironment webEnvironment = super.createEnvironment(sc); RealmSecurityManager rsm = (RealmSecurityManager) webEnvironment.getSecurityManager(); HashedCredentialsMatcher hashedCredentialsMatcher = new HashedCredentialsMatcher(HASHING_ALGORITHM); hashedCredentialsMatcher.setStoredCredentialsHexEncoded(true); jpaRealm.setCredentialsMatcher(hashedCredentialsMatcher); Collection<Realm> realms = rsm.getRealms(); realms.add(jpaRealm); rsm.setRealms(realms); ((DefaultWebEnvironment) webEnvironment).setSecurityManager(rsm); return webEnvironment; }
/** * 设定Password校验的Hash算法与迭代次数. */ @PostConstruct public void initCredentialsMatcher() { HashedCredentialsMatcher matcher = new HashedCredentialsMatcher( UserConstant.HASH_ALGORITHM); matcher.setHashIterations(UserConstant.HASH_INTERATIONS); setCredentialsMatcher(matcher); }
@Bean(name = "jdbcRealm") @DependsOn("lifecycleBeanPostProcessor") public JdbcRealm jdbcRealm() { JdbcRealm realm = new JdbcRealm(); HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(); credentialsMatcher.setHashAlgorithmName(Sha256Hash.ALGORITHM_NAME); realm.setCredentialsMatcher(credentialsMatcher); realm.setDataSource(dataSource); realm.init(); return realm; }
public AppDbRealm() { HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(EncodeKit.HASH_ALGORITHM); matcher.setHashIterations(EncodeKit.HASH_INTERATIONS); setCredentialsMatcher(matcher); setName("goja_app_realm"); }
/** * 构造器,设定Password校验的Hash算法与迭代次数. */ @PostConstruct public void initCredentialsMatcher() { HashedCredentialsMatcher matcher = new HashedCredentialsMatcher( Digests.SHA512_ALGORITHM); matcher.setHashIterations(Digests.HASH_INTERATIONS); setCredentialsMatcher(matcher); }
@PostConstruct public void postConstruct() { setCacheManager(new MemoryConstrainedCacheManager()); RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(env, "shiro.password."); nbHashIterations = propertyResolver.getProperty("nbHashIterations", Integer.class); HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(Sha512Hash.ALGORITHM_NAME); credentialsMatcher.setHashIterations(nbHashIterations); setCredentialsMatcher(credentialsMatcher); salt = propertyResolver.getProperty("salt"); }
/** * When annotations activated, you'll need to hash passwords in your configured Realm (i.e.: shiro.ini file) * @return credentialsMatcher singleton implementation for this application */ //@Provides //@Singleton public CredentialsMatcher provideCredentialsMatcher(){ HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(); matcher.setHashAlgorithmName(CREDENTIALS_MATCHER_ALGORITHM_NAME); return matcher; }
/** * 设定Password校验的Hash算法与迭代次数. */ @PostConstruct public void initCredentialsMatcher() { HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(UserService.HASH_ALGORITHM); matcher.setHashIterations(UserService.HASH_INTERATIONS); setCredentialsMatcher(matcher); }
/** * When annotations activated, you'll need to hash passwords in your configured Realm (i.e.: shiro.ini file) * @return credentialsMatcher singleton implementation for this application */ //@Provides //@Singleton public CredentialsMatcher provideCredentialsMatcher(){ logger.entry(); HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(); matcher.setHashAlgorithmName(CREDENTIALS_MATCHER_ALGORITHM_NAME); logger.exit(matcher); return matcher; }
/** * <p>Constructor for UserRealm.</p> */ public UserRealm() { final HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(Sha256Hash.ALGORITHM_NAME); credentialsMatcher.setHashIterations(1024); credentialsMatcher.setStoredCredentialsHexEncoded(false); this.setCredentialsMatcher(credentialsMatcher); }
/** {@inheritDoc} */ @Override protected AuthenticationInfo doGetAuthenticationInfo(final AuthenticationToken authenticationToken) throws AuthenticationException { // DEBUG: Print Security configuration logger.debug("!!! CredentialsMatcher: {}", this.getCredentialsMatcher().toString()); logger.debug("!!! HashAlgorithmName: {}", ((HashedCredentialsMatcher) getCredentialsMatcher()).getHashAlgorithmName()); logger.debug("!!! HashIterations: {}", ((HashedCredentialsMatcher) getCredentialsMatcher()).getHashIterations()); logger.debug("!!! StoredCredentialsHexEncoded: {}", ((HashedCredentialsMatcher) getCredentialsMatcher()).isStoredCredentialsHexEncoded()); final UsernamePasswordToken usernamePasswordToken = (UsernamePasswordToken) authenticationToken; if (usernamePasswordToken.getUsername() == null || usernamePasswordToken.getUsername().isEmpty()) { throw new UnknownAccountException("Authentication failed"); } // Find the thing that stores your user's credentials. This may be the // same or different than // the thing that stores the roles. final UserProfile principal = lookup(UserManagementService.class).findUserByLogin(usernamePasswordToken.getUsername()); if (principal == null) { logger.info("Principal not found for user with username: {}", usernamePasswordToken.getUsername()); return null; } else if (principal.isBlocked()) { logger.info("Access for user with username {} is forbidden", usernamePasswordToken.getUsername()); throw new LockedAccountException(); } logger.info("Principal found for authenticating user with username: {}", usernamePasswordToken.getUsername()); final ByteSource hashedCredentials = new SimpleByteSource(Base64.decode(principal.getPassword())); final ByteSource credentialsSalt = new SimpleByteSource(Base64.decode(principal.getPasswordSalt())); final SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo( principal.getLogin(), hashedCredentials, credentialsSalt, getName()); return authenticationInfo; }
/** * Constructor adds EhCacheManager. */ public PersistenceRealm() { super( new EhCacheManager()); // set hashed credentials matcher HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(HASH_ALGORITHM); credentialsMatcher.setHashIterations(HASH_ITERATIONS); credentialsMatcher.setStoredCredentialsHexEncoded(false); setCredentialsMatcher(credentialsMatcher); }
@Override public void afterPropertiesSet() throws Exception { HashedCredentialsMatcher cm = new HashedCredentialsMatcher(Sha256Hash.ALGORITHM_NAME); cm.setStoredCredentialsHexEncoded(false); cm.setHashIterations(Sha256.HASH_ITERATION); //cm.setHashSalted(true); this.setCredentialsMatcher(cm); // auto-create group "admins" and user "admin". adminsAutoCreate.run(); }
/** * Builds an instance of UserRealm and instantiates an HashedCredentialMatcher * * @return an instance of UserRealm */ public UserRealm() { setName(USER_REALM_NAME); HashedCredentialsMatcher matcher = new HashedCredentialsMatcher("SHA-256"); matcher.setStoredCredentialsHexEncoded(false); setCredentialsMatcher(matcher); }
public ShiroDbRealm() { setCredentialsMatcher(new HashedCredentialsMatcher("SHA-1")); }
public LdapRealm() { HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(HASHING_ALGORITHM); setCredentialsMatcher(credentialsMatcher); }
@PostConstruct public void initCredentialsMatcher() { HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(UserManager.HASH_ALGORITHM); matcher.setHashIterations(UserManager.HASH_INTERATIONS); setCredentialsMatcher(matcher); }
public HashedBase64Password(String password, RandomNumberGenerator rng) { ByteSource salt = rng.nextBytes(); HashedCredentialsMatcher matcher = ((HashedCredentialsMatcher) GwtUtilRealm.this.getCredentialsMatcher()); this.password = new SimpleHash(matcher.getHashAlgorithmName(), password, salt, matcher.getHashIterations()).toBase64(); this.salt = salt.toBase64(); }
@Inject UserValidator(final UserDao userDao, final HashedCredentialsMatcher matcher) { super(matcher); this.userDao = userDao; setName(UserValidator.class.getSimpleName()); }