code: public void reset(SecurityRealm securityRealm) throws ServletException {
          if (securityRealm != null) {
              SecurityRealm.SecurityComponents sc = securityRealm.getSecurityComponents();
              AUTHENTICATION_MANAGER.setDelegate(sc.manager);
              USER_DETAILS_SERVICE_PROXY.setDelegate(sc.userDetails);
              REMEMBER_ME_SERVICES_PROXY.setDelegate(sc.rememberMe);
              // make sure this.filter is always a valid filter.
              Filter oldf = this.filter;
              Filter newf = securityRealm.createFilter(this.filterConfig);
              newf.init(this.filterConfig);
              this.filter = newf;
              if(oldf!=null)
                  oldf.destroy();
          } else {
              // no security related filter needed.
              AUTHENTICATION_MANAGER.setDelegate(null);
              USER_DETAILS_SERVICE_PROXY.setDelegate(null);
              REMEMBER_ME_SERVICES_PROXY.setDelegate(null);
              filter = null;
          }
      }
docs: Reset the proxies and filter for a change in {@link SecurityRealm}.