[ 
https://issues.apache.org/jira/browse/SHIRO-413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13565537#comment-13565537
 ] 

Dan Rollo commented on SHIRO-413:
---------------------------------

FWIW, after digging into this some more, it appears the problem of not calling 
init() on Initializable's is NOT a problem for Realm subclasses, but it IS a 
problem for Filter subclasses.

For example, 
org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(Ini 
ini, Ini.Section mainSection) ensure Realms are init'ed by the call to 
IniSecurityManagerFactory.initRealms(securityManager) - which invokes 
Initializable.init().

However, Filter subclasses do not get init'ed. Only the 
org.apache.shiro.web.servlet.AbstractFilter.init(FilterConfig filterConfig) is 
called by a web server class (tomcat6: 
org.apache.catalina.core.ApplicationFilterConfig().getFilter():295). This call 
to AbstractFilter.init(FilterConfig filterConfig) results in a call to an 
init() method (however, this init() method is NOT an impl of Initializable, it 
is: AbstractShiroFilter.init() throws Exception). 

Also, only the single "uber" ShiroFilter instance gets this call from 
....catalina.core.ApplicationFilterConfig().getFilter() (no Filter subclasses 
get this call).


All this said, I'm not at all certain my Filter implementation is incorrect 
(and maybe much of it's logic should either be moved to a Realm OR my filter 
should make use of the Tomcat Filter delegate redesign I saw mentioned 
elsewhere -> a design change that would make it easier to reuse existing Tomcat 
filters as it - which is basically exactly what I am trying to do).


                
> init() method is not called on class that implements 
> org.apache.shiro.util.Initializable
> ----------------------------------------------------------------------------------------
>
>                 Key: SHIRO-413
>                 URL: https://issues.apache.org/jira/browse/SHIRO-413
>             Project: Shiro
>          Issue Type: Bug
>          Components: Configuration
>    Affects Versions: 1.2.1
>            Reporter: Dan Rollo
>            Priority: Critical
>
> Classes configured in shiro.ini that implement the "Initializable" interface 
> should automatically have their "init()" methods called. It appears this call 
> is not always occurring. Example below:
> public class WaffleNegotiateAuthFilter extends BasicHttpAuthenticationFilter
>                                        implements Initializable
> {
> ...
>     private final NegotiateSecurityFilter negotiateFilter;
>     public WaffleNegotiateAuthFilter() {
>         negotiateFilter = new NegotiateSecurityFilter();
>     }
>     @Override
>     protected void onFilterConfigSet() throws Exception {
>         negotiateFilter.init(getFilterConfig());
>     }
>     /**
>      * Initializes this object.
>      *
>      * @throws org.apache.shiro.ShiroException
>      *          if an exception occurs during initialization.
>      */
>     public void init() throws ShiroException {
>         try {
>             super.init(getFilterConfig());
>         } catch (ServletException e) {
>             throw new ShiroException(e);
>         }
>     }
> ...
> I still do not see the init() method being called.
> See this thread for more details: 
> http://shiro-user.582556.n2.nabble.com/AuthenticatingFilter-lifecycle-when-used-in-urls-td7578146.html

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to