• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SimpleCredentialsMatcher类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.shiro.authc.credential.SimpleCredentialsMatcher的典型用法代码示例。如果您正苦于以下问题:Java SimpleCredentialsMatcher类的具体用法?Java SimpleCredentialsMatcher怎么用?Java SimpleCredentialsMatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SimpleCredentialsMatcher类属于org.apache.shiro.authc.credential包,在下文中一共展示了SimpleCredentialsMatcher类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: ApiKeyRealm

import org.apache.shiro.authc.credential.SimpleCredentialsMatcher; //导入依赖的package包/类
public ApiKeyRealm(String name, CacheManager cacheManager, AuthIdentityReader<ApiKey> authIdentityReader,
                   PermissionReader permissionReader, @Nullable String anonymousId) {
    super(null, AnonymousCredentialsMatcher.anonymousOrMatchUsing(new SimpleCredentialsMatcher()));


    _authIdentityReader = checkNotNull(authIdentityReader, "authIdentityReader");
    _permissionReader = checkNotNull(permissionReader, "permissionReader");
    _anonymousId = anonymousId;

    setName(checkNotNull(name, "name"));
    setAuthenticationTokenClass(ApiKeyAuthenticationToken.class);
    setPermissionResolver(permissionReader.getPermissionResolver());
    setRolePermissionResolver(createRolePermissionResolver());
    setCacheManager(prepareCacheManager(cacheManager));
    setAuthenticationCachingEnabled(true);
    setAuthorizationCachingEnabled(true);

    // By default Shiro calls clearCache() for each user when they are logged out in order to prevent stale
    // credentials from being cached.  However, if the cache manager implements InvalidatingCacheManager then it has
    // its own internal listeners that will invalidate the cache on any updates, making this behavior unnecessarily
    // expensive.
    _clearCaches = cacheManager != null && !(cacheManager instanceof InvalidatableCacheManager);
    _log.debug("Clearing of caches for realm {} is {}", name, _clearCaches ? "enabled" : "disabled");
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:25,代码来源:ApiKeyRealm.java


示例2: hashedCredentialsMatcher

import org.apache.shiro.authc.credential.SimpleCredentialsMatcher; //导入依赖的package包/类
/**
     * 凭证匹配器
     * (由于我们的密码校验交给Shiro的SimpleAuthenticationInfo进行处理了
     *  所以我们需要修改下doGetAuthenticationInfo中的代码;
     * )
     * @return
     */
    @Bean
    public SimpleCredentialsMatcher /*HashedCredentialsMatcher*/ hashedCredentialsMatcher(){

        //1:
//        HashedCredentialsMatcher hashedCredentialsMatcher = new HashedCredentialsMatcher();
//        hashedCredentialsMatcher.setHashAlgorithmName("md5");//MD5算法;
//        hashedCredentialsMatcher.setHashIterations(2);//散列的次数
//        return hashedCredentialsMatcher;

//2:或:
        SimpleCredentialsMatcher simpleCredentialsMatcher=  new SimpleCredentialsMatcher(){
            @Override
            public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
//
//                UsernamePasswordToken upToken = (UsernamePasswordToken) token;
//                //将用户在页面输入的原始密码加密   param : 1.用户页面填写的密码, 加密的盐
//                //String pwd = Encrypt.md5(upToken.getPassword().toString(), upToken.getUsername());
//                String pwd = md5(new String(upToken.getPassword()), upToken.getUsername());
//                //3取出数据库加密的密码
//                Object dbPwd = info.getCredentials();  //从AuthRealm doGetAuthenticationInfo传入的密码,数据库查询的密码.
//
//                return  this.equals(pwd,dbPwd);
                return true;
            }
        };

        return simpleCredentialsMatcher;
    }
 
开发者ID:mmdsyl,项目名称:BLOG-Microservice,代码行数:36,代码来源:ShiroConfiguration.java


示例3: AuthenticatingRealm

import org.apache.shiro.authc.credential.SimpleCredentialsMatcher; //导入依赖的package包/类
public AuthenticatingRealm() {
    this(null, new SimpleCredentialsMatcher());
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:4,代码来源:AuthenticatingRealm.java


示例4: ShiroRealm

import org.apache.shiro.authc.credential.SimpleCredentialsMatcher; //导入依赖的package包/类
public ShiroRealm() {
    super( new MemoryConstrainedCacheManager(), new SimpleCredentialsMatcher() );
}
 
开发者ID:apache,项目名称:usergrid,代码行数:4,代码来源:ShiroRealm.java



注:本文中的org.apache.shiro.authc.credential.SimpleCredentialsMatcher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WebDriverRunner类代码示例发布时间:2022-05-22
下一篇:
Java ContentType类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap