1 Reply Latest reply on Mar 26, 2009 5:26 PM by kukeltje.ronald.jbpm.org

    Can't disabled authentication-filter in Java

    pdepaepe
      Hello,

      I need to activate the http authentication with a boolean from my System.getProperty().
      So i extended the AbstractFilter. I can easily reproduce

      <web:authentication-filter url-pattern="*.seam" auth-type="basic"/>

      But not

      <web:authentication-filter url-pattern="*.seam" auth-type="basic" disabled="true"/>

      Wich is working well from components.xml, but not in java, with the folowing code (It asks me always http auth, whatever my property).

      @Startup
      @Scope(ScopeType.APPLICATION)
      @Name("org.jboss.seam.web.authenticationFilter")
      @BypassInterceptors
      @Filter(within="org.jboss.seam.web.exceptionFilter")
      public class ProjectAuthenticationFilter extends AbstractFilter {

              private AuthenticationFilter authenticationFilter;

              @Create
              public void init() throws ServletException {
                      authenticationFilter = new AuthenticationFilter();
                      authenticationFilter.setAuthType("basic");
                      authenticationFilter.setRealm("Project");
                      authenticationFilter.setUrlPattern("*.seam");
                      if(System.getProperty("project.Authentication").compareTo("HTTP") != 0){
                              authenticationFilter.setDisabled(true);
                      }
              }

              public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
                      authenticationFilter.doFilter(servletRequest, servletResponse, filterChain);
              }

      }


      Thank you for your help.
        • 1. Re: Can't disabled authentication-filter in Java
          kukeltje.ronald.jbpm.org

          why not do something like



                  public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
                        if(System.getProperty("project.Authentication").compareTo("HTTP") == 0){
                            authenticationFilter.doFilter(servletRequest, servletResponse, filterChain);
                        }
                  }