0

i have 2 links login1 and login2 when i click login1 that should avoid filter node which has login filter in xml, that means it should not read <filter-name>LoginFilter</filter-name> i have googled got some examples how to modify xml using java but is there a way which can check condition without changing xml file

here is my xml file:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4"
        xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >

        <display-name>OIOSAML-J</display-name>
        <env-entry>
            <env-entry-name>oiosaml-j.home</env-entry-name>
            <env-entry-type>java.lang.String</env-entry-type>
            <env-entry-value>c:\oiosaml-config</env-entry-value>
        </env-entry>

        <!--<env-entry>
            <env-entry-name>oiosaml-j.name</env-entry-name>
            <env-entry-type>java.lang.String</env-entry-type>
            <env-entry-value>demo</env-entry-value>
        </env-entry>-->

        <listener>
            <listener-class>dk.itst.oiosaml.sp.service.session.SessionDestroyListener</listener-class>
        </listener>  

        <servlet>
            <servlet-name>SAMLDispatcherServlet</servlet-name>
            <servlet-class>
                dk.itst.oiosaml.sp.service.DispatcherServlet
            </servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>

        <servlet-mapping>
            <servlet-name>SAMLDispatcherServlet</servlet-name>
            <url-pattern>/saml/*</url-pattern>
        </servlet-mapping>
    <filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
  </filter>
        <filter>
            <filter-name>LoginFilter</filter-name>
            <filter-class>dk.itst.oiosaml.sp.service.SPFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>LoginFilter</filter-name>
            <url-pattern>/sp/*</url-pattern>
        </filter-mapping>
<filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
  </filter-mapping>
        <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
    </web-app>

here is my view code:

<html xmlns="http://www.w3.org/1999/xhtml"  
        xmlns:h="http://java.sun.com/jsf/html"  
        xmlns:f="http://java.sun.com/jsf/core"  
        xmlns:p="http://primefaces.org/ui"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:c="http://java.sun.com/jsp/jstl/core"
        >  
   <h:body>
       <div><a href="sp/">Login1</a></div>|<div><a href="sp/">login2</a></div>
    </h:body>
  </html>
3bu1
  • 977
  • 12
  • 30

1 Answers1

0

The LoginFilter will be triggered on every request going to any target under /sp/. If you want a webpage does not trigger this Filter you must make sure that the page is not on a path that will trigger the filter. May be have a structure like this.

/
/sp/
/public/

and put the login page in public

Stefan Rasmusson
  • 5,445
  • 3
  • 21
  • 48
  • that means i should make another copy of the /sp/* – 3bu1 Dec 17 '14 at 10:43
  • Nope, leave the filtermapping as it is. Let the login2 page be accessible on /public/login2 – Stefan Rasmusson Dec 17 '14 at 13:17
  • after logging in is successfully viewer should be able to access files in /sp/, which will not happen because of filter.how can i access sp without logging in into login1..? – 3bu1 Dec 17 '14 at 13:26
  • That statement does not make much sense to me. Users should be able to access pages under /sp/ but in the next sentence you say that you want users to access it without logging in. You have to be more clear in what you want to do – Stefan Rasmusson Dec 17 '14 at 13:33
  • the thing is login1 is a local login which is controlled by us, login2 is a saml one signon (we are using oiosaml).if a viewer want to login using login1 still he should be able to access /sp/, but due to filter /sp/ is un accessable. – 3bu1 Dec 18 '14 at 07:51
  • 1
    Ok what I suggest in that case is that you build your own filter. This filter checks if the user is logged in using login1. If it is the request is let trough. if not the filter passes the request to the login2 filter – Stefan Rasmusson Dec 18 '14 at 12:29