Java 类org.apache.shiro.authc.credential.HashedCredentialsMatcher 实例源码

项目:clotho3crud    文件:ClothoRealm.java   
@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();
}
项目:kettle_support_kettle8.0    文件:Authorizing2Realm.java   
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(
            Random.SHA1);
    matcher.setHashIterations(Random.ITERATION);
    setCredentialsMatcher(matcher);
}
项目:springboot-shiro-cas-mybatis    文件:ShiroConfig.java   
/**
 * realm
 * 
 * @return
 */
@Bean(name = "shiroRealm")
public ShiroRealm myAuthRealm(
        @Qualifier("hashedCredentialsMatcher") HashedCredentialsMatcher matcher
       ) {
    ShiroRealm shiroRealm = new ShiroRealm();
    // 设置密码凭证匹配器
    shiroRealm.setCredentialsMatcher(matcher); // myShiroRealm.setCredentialsMatcher(hashedCredentialsMatcher());

    return shiroRealm;
}
项目:ZHFS-WEB    文件:MyRealm.java   
/**
 * 用户的登录的明文密码,先经过md5加密再和数据库比对
 */
@PostConstruct
public void setCredentialMatcher() {
    HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher();
    credentialsMatcher.setHashAlgorithmName("MD5");
    credentialsMatcher.setHashIterations(1024);
    setCredentialsMatcher(credentialsMatcher);
}
项目:Spring-Shiro-Spark    文件:ShiroConfig.java   
/**
 * HashCredentialsMatcher,对密码进行编码
 */
@Bean(name = "hashCredentialsMatcher")
public HashedCredentialsMatcher hashedCredentialsMatcher(){
    HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher();
    credentialsMatcher.setHashAlgorithmName("MD5");
    credentialsMatcher.setHashIterations(2); //散列两次
    credentialsMatcher.setStoredCredentialsHexEncoded(true);
    return credentialsMatcher;
}
项目:easyweb    文件:SystemAuthorizingRealm.java   
/**
 * 设定密码校验的Hash算法与迭代次数
 */
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(MD5Util.HASH_ALGORITHM);
    matcher.setHashIterations(MD5Util.HASH_INTERATIONS);
    setCredentialsMatcher(matcher);
}
项目:melon    文件:SystemAuthorizingRealm.java   
/**
 * 设定密码校验的Hash算法与迭代次数
 */
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(SystemService.HASH_ALGORITHM);
    matcher.setHashIterations(SystemService.HASH_INTERATIONS);
    setCredentialsMatcher(matcher);
}
项目:Shop-for-JavaWeb    文件:SystemAuthorizingRealm.java   
/**
 * 设定密码校验的Hash算法与迭代次数
 */
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(SystemService.HASH_ALGORITHM);
    matcher.setHashIterations(SystemService.HASH_INTERATIONS);
    setCredentialsMatcher(matcher);
}
项目:YCBugsManager    文件:ShiroDbRealm.java   
/**
 * 设定Password校验的Hash算法与迭代次数.
 */
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(AccountService.HASH_ALGORITHM);
    matcher.setHashIterations(AccountService.HASH_INTERATIONS);

    setCredentialsMatcher(matcher);
}
项目:spring-boot-sample    文件:SystemAuthorizingRealm.java   
/**
 * 设定密码校验的Hash算法与迭代次数
 */
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(SystemService.HASH_ALGORITHM);
    matcher.setHashIterations(SystemService.HASH_INTERATIONS);
    setCredentialsMatcher(matcher);
}
项目:g2    文件:ShiroDbRealm.java   
/**
 * 设定Password校验的Hash算法与迭代次数.
 */
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(AccountService.HASH_ALGORITHM);
    matcher.setHashIterations(AccountService.HASH_INTERATIONS);

    setCredentialsMatcher(matcher);
}
项目:vdr-jonglisto    文件:AppModule.java   
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;
}
项目:bookery    文件:CDIAwareShiroEnvironmentLoader.java   
@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;
}
项目:spring-boot-quickstart    文件:ShiroDbRealm.java   
/**
 * 设定Password校验的Hash算法与迭代次数.
 */
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(AccountService.HASH_ALGORITHM);
    matcher.setHashIterations(AccountService.HASH_INTERATIONS);

    setCredentialsMatcher(matcher);
}
项目:MultimediaDesktop    文件:UserRealm.java   
/**
 * 设定Password校验的Hash算法与迭代次数.
 */
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(
            UserConstant.HASH_ALGORITHM);
    matcher.setHashIterations(UserConstant.HASH_INTERATIONS);
    setCredentialsMatcher(matcher);
}
项目:java-webapp-security-examples    文件:WebSecurityConfig.java   
@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;
}
项目:goja    文件:AppDbRealm.java   
public AppDbRealm() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(EncodeKit.HASH_ALGORITHM);
    matcher.setHashIterations(EncodeKit.HASH_INTERATIONS);

    setCredentialsMatcher(matcher);

    setName("goja_app_realm");
}
项目:fengduo    文件:ShiroDbRealm.java   
/**
 * 构造器,设定Password校验的Hash算法与迭代次数.
 */
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(
            Digests.SHA512_ALGORITHM);
    matcher.setHashIterations(Digests.HASH_INTERATIONS);
    setCredentialsMatcher(matcher);
}
项目:kettle    文件:Authorizing2Realm.java   
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(
            Random.SHA1);
    matcher.setHashIterations(Random.ITERATION);
    setCredentialsMatcher(matcher);
}
项目:agate    文件:AgateUserRealm.java   
@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");
}
项目:secure-rest-webapp-archetype    文件:BootstrapShiroModule.java   
/**
 * 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;
}
项目:netloan-project    文件:CustomPermissionsRealm.java   
/**
 * 设定Password校验的Hash算法与迭代次数.
 */
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(UserService.HASH_ALGORITHM);
    matcher.setHashIterations(UserService.HASH_INTERATIONS);
    setCredentialsMatcher(matcher);
}
项目:netloan-project    文件:MemberPermissionsRealm.java   
/**
 * 设定Password校验的Hash算法与迭代次数.
 */
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(UserService.HASH_ALGORITHM);
    matcher.setHashIterations(UserService.HASH_INTERATIONS);
    setCredentialsMatcher(matcher);
}
项目:shiro-guice-async-webapp    文件:BootstrapShiroModule.java   
/**
 * 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;
}
项目:dadaban    文件:ShiroDbRealm.java   
/**
 * 设定Password校验的Hash算法与迭代次数.
 */
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(AccountService.HASH_ALGORITHM);
    matcher.setHashIterations(AccountService.HASH_INTERATIONS);

    setCredentialsMatcher(matcher);
}
项目:shiro-guice-jersey-bootstrap    文件:BootstrapShiroModule.java   
/**
 * 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;
}
项目:shiro-guice-resteasy-webapp    文件:BootstrapShiroModule.java   
/**
 * 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;
}
项目:extacrm    文件:UserRealm.java   
/**
 * <p>Constructor for UserRealm.</p>
 */
public UserRealm() {
    final HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(Sha256Hash.ALGORITHM_NAME);
    credentialsMatcher.setHashIterations(1024);
    credentialsMatcher.setStoredCredentialsHexEncoded(false);
    this.setCredentialsMatcher(credentialsMatcher);
}
项目:extacrm    文件:UserRealm.java   
/** {@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;
}
项目:appengine    文件:ShiroDbRealm.java   
/**
 * 设定Password校验的Hash算法与迭代次数.
 */
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(AccountService.HASH_ALGORITHM);
    matcher.setHashIterations(AccountService.HASH_INTERATIONS);

    setCredentialsMatcher(matcher);
}
项目:appengine    文件:ShiroDbRealm.java   
/**
 * 设定Password校验的Hash算法与迭代次数.
 */
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(AccountService.HASH_ALGORITHM);
    matcher.setHashIterations(AccountService.HASH_INTERATIONS);

    setCredentialsMatcher(matcher);
}
项目:appengine    文件:ShiroDbRealm.java   
/**
 * 设定Password校验的Hash算法与迭代次数.
 */
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(AccountService.HASH_ALGORITHM);
    matcher.setHashIterations(AccountService.HASH_INTERATIONS);

    setCredentialsMatcher(matcher);
}
项目:panifex-platform    文件:PersistenceRealm.java   
/**
 * 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);
}
项目:glados-wiki    文件:MyRealm.java   
@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();
}
项目:freedomotic    文件:UserRealm.java   
/**
 * 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);
}
项目:DWSurvey    文件:ShiroDbRealm.java   
public ShiroDbRealm() {
    setCredentialsMatcher(new HashedCredentialsMatcher("SHA-1"));
}
项目:zeppelin    文件:LdapRealm.java   
public LdapRealm() {
  HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(HASHING_ALGORITHM);
  setCredentialsMatcher(credentialsMatcher);
}
项目:snaker-demo    文件:ShiroAuthorizingRealm.java   
@PostConstruct
public void initCredentialsMatcher() {
    HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(UserManager.HASH_ALGORITHM);
    matcher.setHashIterations(UserManager.HASH_INTERATIONS);
    setCredentialsMatcher(matcher);
}
项目:gwtutil    文件:GwtUtilRealm.java   
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();
}
项目:devhub-prototype    文件:UserValidator.java   
@Inject
UserValidator(final UserDao userDao, final HashedCredentialsMatcher matcher) {
    super(matcher);
    this.userDao = userDao;
    setName(UserValidator.class.getSimpleName());
}