org.apache.shiro.authc.credential.HashedCredentialsMatcher Java Examples
The following examples show how to use
org.apache.shiro.authc.credential.HashedCredentialsMatcher.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShiroConfig.java From ElementVueSpringbootCodeTemplate with Apache License 2.0 | 6 votes |
/** * realm * * @return */ @Bean(name = "authRealm") public MyAuthorizingRealm myAuthRealm( @Qualifier("hashedCredentialsMatcher") HashedCredentialsMatcher matcher // CacheManager cacheManager ) { log.info("myShiroRealm()"); MyAuthorizingRealm myAuthorizingRealm = new MyAuthorizingRealm(); // 设置密码凭证匹配器 myAuthorizingRealm.setCredentialsMatcher(matcher); // 设置缓存管理器 // myAuthorizingRealm.setCacheManager(cacheManager); return myAuthorizingRealm; }
Example #2
Source File: SystemAuthorizingRealm.java From easyweb with Apache License 2.0 | 5 votes |
/** * 设定密码校验的Hash算法与迭代次数 */ @PostConstruct public void initCredentialsMatcher() { HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(MD5Util.HASH_ALGORITHM); matcher.setHashIterations(MD5Util.HASH_INTERATIONS); setCredentialsMatcher(matcher); }
Example #3
Source File: ShiroDbRealm.java From dubai with MIT License | 5 votes |
/** * 设定Password校验的Hash算法与迭代次数. */ @PostConstruct public void initCredentialsMatcher() { HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(UserService.HASH_ALGORITHM); matcher.setHashIterations(UserService.HASH_INTERATIONS); setCredentialsMatcher(matcher); }
Example #4
Source File: ShiroDbRealm.java From Mario with Apache License 2.0 | 5 votes |
/** * 设定Password校验的Hash算法与迭代次数. */ @PostConstruct public void initCredentialsMatcher() { HashedCredentialsMatcher matcher = new HashedCredentialsMatcher( AccountService.HASH_ALGORITHM); matcher.setHashIterations(AccountService.HASH_INTERATIONS); setCredentialsMatcher(matcher); }
Example #5
Source File: WebSecurityConfig.java From java-webapp-security-examples with Apache License 2.0 | 5 votes |
@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; }
Example #6
Source File: UserRealm.java From MultimediaDesktop with Apache License 2.0 | 5 votes |
/** * 设定Password校验的Hash算法与迭代次数. */ @PostConstruct public void initCredentialsMatcher() { HashedCredentialsMatcher matcher = new HashedCredentialsMatcher( UserConstant.HASH_ALGORITHM); matcher.setHashIterations(UserConstant.HASH_INTERATIONS); setCredentialsMatcher(matcher); }
Example #7
Source File: AuthorizingRealmImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Inject public AuthorizingRealmImpl(final RealmSecurityManager realmSecurityManager, final UserManager userManager, final Map<String, UserManager> userManagerMap) { this.realmSecurityManager = realmSecurityManager; this.userManager = userManager; this.userManagerMap = userManagerMap; HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(); credentialsMatcher.setHashAlgorithmName(Sha1Hash.ALGORITHM_NAME); setCredentialsMatcher(credentialsMatcher); setName(NAME); setAuthenticationCachingEnabled(false); // we authz only, no authc done by this realm setAuthorizationCachingEnabled(true); }
Example #8
Source File: ShiroDbRealm.java From spring-boot-quickstart with Apache License 2.0 | 5 votes |
/** * 设定Password校验的Hash算法与迭代次数. */ @PostConstruct public void initCredentialsMatcher() { HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(AccountService.HASH_ALGORITHM); matcher.setHashIterations(AccountService.HASH_INTERATIONS); setCredentialsMatcher(matcher); }
Example #9
Source File: SystemAuthorizingRealm.java From Shop-for-JavaWeb with MIT License | 5 votes |
/** * 设定密码校验的Hash算法与迭代次数 */ @PostConstruct public void initCredentialsMatcher() { HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(SystemService.HASH_ALGORITHM); matcher.setHashIterations(SystemService.HASH_INTERATIONS); setCredentialsMatcher(matcher); }
Example #10
Source File: ShiroConfiguration.java From wangmarket with Apache License 2.0 | 5 votes |
@Bean(name = "hashedCredentialsMatcher") public HashedCredentialsMatcher hashedCredentialsMatcher() { HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(); credentialsMatcher.setHashAlgorithmName("MD5"); credentialsMatcher.setHashIterations(2); credentialsMatcher.setStoredCredentialsHexEncoded(true); return credentialsMatcher; }
Example #11
Source File: MyShiroRealm.java From erp-framework with MIT License | 5 votes |
/** * 重写shiro的密码验证,让shiro用我自己的验证. */ @PostConstruct public void initCredentialsMatcher() { HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(Constants.HASH_ALGORITHM); matcher.setHashIterations(Constants.HASH_INTERATIONS); setCredentialsMatcher(matcher); }
Example #12
Source File: ShiroConfig.java From Spring-Shiro-Spark with Apache License 2.0 | 5 votes |
/** * HashCredentialsMatcher,对密码进行编码 */ @Bean(name = "hashCredentialsMatcher") public HashedCredentialsMatcher hashedCredentialsMatcher(){ HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(); credentialsMatcher.setHashAlgorithmName("MD5"); credentialsMatcher.setHashIterations(2); //散列两次 credentialsMatcher.setStoredCredentialsHexEncoded(true); return credentialsMatcher; }
Example #13
Source File: ShiroConfig.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
/** * realm * * @return */ @Bean(name = "shiroRealm") public ShiroRealm myAuthRealm( @Qualifier("hashedCredentialsMatcher") HashedCredentialsMatcher matcher ) { ShiroRealm shiroRealm = new ShiroRealm(); // 设置密码凭证匹配器 shiroRealm.setCredentialsMatcher(matcher); // myShiroRealm.setCredentialsMatcher(hashedCredentialsMatcher()); return shiroRealm; }
Example #14
Source File: AuthRealm.java From mysiteforme with Apache License 2.0 | 5 votes |
/** * 设定Password校验的Hash算法与迭代次数. */ @PostConstruct public void initCredentialsMatcher() { HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(Constants.HASH_ALGORITHM); matcher.setHashIterations(Constants.HASH_INTERATIONS); setCredentialsMatcher(matcher); }
Example #15
Source File: UserRealm.java From seezoon-framework-all with Apache License 2.0 | 5 votes |
@Override public void setCredentialsMatcher(CredentialsMatcher credentialsMatcher) { HashedCredentialsMatcher shaCredentialsMatcher = new HashedCredentialsMatcher(); shaCredentialsMatcher.setHashAlgorithmName(ShiroUtils.hashAlgorithmName); shaCredentialsMatcher.setHashIterations(ShiroUtils.hashIterations); super.setCredentialsMatcher(shaCredentialsMatcher); }
Example #16
Source File: MyShiroRealm.java From SpringBootBucket with MIT License | 5 votes |
/** * 设置认证加密方式 */ @Override public void setCredentialsMatcher(CredentialsMatcher credentialsMatcher) { HashedCredentialsMatcher md5CredentialsMatcher = new HashedCredentialsMatcher(); md5CredentialsMatcher.setHashAlgorithmName(ShiroKit.HASH_ALGORITHM_NAME); md5CredentialsMatcher.setHashIterations(ShiroKit.HASH_ITERATIONS); super.setCredentialsMatcher(md5CredentialsMatcher); }
Example #17
Source File: Sha256CredentialsHashingStrategy.java From arcusplatform with Apache License 2.0 | 5 votes |
public Sha256CredentialsHashingStrategy() { HashedCredentialsMatcher hashMatcher = new HashedCredentialsMatcher(); hashMatcher.setHashAlgorithmName(Sha256Hash.ALGORITHM_NAME); hashMatcher.setHashIterations(ITERATIONS); hashMatcher.setStoredCredentialsHexEncoded(false); credentialsMatcher = hashMatcher; }
Example #18
Source File: UserRealm.java From kvf-admin with MIT License | 5 votes |
@Override public void setCredentialsMatcher(CredentialsMatcher credentialsMatcher) { HashedCredentialsMatcher shaCredentialsMatcher = new HashedCredentialsMatcher(); shaCredentialsMatcher.setHashAlgorithmName(ShiroKit.HASH_ALGORITHM_NAME); shaCredentialsMatcher.setHashIterations(ShiroKit.HASH_ITERATIONS); super.setCredentialsMatcher(shaCredentialsMatcher); }
Example #19
Source File: ShiroDbRealm.java From WebStack-Guns with MIT License | 5 votes |
/** * 设置认证加密方式 */ @Override public void setCredentialsMatcher(CredentialsMatcher credentialsMatcher) { HashedCredentialsMatcher md5CredentialsMatcher = new HashedCredentialsMatcher(); md5CredentialsMatcher.setHashAlgorithmName(ShiroKit.hashAlgorithmName); md5CredentialsMatcher.setHashIterations(ShiroKit.hashIterations); super.setCredentialsMatcher(md5CredentialsMatcher); }
Example #20
Source File: ApiController.java From WebStack-Guns with MIT License | 5 votes |
/** * api登录接口,通过账号密码获取token */ @RequestMapping("/auth") public Object auth(@RequestParam("username") String username, @RequestParam("password") String password) { //封装请求账号密码为shiro可验证的token UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(username, password.toCharArray()); //获取数据库中的账号密码,准备比对 User user = userMapper.getByAccount(username); String credentials = user.getPassword(); String salt = user.getSalt(); ByteSource credentialsSalt = new Md5Hash(salt); SimpleAuthenticationInfo simpleAuthenticationInfo = new SimpleAuthenticationInfo( new ShiroUser(), credentials, credentialsSalt, ""); //校验用户账号密码 HashedCredentialsMatcher md5CredentialsMatcher = new HashedCredentialsMatcher(); md5CredentialsMatcher.setHashAlgorithmName(ShiroKit.hashAlgorithmName); md5CredentialsMatcher.setHashIterations(ShiroKit.hashIterations); boolean passwordTrueFlag = md5CredentialsMatcher.doCredentialsMatch( usernamePasswordToken, simpleAuthenticationInfo); if (passwordTrueFlag) { HashMap<String, Object> result = new HashMap<>(); result.put("token", JwtTokenUtil.generateToken(String.valueOf(user.getId()))); return result; } else { return new ErrorResponseData(500, "账号密码错误!"); } }
Example #21
Source File: SimpleAuthorizingRealm.java From NutzSite with Apache License 2.0 | 5 votes |
public SimpleAuthorizingRealm(CacheManager cacheManager, CredentialsMatcher matcher) { super(cacheManager, matcher); HashedCredentialsMatcher hashedCredentialsMatcher = new HashedCredentialsMatcher(); hashedCredentialsMatcher.setHashAlgorithmName("SHA-256"); hashedCredentialsMatcher.setHashIterations(1024); // 这一行决定hex还是base64 hashedCredentialsMatcher.setStoredCredentialsHexEncoded(false); // 设置token类型是关键!!! setCredentialsMatcher(hashedCredentialsMatcher); setAuthenticationTokenClass(UsernamePasswordToken.class); }
Example #22
Source File: ShiroDbRealm.java From MeetingFilm with Apache License 2.0 | 5 votes |
/** * 设置认证加密方式 */ @Override public void setCredentialsMatcher(CredentialsMatcher credentialsMatcher) { HashedCredentialsMatcher md5CredentialsMatcher = new HashedCredentialsMatcher(); md5CredentialsMatcher.setHashAlgorithmName(ShiroKit.hashAlgorithmName); md5CredentialsMatcher.setHashIterations(ShiroKit.hashIterations); super.setCredentialsMatcher(md5CredentialsMatcher); }
Example #23
Source File: ShiroDbRealm.java From DWSurvey with GNU Affero General Public License v3.0 | 4 votes |
public ShiroDbRealm() { setCredentialsMatcher(new HashedCredentialsMatcher("SHA-1")); }
Example #24
Source File: ShiroConfig.java From Shiro-Action with MIT License | 4 votes |
/** * 用户名密码登录密码匹配器 */ @Bean public HashedCredentialsMatcher hashedCredentialsMatcher() { return new RetryLimitHashedCredentialsMatcher("md5"); }
Example #25
Source File: LdapRealm.java From zeppelin with Apache License 2.0 | 4 votes |
public LdapRealm() { HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(HASHING_ALGORITHM); setCredentialsMatcher(credentialsMatcher); }
Example #26
Source File: KnoxLdapRealm.java From knox with Apache License 2.0 | 4 votes |
public KnoxLdapRealm() { HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(HASHING_ALGORITHM); setCredentialsMatcher(credentialsMatcher); }
Example #27
Source File: KnoxPamRealm.java From knox with Apache License 2.0 | 4 votes |
public KnoxPamRealm() { HashedCredentialsMatcher credentialsMatcher = new HashedCredentialsMatcher(HASHING_ALGORITHM); setCredentialsMatcher(credentialsMatcher); }