• Shiro Authenticator认证器


    Authenticating Subjects 认证用户

      认证步骤

        认证分三步:1、收集用户(Subject)基本信息(principal)和认证信息(credential);

              2、提交用户(Subject)基本信息(principal)和认证信息(credential);

              3、认证结果信息处理。

        

      Step One:   

    UsernamePasswordToken token = new UsernamePasswordToken("username", "password");
    token.setRememberMe(true);

      Step Two:

    Subject currentUser = SecurityUtils.getSubject();
    currentUser.login(token);

      Step Three:

    try {
                    currentUser.login(token);
                } catch (UnknownAccountException e) {
                    // TODO 用户不存在
                } catch (IncorrectCredentialsException e) {
                    // TODO 用户名或密码不正确
                    // For example, this exception might be thrown 
                    //if a user's password is "secret" and "secrets" was entered by mistake
                } catch (LockedAccountException e) {
                    // TODO 用户被锁定不能登录
                } catch (AuthenticationException e) {
                    // TODO 认证过程中意想不到的异常
                }

    AuthenticationStrategy 认证序列

      Shiro SecurityManager实现默认使用ModularRealmAuthenticator实例,为应用程序配置两个或更多领域时,ModularRealmAuthenticator依赖于内部AuthenticationStrategy组件来确定认证尝试成功或失败的条件。 

      Shiro有3个具体AuthenticationStrategy实现:1、AtLeastOneSuccessfulStrategy(任意一个Realm认证成功则成功),默认使用该实现

                          2、FirstSuccessfulStrategy(第一个Realm认证成功)

                          3、AllSuccessfulStrategy(全部Realm认证成功)

  • 相关阅读:
    Hpuoj1039--【C语言训练】角谷猜想
    hpuoj--1093: 回文数(一)
    Zoj1628--Diamond(Dfs《暴力》)
    Poj1995--Raising Modulo Numbers(快速幂)
    杭电5137--How Many Maos Does the Guanxi Worth(Spfa+暴力枚举)
    杭电1166--敌兵布阵(线段树 | 树状数组)

    南阳5--Binary String Matching(Kmp)
    CGAL
    vs c++默认路径
  • 原文地址:https://www.cnblogs.com/BINGJJFLY/p/8967371.html
Copyright © 2020-2023  润新知