zoukankan      html  css  js  c++  java
  • 给AuthenticatingRealm设置CredentialsMatcher

    1:通过查看AuthenticatingRealm的构造方法,看到第一,二个构造函数中没有传入CredentialsMatcher,则AuthenticatingRealm自己创建了SimpleCredentialsMatcher。即默认情况下AuthenticatingRealm的CredentialsMatcher 是SimpleCredentialsMatcher。

    2:无论开发者调用了哪个构造函数,最终都会调用第四个构造函数,并将matcher通过第175行代码中的setCredentialsMatcher设置进去。

    3:由于CredentialsMatcher有很多实现类,如果开发者想给AuthenticatingRealm设置其他的matcher,可以通过在子类中调用父类构造函数的方式来改变AuthenticatingRealm中的matcher。在创建子类对象时,传入一个HashedCredentialsMatcher的对象。

    4:由于AuthenticatingRealm中setCredentialsMatcher方法是public的,所以会被子类继承,开发者也可以通过调用子类的setCredentialsMatcher方法来设置matcher。

    这样以来,开发者就可以通过3或4步骤来改变CredentialsMatcher。

  • 相关阅读:
    团队项目-Beta冲刺(第一周)
    个人第4次作业—Alpha项目测试
    团队项目——Alpha发布2
    优课堂考勤系统——Alpha发布1
    优课堂—系统设计
    优课堂—需求分析
    thrift学习笔记
    APP分享
    ActionBar
    ListView添加headview
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13302482.html
Copyright © 2011-2022 走看看