You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Madhav Bhargava <Ma...@infosys.com> on 2010/01/11 21:26:11 UTC
Spring FilterSecurityInterceptor not been called for myfaces
forwards
Hi All,
I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring security -2.0.5, WAS 6.0 (app server)
I have configured spring security for my JSF application along with SiteMinder as an external authentication mechanism. It works fine till a forward happens from within myfaces.
Here is my spring servlet filter chain declaration:
<filter>
<description>
Spring delegating filter which will initiate the spring
security filter chain
</description>
<display-name>springSecurityFilterChain</display-name>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
And in my spring application context I have followed the advice from spring forums and done necessary settings:
Excerpt is:
<security:http
entry-point-ref="preAuthenticatedProcessingFilterEntryPoint" once-per-request="false">
<security:intercept-url pattern="/index.jsp" filters="none" />
<security:intercept-url pattern="/login.jsp" filters="none" />
<security:intercept-url pattern="/authenticationservlet" filters="none"/>
<security:intercept-url pattern="**/jsp/common/**" filters="none"/>
<security:intercept-url pattern="/**/css/**" filters="none"/>
<security:intercept-url pattern="/**/*.js" filters="none"/>
<security:intercept-url pattern="/images/**" filters="none"/>
<security:intercept-url pattern="/**/secure/**" access="ROLE_USER" />
<security:intercept-url pattern="/**/operations/**" access="ROLE_OPERATIONS"/>
<security:intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
</security:http>
Now when I forward a request from index.jsp to login.jsp then the spring filters are called with the login.jsp URL even though the browser shows the old URL.
However when from within an action method a navigation case is handled then it is not intercepted by the spring filters at all. However if I give a <redirect/> then it is properly intercepted with the correct URL as expected.
What can be the reason?
Regards,
Madhav
RE: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Madhav Bhargava <Ma...@infosys.com>.
No problems Jakob. I really appreciate the time you have already spent.
If I come up with a solution then I will post it on this forum.
Regards,
Madhav
>From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On Behalf Of Jakob Korherr
>Sent: Monday, January 18, 2010 4:42 PM
>
>I'm really sorry, but I can't figure out the problem. Maybe anyone else
>could take a look at this log...
>
>
>2010/1/18 Madhav Bhargava <Ma...@infosys.com>
>
> Attached is the log file. Look for lined which have (URLInterceptor.java)
> This will give you the URL that has been intercepted by the custom filter
> which sits before any spring filter. Right now all it does is print out the
> URL that it intercepted.
>
> To refresh your memory here is the flow again in brief:
>
> 1. *http://localhost:9080/contextRoot/*<http://localhost:9080/contextRoot/>is invoked and it internally it redirects it to the welcome page
> (/index.jsp)
> 2. index.jsp does a <jsp:forward> to /login.jsp
> 3. User enters the credentials and as of now since we do not have
> Siteminder for authentication the action attribute points to
> /jsp/secure/hprelanding.jspx (first JSF page) so a redirect is send.
> 4. On hprelanding page an automatic click happens on a hidden command
> button which calls a backing bean action method. Since I am using icefaces
> the click of a button request is sent using the URL: *
> http://localhost:9080/HPRE/block/**send-receive-updates*<http://localhost:9080/HPRE/block/send-receive-updates>
> 5. You will find many other URL's in between which is all caused by
> icefaces.
> 6. The action method will do nothing but forward the request to
> operationlanding.jspx page which should only be visible to users who have
> ROLE_OPERATIONS however that URL never comes up. Instead the next URL of
> importance is again hprelanding.jspx one.
>
> Regards,
> Madhav
>
> >From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com<se...@gmail.com>]
> On Behalf Of Jakob Korherr
> >Sent: Monday, January 18, 2010 3:45 PM
> >
> >It would be great to see some logs!
> >
> >2010/1/18 Madhav Bhargava <Ma...@infosys.com>
> >
> > Sorry for the confusion. There was some problem with log4j configuration
> on
> > WAS 6 and therefore I was not able to generate DEBUG logs out of spring
> > security. The issue turned out to be a ws-commons-logging.jar. Anyways
> back
> > to the issue:
> >
> > In the log it shows that the filter is actually getting called but with
> an
> > older URL. So the spring security filter configuration is fine but now
> it’s
> > the problem only with JSF. The <jsp:forward> thing works fine as I am
> doing
> > a forward from index.jsp to login.jsp
> >
> > If you want the DEBUG logs then I can provide them.
> >
> > Regards,
> > Madhav
> >
> > >From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com<se...@gmail.com>]
> On
> > Behalf Of Jakob Korherr
> > >
> > >»The spring security filters are not invoked at all when a JSF forward
> > >happens.«
> > >
> > >Then the issue has to be a misconfiguration problem, because a normal
> > filter
> > >is called for the JSF forward (I tested that). However, I don't know
> > spring
> > >security filters well enough to point out what the real problem is.
> sorry!
> > >
> > >
> > >2010/1/18 Madhav Bhargava <Ma...@infosys.com>
> > >
> > > Sorry for the delay in response. The spring security filters are not
> > > invoked at all when a JSF forward happens.
> > > What we have done as a workaround is that login page has now been made
> a
> > > simple non JSF JSP. We redirect from login page to another page which
> is
> > > just a dummy page. This redirect causes spring security to set up
> > > SecurityContext properly. So we are able to use spring security
> component
> > > level authorizations properly. However the URL level authorization is
> > still
> > > an issue.
> > >
> > > Regards,
> > > Madhav
> > >
> > > >From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com<se...@gmail.com>]
> On
> > > Behalf Of Jakob Korherr
> > > >
> > > Can you sort out if the filter itself is not called or if the filter
> > > behaves
> > > >wrong?
> > > >
> > > >
> > > >2010/1/13 Madhav Bhargava <Ma...@infosys.com>
> > > >
> > > > Yeah this is the place.
> > > > Back to the problem. I still cannot come up with a workaround :(
> > > >
> > > > From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com<se...@gmail.com>]
> On
> > > > Behalf Of Jakob Korherr
> > > > >The "magic" happens in JspViewHandlerImpl's renderView() method:
> > > > >
> > > > >public void renderView(FacesContext facesContext, UIViewRoot
> > > viewToRender)
> > > > > throws IOException, FacesException {
> > > > > externalContext.dispatch(viewId);
> > > > > ....
> > > > >
> > > > > }
> > > > >
> > > > >Regards,
> > > > >Jakob
> > > > >
> > > > >2010/1/13 Madhav Bhargava <Ma...@infosys.com>
> > > > >
> > > > > Yes, I am not using facelets.
> > > > > I had a look at the NavigationHandlerImpl and here is the excerpt
> > from
> > > > it:
> > > > >
> > > > > Method: handleNavigation
> > > > >
> > > > > if (navigationCase != null)
> > > > > {
> > > > > if (log.isTraceEnabled())
> > > > > {
> > > > > log.trace("handleNavigation fromAction=" +
> fromAction
> > +
> > > "
> > > > > outcome=" + outcome +
> > > > > " toViewId =" +
> navigationCase.getToViewId()
> > +
> > > > > " redirect=" +
> navigationCase.isRedirect());
> > > > > }
> > > > > if (navigationCase.isRedirect() &&
> > > > > (!PortletUtil.isPortletRequest(facesContext)))
> > > > > { // Spec section 7.4.2 says "redirects not possible" in
> > > this
> > > > > case for portlets
> > > > > ExternalContext externalContext =
> > > > > facesContext.getExternalContext();
> > > > > ViewHandler viewHandler =
> > > > > facesContext.getApplication().getViewHandler();
> > > > > String redirectPath =
> > > > viewHandler.getActionURL(facesContext,
> > > > > navigationCase.getToViewId());
> > > > >
> > > > > try
> > > > > {
> > > > >
> > > > >
> > >
> externalContext.redirect(externalContext.encodeActionURL(redirectPath));
> > > > > }
> > > > > catch (IOException e)
> > > > > {
> > > > > throw new FacesException(e.getMessage(), e);
> > > > > }
> > > > > }
> > > > > else
> > > > > {
> > > > > ViewHandler viewHandler =
> > > > > facesContext.getApplication().getViewHandler();
> > > > > //create new view
> > > > > String newViewId = navigationCase.getToViewId();
> > > > > UIViewRoot viewRoot = null;
> > > > > if (isPartialStateSavingOn(facesContext)) {
> > > > > viewRoot =
> > > > > viewHandler.restoreView(facesContext,newViewId);
> > > > > } else {
> > > > > viewRoot = viewHandler.createView(facesContext,
> > > > > newViewId);
> > > > > }
> > > > > facesContext.setViewRoot(viewRoot);
> > > > > facesContext.renderResponse();
> > > > > }
> > > > >
> > > > > In the above code, redirect happens properly however for a forward
> > > there
> > > > is
> > > > > no RequestDispatcher.forward or ExternalContext.dispatch called. So
> I
> > > do
> > > > not
> > > > > know where a forward happens.
> > > > >
> > > > > Regards,
> > > > > Madhav
> > > > >
> > > > > From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com<se...@gmail.com>
> ]
> > On
> > > > > Behalf Of Jakob Korherr
> > > > > >Hi Tomasz,
> > > > > >
> > > > > >That's all correct! However, I don't think he is using Facelets,
> > > because
> > > > > he
> > > > > >mentioned JSP-pages...
> > > > > >
> > > > > >Regards,
> > > > > >Jakob
> > > > > >
> > > > > >2010/1/12 Tomasz Pasierb <to...@poczta.fm>
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > as I understand you use a commandButton and as a result a
> different
> > > > page
> > > > > (a
> > > > > > secured one) is rendered but spring security does not seem to
> > > intercept
> > > > > the
> > > > > > url, is that right?
> > > > > >
> > > > > > If so and if the solution used by you uses Facelets then this may
> > be
> > > > the
> > > > > > problem.
> > > > > > When using Facelets as opposed to "pure" (older) jsf+jsp approach
> > > there
> > > > > is
> > > > > > no forward when a new view is rendered that is a result of a
> > > navigation
> > > > > case
> > > > > > forward. I've been investigating this recently. When JSP view
> > handler
> > > > is
> > > > > > used it checks which view should be rendered next and does a
> > forward
> > > to
> > > > > this
> > > > > > new view which spring security can intercept. The Facelet view
> > > handler
> > > > > > however seems to load the view (xhtml) and render it without
> making
> > > the
> > > > > > actual forward. As a result no interception can happen and
> usually
> > it
> > > > is
> > > > > > triggered with the next request.
> > > > > > You need to either use redirects or make GET requests to
> logically
> > > > > separate
> > > > > > views - I know this is not natural with jsf versions prior to
> 2.0,
> > > but
> > > > > this
> > > > > > new spec seems to change everything :-) - use can easily generate
> > GET
> > > > > > requests with the new version.
> > > > > >
> > > > > > Hope this helps ;)
> > > > > >
> > > > > > Regards,
> > > > > > Tom Pasierb
> > > > > >
> > > > > > Madhav Bhargava pisze:
> > > > > >
> > > > > > Hi All,
> > > > > >>
> > > > > >> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring
> > > security
> > > > > >> -2.0.5, WAS 6.0 (app server)
> > > > > >>
> > > > > >> I have configured spring security for my JSF application along
> > with
> > > > > >> SiteMinder as an external authentication mechanism. It works
> fine
> > > till
> > > > a
> > > > > >> forward happens from within myfaces.
> > > > > >>
> > > > > >> Here is my spring servlet filter chain declaration:
> > > > > >> <filter>
> > > > > >> <description>
> > > > > >> Spring delegating filter which
> will
> > > > > >> initiate the spring
> > > > > >> security filter chain
> > > > > >> </description>
> > > > > >>
> > > <display-name>springSecurityFilterChain</display-name>
> > > > > >>
> > <filter-name>springSecurityFilterChain</filter-name>
> > > > > >> <filter-class>
> > > > > >>
> > > > > >> org.springframework.web.filter.DelegatingFilterProxy
> > > > > >> </filter-class>
> > > > > >> </filter>
> > > > > >>
> > > > > >> <filter-mapping>
> > > > > >>
> > <filter-name>springSecurityFilterChain</filter-name>
> > > > > >> <url-pattern>/*</url-pattern>
> > > > > >> <dispatcher>FORWARD</dispatcher>
> > > > > >> <dispatcher>REQUEST</dispatcher>
> > > > > >> </filter-mapping>
> > > > > >>
> > > > > >> And in my spring application context I have followed the advice
> > from
> > > > > >> spring forums and done necessary settings:
> > > > > >> Excerpt is:
> > > > > >>
> > > > > >> <security:http
> > > > > >>
> > > > > >> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint"
> > > > > >> once-per-request="false">
> > > > > >> <security:intercept-url pattern="/index.jsp"
> > > > > filters="none"
> > > > > >> />
> > > > > >> <security:intercept-url pattern="/login.jsp"
> > > > > filters="none"
> > > > > >> />
> > > > > >> <security:intercept-url
> > > > pattern="/authenticationservlet"
> > > > > >> filters="none"/>
> > > > > >> <security:intercept-url
> pattern="**/jsp/common/**"
> > > > > >> filters="none"/>
> > > > > >> <security:intercept-url pattern="/**/css/**"
> > > > > >> filters="none"/>
> > > > > >> <security:intercept-url pattern="/**/*.js"
> > > > > filters="none"/>
> > > > > >> <security:intercept-url pattern="/images/**"
> > > > > >> filters="none"/>
> > > > > >> <security:intercept-url pattern="/**/secure/**"
> > > > > >> access="ROLE_USER" />
> > > > > >> <security:intercept-url
> pattern="/**/operations/**"
> > > > > >> access="ROLE_OPERATIONS"/>
> > > > > >> <security:intercept-url pattern="/**"
> > > > > >> access="IS_AUTHENTICATED_ANONYMOUSLY" />
> > > > > >> </security:http>
> > > > > >>
> > > > > >> Now when I forward a request from index.jsp to login.jsp then
> the
> > > > spring
> > > > > >> filters are called with the login.jsp URL even though the
> browser
> > > > shows
> > > > > the
> > > > > >> old URL.
> > > > > >>
> > > > > >> However when from within an action method a navigation case is
> > > handled
> > > > > >> then it is not intercepted by the spring filters at all. However
> > if
> > > I
> > > > > give a
> > > > > >> <redirect/> then it is properly intercepted with the correct URL
> > as
> > > > > >> expected.
> > > > > >>
> > > > > >> What can be the reason?
> > > > > >>
> > > > > >> Regards,
> > > > > >> Madhav
> > > > > >>
> > > > > >>
> > > > > >>
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> > **************** CAUTION - Disclaimer *****************
> > This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
> > solely
> > for the use of the addressee(s). If you are not the intended recipient,
> > please
> > notify the sender by e-mail and delete the original message. Further, you
> > are not
> > to copy, disclose, or distribute this e-mail or its contents to any other
> > person and
> > any such actions are unlawful. This e-mail may contain viruses. Infosys
> has
> > taken
> > every reasonable precaution to minimize this risk, but is not liable for
> > any damage
> > you may sustain as a result of any virus in this e-mail. You should carry
> > out your
> > own virus checks before opening the e-mail or attachment. Infosys
> reserves
> > the
> > right to monitor and review the content of all messages sent to or from
> > this e-mail
> > address. Messages sent to or from this e-mail address may be stored on
> the
> > Infosys e-mail system.
> > ***INFOSYS******** End of Disclaimer ********INFOSYS***
> >
>
>
Re: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Jakob Korherr <ja...@gmail.com>.
I'm really sorry, but I can't figure out the problem. Maybe anyone else
could take a look at this log...
2010/1/18 Madhav Bhargava <Ma...@infosys.com>
> Attached is the log file. Look for lined which have (URLInterceptor.java)
> This will give you the URL that has been intercepted by the custom filter
> which sits before any spring filter. Right now all it does is print out the
> URL that it intercepted.
>
> To refresh your memory here is the flow again in brief:
>
> 1. *http://localhost:9080/contextRoot/*<http://localhost:9080/contextRoot/>is invoked and it internally it redirects it to the welcome page
> (/index.jsp)
> 2. index.jsp does a <jsp:forward> to /login.jsp
> 3. User enters the credentials and as of now since we do not have
> Siteminder for authentication the action attribute points to
> /jsp/secure/hprelanding.jspx (first JSF page) so a redirect is send.
> 4. On hprelanding page an automatic click happens on a hidden command
> button which calls a backing bean action method. Since I am using icefaces
> the click of a button request is sent using the URL: *
> http://localhost:9080/HPRE/block/**send-receive-updates*<http://localhost:9080/HPRE/block/send-receive-updates>
> 5. You will find many other URL's in between which is all caused by
> icefaces.
> 6. The action method will do nothing but forward the request to
> operationlanding.jspx page which should only be visible to users who have
> ROLE_OPERATIONS however that URL never comes up. Instead the next URL of
> importance is again hprelanding.jspx one.
>
> Regards,
> Madhav
>
> >From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com<se...@gmail.com>]
> On Behalf Of Jakob Korherr
> >Sent: Monday, January 18, 2010 3:45 PM
> >
> >It would be great to see some logs!
> >
> >2010/1/18 Madhav Bhargava <Ma...@infosys.com>
> >
> > Sorry for the confusion. There was some problem with log4j configuration
> on
> > WAS 6 and therefore I was not able to generate DEBUG logs out of spring
> > security. The issue turned out to be a ws-commons-logging.jar. Anyways
> back
> > to the issue:
> >
> > In the log it shows that the filter is actually getting called but with
> an
> > older URL. So the spring security filter configuration is fine but now
> it’s
> > the problem only with JSF. The <jsp:forward> thing works fine as I am
> doing
> > a forward from index.jsp to login.jsp
> >
> > If you want the DEBUG logs then I can provide them.
> >
> > Regards,
> > Madhav
> >
> > >From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com<se...@gmail.com>]
> On
> > Behalf Of Jakob Korherr
> > >
> > >»The spring security filters are not invoked at all when a JSF forward
> > >happens.«
> > >
> > >Then the issue has to be a misconfiguration problem, because a normal
> > filter
> > >is called for the JSF forward (I tested that). However, I don't know
> > spring
> > >security filters well enough to point out what the real problem is.
> sorry!
> > >
> > >
> > >2010/1/18 Madhav Bhargava <Ma...@infosys.com>
> > >
> > > Sorry for the delay in response. The spring security filters are not
> > > invoked at all when a JSF forward happens.
> > > What we have done as a workaround is that login page has now been made
> a
> > > simple non JSF JSP. We redirect from login page to another page which
> is
> > > just a dummy page. This redirect causes spring security to set up
> > > SecurityContext properly. So we are able to use spring security
> component
> > > level authorizations properly. However the URL level authorization is
> > still
> > > an issue.
> > >
> > > Regards,
> > > Madhav
> > >
> > > >From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com<se...@gmail.com>]
> On
> > > Behalf Of Jakob Korherr
> > > >
> > > Can you sort out if the filter itself is not called or if the filter
> > > behaves
> > > >wrong?
> > > >
> > > >
> > > >2010/1/13 Madhav Bhargava <Ma...@infosys.com>
> > > >
> > > > Yeah this is the place.
> > > > Back to the problem. I still cannot come up with a workaround :(
> > > >
> > > > From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com<se...@gmail.com>]
> On
> > > > Behalf Of Jakob Korherr
> > > > >The "magic" happens in JspViewHandlerImpl's renderView() method:
> > > > >
> > > > >public void renderView(FacesContext facesContext, UIViewRoot
> > > viewToRender)
> > > > > throws IOException, FacesException {
> > > > > externalContext.dispatch(viewId);
> > > > > ....
> > > > >
> > > > > }
> > > > >
> > > > >Regards,
> > > > >Jakob
> > > > >
> > > > >2010/1/13 Madhav Bhargava <Ma...@infosys.com>
> > > > >
> > > > > Yes, I am not using facelets.
> > > > > I had a look at the NavigationHandlerImpl and here is the excerpt
> > from
> > > > it:
> > > > >
> > > > > Method: handleNavigation
> > > > >
> > > > > if (navigationCase != null)
> > > > > {
> > > > > if (log.isTraceEnabled())
> > > > > {
> > > > > log.trace("handleNavigation fromAction=" +
> fromAction
> > +
> > > "
> > > > > outcome=" + outcome +
> > > > > " toViewId =" +
> navigationCase.getToViewId()
> > +
> > > > > " redirect=" +
> navigationCase.isRedirect());
> > > > > }
> > > > > if (navigationCase.isRedirect() &&
> > > > > (!PortletUtil.isPortletRequest(facesContext)))
> > > > > { // Spec section 7.4.2 says "redirects not possible" in
> > > this
> > > > > case for portlets
> > > > > ExternalContext externalContext =
> > > > > facesContext.getExternalContext();
> > > > > ViewHandler viewHandler =
> > > > > facesContext.getApplication().getViewHandler();
> > > > > String redirectPath =
> > > > viewHandler.getActionURL(facesContext,
> > > > > navigationCase.getToViewId());
> > > > >
> > > > > try
> > > > > {
> > > > >
> > > > >
> > >
> externalContext.redirect(externalContext.encodeActionURL(redirectPath));
> > > > > }
> > > > > catch (IOException e)
> > > > > {
> > > > > throw new FacesException(e.getMessage(), e);
> > > > > }
> > > > > }
> > > > > else
> > > > > {
> > > > > ViewHandler viewHandler =
> > > > > facesContext.getApplication().getViewHandler();
> > > > > //create new view
> > > > > String newViewId = navigationCase.getToViewId();
> > > > > UIViewRoot viewRoot = null;
> > > > > if (isPartialStateSavingOn(facesContext)) {
> > > > > viewRoot =
> > > > > viewHandler.restoreView(facesContext,newViewId);
> > > > > } else {
> > > > > viewRoot = viewHandler.createView(facesContext,
> > > > > newViewId);
> > > > > }
> > > > > facesContext.setViewRoot(viewRoot);
> > > > > facesContext.renderResponse();
> > > > > }
> > > > >
> > > > > In the above code, redirect happens properly however for a forward
> > > there
> > > > is
> > > > > no RequestDispatcher.forward or ExternalContext.dispatch called. So
> I
> > > do
> > > > not
> > > > > know where a forward happens.
> > > > >
> > > > > Regards,
> > > > > Madhav
> > > > >
> > > > > From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com<se...@gmail.com>
> ]
> > On
> > > > > Behalf Of Jakob Korherr
> > > > > >Hi Tomasz,
> > > > > >
> > > > > >That's all correct! However, I don't think he is using Facelets,
> > > because
> > > > > he
> > > > > >mentioned JSP-pages...
> > > > > >
> > > > > >Regards,
> > > > > >Jakob
> > > > > >
> > > > > >2010/1/12 Tomasz Pasierb <to...@poczta.fm>
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > as I understand you use a commandButton and as a result a
> different
> > > > page
> > > > > (a
> > > > > > secured one) is rendered but spring security does not seem to
> > > intercept
> > > > > the
> > > > > > url, is that right?
> > > > > >
> > > > > > If so and if the solution used by you uses Facelets then this may
> > be
> > > > the
> > > > > > problem.
> > > > > > When using Facelets as opposed to "pure" (older) jsf+jsp approach
> > > there
> > > > > is
> > > > > > no forward when a new view is rendered that is a result of a
> > > navigation
> > > > > case
> > > > > > forward. I've been investigating this recently. When JSP view
> > handler
> > > > is
> > > > > > used it checks which view should be rendered next and does a
> > forward
> > > to
> > > > > this
> > > > > > new view which spring security can intercept. The Facelet view
> > > handler
> > > > > > however seems to load the view (xhtml) and render it without
> making
> > > the
> > > > > > actual forward. As a result no interception can happen and
> usually
> > it
> > > > is
> > > > > > triggered with the next request.
> > > > > > You need to either use redirects or make GET requests to
> logically
> > > > > separate
> > > > > > views - I know this is not natural with jsf versions prior to
> 2.0,
> > > but
> > > > > this
> > > > > > new spec seems to change everything :-) - use can easily generate
> > GET
> > > > > > requests with the new version.
> > > > > >
> > > > > > Hope this helps ;)
> > > > > >
> > > > > > Regards,
> > > > > > Tom Pasierb
> > > > > >
> > > > > > Madhav Bhargava pisze:
> > > > > >
> > > > > > Hi All,
> > > > > >>
> > > > > >> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring
> > > security
> > > > > >> -2.0.5, WAS 6.0 (app server)
> > > > > >>
> > > > > >> I have configured spring security for my JSF application along
> > with
> > > > > >> SiteMinder as an external authentication mechanism. It works
> fine
> > > till
> > > > a
> > > > > >> forward happens from within myfaces.
> > > > > >>
> > > > > >> Here is my spring servlet filter chain declaration:
> > > > > >> <filter>
> > > > > >> <description>
> > > > > >> Spring delegating filter which
> will
> > > > > >> initiate the spring
> > > > > >> security filter chain
> > > > > >> </description>
> > > > > >>
> > > <display-name>springSecurityFilterChain</display-name>
> > > > > >>
> > <filter-name>springSecurityFilterChain</filter-name>
> > > > > >> <filter-class>
> > > > > >>
> > > > > >> org.springframework.web.filter.DelegatingFilterProxy
> > > > > >> </filter-class>
> > > > > >> </filter>
> > > > > >>
> > > > > >> <filter-mapping>
> > > > > >>
> > <filter-name>springSecurityFilterChain</filter-name>
> > > > > >> <url-pattern>/*</url-pattern>
> > > > > >> <dispatcher>FORWARD</dispatcher>
> > > > > >> <dispatcher>REQUEST</dispatcher>
> > > > > >> </filter-mapping>
> > > > > >>
> > > > > >> And in my spring application context I have followed the advice
> > from
> > > > > >> spring forums and done necessary settings:
> > > > > >> Excerpt is:
> > > > > >>
> > > > > >> <security:http
> > > > > >>
> > > > > >> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint"
> > > > > >> once-per-request="false">
> > > > > >> <security:intercept-url pattern="/index.jsp"
> > > > > filters="none"
> > > > > >> />
> > > > > >> <security:intercept-url pattern="/login.jsp"
> > > > > filters="none"
> > > > > >> />
> > > > > >> <security:intercept-url
> > > > pattern="/authenticationservlet"
> > > > > >> filters="none"/>
> > > > > >> <security:intercept-url
> pattern="**/jsp/common/**"
> > > > > >> filters="none"/>
> > > > > >> <security:intercept-url pattern="/**/css/**"
> > > > > >> filters="none"/>
> > > > > >> <security:intercept-url pattern="/**/*.js"
> > > > > filters="none"/>
> > > > > >> <security:intercept-url pattern="/images/**"
> > > > > >> filters="none"/>
> > > > > >> <security:intercept-url pattern="/**/secure/**"
> > > > > >> access="ROLE_USER" />
> > > > > >> <security:intercept-url
> pattern="/**/operations/**"
> > > > > >> access="ROLE_OPERATIONS"/>
> > > > > >> <security:intercept-url pattern="/**"
> > > > > >> access="IS_AUTHENTICATED_ANONYMOUSLY" />
> > > > > >> </security:http>
> > > > > >>
> > > > > >> Now when I forward a request from index.jsp to login.jsp then
> the
> > > > spring
> > > > > >> filters are called with the login.jsp URL even though the
> browser
> > > > shows
> > > > > the
> > > > > >> old URL.
> > > > > >>
> > > > > >> However when from within an action method a navigation case is
> > > handled
> > > > > >> then it is not intercepted by the spring filters at all. However
> > if
> > > I
> > > > > give a
> > > > > >> <redirect/> then it is properly intercepted with the correct URL
> > as
> > > > > >> expected.
> > > > > >>
> > > > > >> What can be the reason?
> > > > > >>
> > > > > >> Regards,
> > > > > >> Madhav
> > > > > >>
> > > > > >>
> > > > > >>
> > > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> > **************** CAUTION - Disclaimer *****************
> > This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
> > solely
> > for the use of the addressee(s). If you are not the intended recipient,
> > please
> > notify the sender by e-mail and delete the original message. Further, you
> > are not
> > to copy, disclose, or distribute this e-mail or its contents to any other
> > person and
> > any such actions are unlawful. This e-mail may contain viruses. Infosys
> has
> > taken
> > every reasonable precaution to minimize this risk, but is not liable for
> > any damage
> > you may sustain as a result of any virus in this e-mail. You should carry
> > out your
> > own virus checks before opening the e-mail or attachment. Infosys
> reserves
> > the
> > right to monitor and review the content of all messages sent to or from
> > this e-mail
> > address. Messages sent to or from this e-mail address may be stored on
> the
> > Infosys e-mail system.
> > ***INFOSYS******** End of Disclaimer ********INFOSYS***
> >
>
>
RE: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Madhav Bhargava <Ma...@infosys.com>.
Attached is the log file. Look for lined which have (URLInterceptor.java) This will give you the URL that has been intercepted by the custom filter which sits before any spring filter. Right now all it does is print out the URL that it intercepted.
To refresh your memory here is the flow again in brief:
1. http://localhost:9080/contextRoot/ is invoked and it internally it redirects it to the welcome page (/index.jsp)
2. index.jsp does a <jsp:forward> to /login.jsp
3. User enters the credentials and as of now since we do not have Siteminder for authentication the action attribute points to /jsp/secure/hprelanding.jspx (first JSF page) so a redirect is send.
4. On hprelanding page an automatic click happens on a hidden command button which calls a backing bean action method. Since I am using icefaces the click of a button request is sent using the URL: http://localhost:9080/HPRE/block/send-receive-updates
5. You will find many other URL's in between which is all caused by icefaces.
6. The action method will do nothing but forward the request to operationlanding.jspx page which should only be visible to users who have ROLE_OPERATIONS however that URL never comes up. Instead the next URL of importance is again hprelanding.jspx one.
Regards,
Madhav
>From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On Behalf Of Jakob Korherr
>Sent: Monday, January 18, 2010 3:45 PM
>
>It would be great to see some logs!
>
>2010/1/18 Madhav Bhargava <Ma...@infosys.com>
>
> Sorry for the confusion. There was some problem with log4j configuration on
> WAS 6 and therefore I was not able to generate DEBUG logs out of spring
> security. The issue turned out to be a ws-commons-logging.jar. Anyways back
> to the issue:
>
> In the log it shows that the filter is actually getting called but with an
> older URL. So the spring security filter configuration is fine but now it’s
> the problem only with JSF. The <jsp:forward> thing works fine as I am doing
> a forward from index.jsp to login.jsp
>
> If you want the DEBUG logs then I can provide them.
>
> Regards,
> Madhav
>
> >From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> Behalf Of Jakob Korherr
> >
> >»The spring security filters are not invoked at all when a JSF forward
> >happens.«
> >
> >Then the issue has to be a misconfiguration problem, because a normal
> filter
> >is called for the JSF forward (I tested that). However, I don't know
> spring
> >security filters well enough to point out what the real problem is. sorry!
> >
> >
> >2010/1/18 Madhav Bhargava <Ma...@infosys.com>
> >
> > Sorry for the delay in response. The spring security filters are not
> > invoked at all when a JSF forward happens.
> > What we have done as a workaround is that login page has now been made a
> > simple non JSF JSP. We redirect from login page to another page which is
> > just a dummy page. This redirect causes spring security to set up
> > SecurityContext properly. So we are able to use spring security component
> > level authorizations properly. However the URL level authorization is
> still
> > an issue.
> >
> > Regards,
> > Madhav
> >
> > >From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> > Behalf Of Jakob Korherr
> > >
> > Can you sort out if the filter itself is not called or if the filter
> > behaves
> > >wrong?
> > >
> > >
> > >2010/1/13 Madhav Bhargava <Ma...@infosys.com>
> > >
> > > Yeah this is the place.
> > > Back to the problem. I still cannot come up with a workaround :(
> > >
> > > From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> > > Behalf Of Jakob Korherr
> > > >The "magic" happens in JspViewHandlerImpl's renderView() method:
> > > >
> > > >public void renderView(FacesContext facesContext, UIViewRoot
> > viewToRender)
> > > > throws IOException, FacesException {
> > > > externalContext.dispatch(viewId);
> > > > ....
> > > >
> > > > }
> > > >
> > > >Regards,
> > > >Jakob
> > > >
> > > >2010/1/13 Madhav Bhargava <Ma...@infosys.com>
> > > >
> > > > Yes, I am not using facelets.
> > > > I had a look at the NavigationHandlerImpl and here is the excerpt
> from
> > > it:
> > > >
> > > > Method: handleNavigation
> > > >
> > > > if (navigationCase != null)
> > > > {
> > > > if (log.isTraceEnabled())
> > > > {
> > > > log.trace("handleNavigation fromAction=" + fromAction
> +
> > "
> > > > outcome=" + outcome +
> > > > " toViewId =" + navigationCase.getToViewId()
> +
> > > > " redirect=" + navigationCase.isRedirect());
> > > > }
> > > > if (navigationCase.isRedirect() &&
> > > > (!PortletUtil.isPortletRequest(facesContext)))
> > > > { // Spec section 7.4.2 says "redirects not possible" in
> > this
> > > > case for portlets
> > > > ExternalContext externalContext =
> > > > facesContext.getExternalContext();
> > > > ViewHandler viewHandler =
> > > > facesContext.getApplication().getViewHandler();
> > > > String redirectPath =
> > > viewHandler.getActionURL(facesContext,
> > > > navigationCase.getToViewId());
> > > >
> > > > try
> > > > {
> > > >
> > > >
> > externalContext.redirect(externalContext.encodeActionURL(redirectPath));
> > > > }
> > > > catch (IOException e)
> > > > {
> > > > throw new FacesException(e.getMessage(), e);
> > > > }
> > > > }
> > > > else
> > > > {
> > > > ViewHandler viewHandler =
> > > > facesContext.getApplication().getViewHandler();
> > > > //create new view
> > > > String newViewId = navigationCase.getToViewId();
> > > > UIViewRoot viewRoot = null;
> > > > if (isPartialStateSavingOn(facesContext)) {
> > > > viewRoot =
> > > > viewHandler.restoreView(facesContext,newViewId);
> > > > } else {
> > > > viewRoot = viewHandler.createView(facesContext,
> > > > newViewId);
> > > > }
> > > > facesContext.setViewRoot(viewRoot);
> > > > facesContext.renderResponse();
> > > > }
> > > >
> > > > In the above code, redirect happens properly however for a forward
> > there
> > > is
> > > > no RequestDispatcher.forward or ExternalContext.dispatch called. So I
> > do
> > > not
> > > > know where a forward happens.
> > > >
> > > > Regards,
> > > > Madhav
> > > >
> > > > From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com]
> On
> > > > Behalf Of Jakob Korherr
> > > > >Hi Tomasz,
> > > > >
> > > > >That's all correct! However, I don't think he is using Facelets,
> > because
> > > > he
> > > > >mentioned JSP-pages...
> > > > >
> > > > >Regards,
> > > > >Jakob
> > > > >
> > > > >2010/1/12 Tomasz Pasierb <to...@poczta.fm>
> > > > >
> > > > > Hi,
> > > > >
> > > > > as I understand you use a commandButton and as a result a different
> > > page
> > > > (a
> > > > > secured one) is rendered but spring security does not seem to
> > intercept
> > > > the
> > > > > url, is that right?
> > > > >
> > > > > If so and if the solution used by you uses Facelets then this may
> be
> > > the
> > > > > problem.
> > > > > When using Facelets as opposed to "pure" (older) jsf+jsp approach
> > there
> > > > is
> > > > > no forward when a new view is rendered that is a result of a
> > navigation
> > > > case
> > > > > forward. I've been investigating this recently. When JSP view
> handler
> > > is
> > > > > used it checks which view should be rendered next and does a
> forward
> > to
> > > > this
> > > > > new view which spring security can intercept. The Facelet view
> > handler
> > > > > however seems to load the view (xhtml) and render it without making
> > the
> > > > > actual forward. As a result no interception can happen and usually
> it
> > > is
> > > > > triggered with the next request.
> > > > > You need to either use redirects or make GET requests to logically
> > > > separate
> > > > > views - I know this is not natural with jsf versions prior to 2.0,
> > but
> > > > this
> > > > > new spec seems to change everything :-) - use can easily generate
> GET
> > > > > requests with the new version.
> > > > >
> > > > > Hope this helps ;)
> > > > >
> > > > > Regards,
> > > > > Tom Pasierb
> > > > >
> > > > > Madhav Bhargava pisze:
> > > > >
> > > > > Hi All,
> > > > >>
> > > > >> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring
> > security
> > > > >> -2.0.5, WAS 6.0 (app server)
> > > > >>
> > > > >> I have configured spring security for my JSF application along
> with
> > > > >> SiteMinder as an external authentication mechanism. It works fine
> > till
> > > a
> > > > >> forward happens from within myfaces.
> > > > >>
> > > > >> Here is my spring servlet filter chain declaration:
> > > > >> <filter>
> > > > >> <description>
> > > > >> Spring delegating filter which will
> > > > >> initiate the spring
> > > > >> security filter chain
> > > > >> </description>
> > > > >>
> > <display-name>springSecurityFilterChain</display-name>
> > > > >>
> <filter-name>springSecurityFilterChain</filter-name>
> > > > >> <filter-class>
> > > > >>
> > > > >> org.springframework.web.filter.DelegatingFilterProxy
> > > > >> </filter-class>
> > > > >> </filter>
> > > > >>
> > > > >> <filter-mapping>
> > > > >>
> <filter-name>springSecurityFilterChain</filter-name>
> > > > >> <url-pattern>/*</url-pattern>
> > > > >> <dispatcher>FORWARD</dispatcher>
> > > > >> <dispatcher>REQUEST</dispatcher>
> > > > >> </filter-mapping>
> > > > >>
> > > > >> And in my spring application context I have followed the advice
> from
> > > > >> spring forums and done necessary settings:
> > > > >> Excerpt is:
> > > > >>
> > > > >> <security:http
> > > > >>
> > > > >> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint"
> > > > >> once-per-request="false">
> > > > >> <security:intercept-url pattern="/index.jsp"
> > > > filters="none"
> > > > >> />
> > > > >> <security:intercept-url pattern="/login.jsp"
> > > > filters="none"
> > > > >> />
> > > > >> <security:intercept-url
> > > pattern="/authenticationservlet"
> > > > >> filters="none"/>
> > > > >> <security:intercept-url pattern="**/jsp/common/**"
> > > > >> filters="none"/>
> > > > >> <security:intercept-url pattern="/**/css/**"
> > > > >> filters="none"/>
> > > > >> <security:intercept-url pattern="/**/*.js"
> > > > filters="none"/>
> > > > >> <security:intercept-url pattern="/images/**"
> > > > >> filters="none"/>
> > > > >> <security:intercept-url pattern="/**/secure/**"
> > > > >> access="ROLE_USER" />
> > > > >> <security:intercept-url pattern="/**/operations/**"
> > > > >> access="ROLE_OPERATIONS"/>
> > > > >> <security:intercept-url pattern="/**"
> > > > >> access="IS_AUTHENTICATED_ANONYMOUSLY" />
> > > > >> </security:http>
> > > > >>
> > > > >> Now when I forward a request from index.jsp to login.jsp then the
> > > spring
> > > > >> filters are called with the login.jsp URL even though the browser
> > > shows
> > > > the
> > > > >> old URL.
> > > > >>
> > > > >> However when from within an action method a navigation case is
> > handled
> > > > >> then it is not intercepted by the spring filters at all. However
> if
> > I
> > > > give a
> > > > >> <redirect/> then it is properly intercepted with the correct URL
> as
> > > > >> expected.
> > > > >>
> > > > >> What can be the reason?
> > > > >>
> > > > >> Regards,
> > > > >> Madhav
> > > > >>
> > > > >>
> > > > >>
> > > > >
> > > >
> > > >
> > >
> >
>
> **************** CAUTION - Disclaimer *****************
> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
> solely
> for the use of the addressee(s). If you are not the intended recipient,
> please
> notify the sender by e-mail and delete the original message. Further, you
> are not
> to copy, disclose, or distribute this e-mail or its contents to any other
> person and
> any such actions are unlawful. This e-mail may contain viruses. Infosys has
> taken
> every reasonable precaution to minimize this risk, but is not liable for
> any damage
> you may sustain as a result of any virus in this e-mail. You should carry
> out your
> own virus checks before opening the e-mail or attachment. Infosys reserves
> the
> right to monitor and review the content of all messages sent to or from
> this e-mail
> address. Messages sent to or from this e-mail address may be stored on the
> Infosys e-mail system.
> ***INFOSYS******** End of Disclaimer ********INFOSYS***
>
Re: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Jakob Korherr <ja...@gmail.com>.
It would be great to see some logs!
2010/1/18 Madhav Bhargava <Ma...@infosys.com>
> Sorry for the confusion. There was some problem with log4j configuration on
> WAS 6 and therefore I was not able to generate DEBUG logs out of spring
> security. The issue turned out to be a ws-commons-logging.jar. Anyways back
> to the issue:
>
> In the log it shows that the filter is actually getting called but with an
> older URL. So the spring security filter configuration is fine but now it’s
> the problem only with JSF. The <jsp:forward> thing works fine as I am doing
> a forward from index.jsp to login.jsp
>
> If you want the DEBUG logs then I can provide them.
>
> Regards,
> Madhav
>
> >From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> Behalf Of Jakob Korherr
> >
> >»The spring security filters are not invoked at all when a JSF forward
> >happens.«
> >
> >Then the issue has to be a misconfiguration problem, because a normal
> filter
> >is called for the JSF forward (I tested that). However, I don't know
> spring
> >security filters well enough to point out what the real problem is. sorry!
> >
> >
> >2010/1/18 Madhav Bhargava <Ma...@infosys.com>
> >
> > Sorry for the delay in response. The spring security filters are not
> > invoked at all when a JSF forward happens.
> > What we have done as a workaround is that login page has now been made a
> > simple non JSF JSP. We redirect from login page to another page which is
> > just a dummy page. This redirect causes spring security to set up
> > SecurityContext properly. So we are able to use spring security component
> > level authorizations properly. However the URL level authorization is
> still
> > an issue.
> >
> > Regards,
> > Madhav
> >
> > >From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> > Behalf Of Jakob Korherr
> > >
> > Can you sort out if the filter itself is not called or if the filter
> > behaves
> > >wrong?
> > >
> > >
> > >2010/1/13 Madhav Bhargava <Ma...@infosys.com>
> > >
> > > Yeah this is the place.
> > > Back to the problem. I still cannot come up with a workaround :(
> > >
> > > From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> > > Behalf Of Jakob Korherr
> > > >The "magic" happens in JspViewHandlerImpl's renderView() method:
> > > >
> > > >public void renderView(FacesContext facesContext, UIViewRoot
> > viewToRender)
> > > > throws IOException, FacesException {
> > > > externalContext.dispatch(viewId);
> > > > ....
> > > >
> > > > }
> > > >
> > > >Regards,
> > > >Jakob
> > > >
> > > >2010/1/13 Madhav Bhargava <Ma...@infosys.com>
> > > >
> > > > Yes, I am not using facelets.
> > > > I had a look at the NavigationHandlerImpl and here is the excerpt
> from
> > > it:
> > > >
> > > > Method: handleNavigation
> > > >
> > > > if (navigationCase != null)
> > > > {
> > > > if (log.isTraceEnabled())
> > > > {
> > > > log.trace("handleNavigation fromAction=" + fromAction
> +
> > "
> > > > outcome=" + outcome +
> > > > " toViewId =" + navigationCase.getToViewId()
> +
> > > > " redirect=" + navigationCase.isRedirect());
> > > > }
> > > > if (navigationCase.isRedirect() &&
> > > > (!PortletUtil.isPortletRequest(facesContext)))
> > > > { // Spec section 7.4.2 says "redirects not possible" in
> > this
> > > > case for portlets
> > > > ExternalContext externalContext =
> > > > facesContext.getExternalContext();
> > > > ViewHandler viewHandler =
> > > > facesContext.getApplication().getViewHandler();
> > > > String redirectPath =
> > > viewHandler.getActionURL(facesContext,
> > > > navigationCase.getToViewId());
> > > >
> > > > try
> > > > {
> > > >
> > > >
> > externalContext.redirect(externalContext.encodeActionURL(redirectPath));
> > > > }
> > > > catch (IOException e)
> > > > {
> > > > throw new FacesException(e.getMessage(), e);
> > > > }
> > > > }
> > > > else
> > > > {
> > > > ViewHandler viewHandler =
> > > > facesContext.getApplication().getViewHandler();
> > > > //create new view
> > > > String newViewId = navigationCase.getToViewId();
> > > > UIViewRoot viewRoot = null;
> > > > if (isPartialStateSavingOn(facesContext)) {
> > > > viewRoot =
> > > > viewHandler.restoreView(facesContext,newViewId);
> > > > } else {
> > > > viewRoot = viewHandler.createView(facesContext,
> > > > newViewId);
> > > > }
> > > > facesContext.setViewRoot(viewRoot);
> > > > facesContext.renderResponse();
> > > > }
> > > >
> > > > In the above code, redirect happens properly however for a forward
> > there
> > > is
> > > > no RequestDispatcher.forward or ExternalContext.dispatch called. So I
> > do
> > > not
> > > > know where a forward happens.
> > > >
> > > > Regards,
> > > > Madhav
> > > >
> > > > From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com]
> On
> > > > Behalf Of Jakob Korherr
> > > > >Hi Tomasz,
> > > > >
> > > > >That's all correct! However, I don't think he is using Facelets,
> > because
> > > > he
> > > > >mentioned JSP-pages...
> > > > >
> > > > >Regards,
> > > > >Jakob
> > > > >
> > > > >2010/1/12 Tomasz Pasierb <to...@poczta.fm>
> > > > >
> > > > > Hi,
> > > > >
> > > > > as I understand you use a commandButton and as a result a different
> > > page
> > > > (a
> > > > > secured one) is rendered but spring security does not seem to
> > intercept
> > > > the
> > > > > url, is that right?
> > > > >
> > > > > If so and if the solution used by you uses Facelets then this may
> be
> > > the
> > > > > problem.
> > > > > When using Facelets as opposed to "pure" (older) jsf+jsp approach
> > there
> > > > is
> > > > > no forward when a new view is rendered that is a result of a
> > navigation
> > > > case
> > > > > forward. I've been investigating this recently. When JSP view
> handler
> > > is
> > > > > used it checks which view should be rendered next and does a
> forward
> > to
> > > > this
> > > > > new view which spring security can intercept. The Facelet view
> > handler
> > > > > however seems to load the view (xhtml) and render it without making
> > the
> > > > > actual forward. As a result no interception can happen and usually
> it
> > > is
> > > > > triggered with the next request.
> > > > > You need to either use redirects or make GET requests to logically
> > > > separate
> > > > > views - I know this is not natural with jsf versions prior to 2.0,
> > but
> > > > this
> > > > > new spec seems to change everything :-) - use can easily generate
> GET
> > > > > requests with the new version.
> > > > >
> > > > > Hope this helps ;)
> > > > >
> > > > > Regards,
> > > > > Tom Pasierb
> > > > >
> > > > > Madhav Bhargava pisze:
> > > > >
> > > > > Hi All,
> > > > >>
> > > > >> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring
> > security
> > > > >> -2.0.5, WAS 6.0 (app server)
> > > > >>
> > > > >> I have configured spring security for my JSF application along
> with
> > > > >> SiteMinder as an external authentication mechanism. It works fine
> > till
> > > a
> > > > >> forward happens from within myfaces.
> > > > >>
> > > > >> Here is my spring servlet filter chain declaration:
> > > > >> <filter>
> > > > >> <description>
> > > > >> Spring delegating filter which will
> > > > >> initiate the spring
> > > > >> security filter chain
> > > > >> </description>
> > > > >>
> > <display-name>springSecurityFilterChain</display-name>
> > > > >>
> <filter-name>springSecurityFilterChain</filter-name>
> > > > >> <filter-class>
> > > > >>
> > > > >> org.springframework.web.filter.DelegatingFilterProxy
> > > > >> </filter-class>
> > > > >> </filter>
> > > > >>
> > > > >> <filter-mapping>
> > > > >>
> <filter-name>springSecurityFilterChain</filter-name>
> > > > >> <url-pattern>/*</url-pattern>
> > > > >> <dispatcher>FORWARD</dispatcher>
> > > > >> <dispatcher>REQUEST</dispatcher>
> > > > >> </filter-mapping>
> > > > >>
> > > > >> And in my spring application context I have followed the advice
> from
> > > > >> spring forums and done necessary settings:
> > > > >> Excerpt is:
> > > > >>
> > > > >> <security:http
> > > > >>
> > > > >> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint"
> > > > >> once-per-request="false">
> > > > >> <security:intercept-url pattern="/index.jsp"
> > > > filters="none"
> > > > >> />
> > > > >> <security:intercept-url pattern="/login.jsp"
> > > > filters="none"
> > > > >> />
> > > > >> <security:intercept-url
> > > pattern="/authenticationservlet"
> > > > >> filters="none"/>
> > > > >> <security:intercept-url pattern="**/jsp/common/**"
> > > > >> filters="none"/>
> > > > >> <security:intercept-url pattern="/**/css/**"
> > > > >> filters="none"/>
> > > > >> <security:intercept-url pattern="/**/*.js"
> > > > filters="none"/>
> > > > >> <security:intercept-url pattern="/images/**"
> > > > >> filters="none"/>
> > > > >> <security:intercept-url pattern="/**/secure/**"
> > > > >> access="ROLE_USER" />
> > > > >> <security:intercept-url pattern="/**/operations/**"
> > > > >> access="ROLE_OPERATIONS"/>
> > > > >> <security:intercept-url pattern="/**"
> > > > >> access="IS_AUTHENTICATED_ANONYMOUSLY" />
> > > > >> </security:http>
> > > > >>
> > > > >> Now when I forward a request from index.jsp to login.jsp then the
> > > spring
> > > > >> filters are called with the login.jsp URL even though the browser
> > > shows
> > > > the
> > > > >> old URL.
> > > > >>
> > > > >> However when from within an action method a navigation case is
> > handled
> > > > >> then it is not intercepted by the spring filters at all. However
> if
> > I
> > > > give a
> > > > >> <redirect/> then it is properly intercepted with the correct URL
> as
> > > > >> expected.
> > > > >>
> > > > >> What can be the reason?
> > > > >>
> > > > >> Regards,
> > > > >> Madhav
> > > > >>
> > > > >>
> > > > >>
> > > > >
> > > >
> > > >
> > >
> >
>
> **************** CAUTION - Disclaimer *****************
> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
> solely
> for the use of the addressee(s). If you are not the intended recipient,
> please
> notify the sender by e-mail and delete the original message. Further, you
> are not
> to copy, disclose, or distribute this e-mail or its contents to any other
> person and
> any such actions are unlawful. This e-mail may contain viruses. Infosys has
> taken
> every reasonable precaution to minimize this risk, but is not liable for
> any damage
> you may sustain as a result of any virus in this e-mail. You should carry
> out your
> own virus checks before opening the e-mail or attachment. Infosys reserves
> the
> right to monitor and review the content of all messages sent to or from
> this e-mail
> address. Messages sent to or from this e-mail address may be stored on the
> Infosys e-mail system.
> ***INFOSYS******** End of Disclaimer ********INFOSYS***
>
RE: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Madhav Bhargava <Ma...@infosys.com>.
Sorry for the confusion. There was some problem with log4j configuration on WAS 6 and therefore I was not able to generate DEBUG logs out of spring security. The issue turned out to be a ws-commons-logging.jar. Anyways back to the issue:
In the log it shows that the filter is actually getting called but with an older URL. So the spring security filter configuration is fine but now it’s the problem only with JSF. The <jsp:forward> thing works fine as I am doing a forward from index.jsp to login.jsp
If you want the DEBUG logs then I can provide them.
Regards,
Madhav
>From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On Behalf Of Jakob Korherr
>
>»The spring security filters are not invoked at all when a JSF forward
>happens.«
>
>Then the issue has to be a misconfiguration problem, because a normal filter
>is called for the JSF forward (I tested that). However, I don't know spring
>security filters well enough to point out what the real problem is. sorry!
>
>
>2010/1/18 Madhav Bhargava <Ma...@infosys.com>
>
> Sorry for the delay in response. The spring security filters are not
> invoked at all when a JSF forward happens.
> What we have done as a workaround is that login page has now been made a
> simple non JSF JSP. We redirect from login page to another page which is
> just a dummy page. This redirect causes spring security to set up
> SecurityContext properly. So we are able to use spring security component
> level authorizations properly. However the URL level authorization is still
> an issue.
>
> Regards,
> Madhav
>
> >From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> Behalf Of Jakob Korherr
> >
> Can you sort out if the filter itself is not called or if the filter
> behaves
> >wrong?
> >
> >
> >2010/1/13 Madhav Bhargava <Ma...@infosys.com>
> >
> > Yeah this is the place.
> > Back to the problem. I still cannot come up with a workaround :(
> >
> > From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> > Behalf Of Jakob Korherr
> > >The "magic" happens in JspViewHandlerImpl's renderView() method:
> > >
> > >public void renderView(FacesContext facesContext, UIViewRoot
> viewToRender)
> > > throws IOException, FacesException {
> > > externalContext.dispatch(viewId);
> > > ....
> > >
> > > }
> > >
> > >Regards,
> > >Jakob
> > >
> > >2010/1/13 Madhav Bhargava <Ma...@infosys.com>
> > >
> > > Yes, I am not using facelets.
> > > I had a look at the NavigationHandlerImpl and here is the excerpt from
> > it:
> > >
> > > Method: handleNavigation
> > >
> > > if (navigationCase != null)
> > > {
> > > if (log.isTraceEnabled())
> > > {
> > > log.trace("handleNavigation fromAction=" + fromAction +
> "
> > > outcome=" + outcome +
> > > " toViewId =" + navigationCase.getToViewId() +
> > > " redirect=" + navigationCase.isRedirect());
> > > }
> > > if (navigationCase.isRedirect() &&
> > > (!PortletUtil.isPortletRequest(facesContext)))
> > > { // Spec section 7.4.2 says "redirects not possible" in
> this
> > > case for portlets
> > > ExternalContext externalContext =
> > > facesContext.getExternalContext();
> > > ViewHandler viewHandler =
> > > facesContext.getApplication().getViewHandler();
> > > String redirectPath =
> > viewHandler.getActionURL(facesContext,
> > > navigationCase.getToViewId());
> > >
> > > try
> > > {
> > >
> > >
> externalContext.redirect(externalContext.encodeActionURL(redirectPath));
> > > }
> > > catch (IOException e)
> > > {
> > > throw new FacesException(e.getMessage(), e);
> > > }
> > > }
> > > else
> > > {
> > > ViewHandler viewHandler =
> > > facesContext.getApplication().getViewHandler();
> > > //create new view
> > > String newViewId = navigationCase.getToViewId();
> > > UIViewRoot viewRoot = null;
> > > if (isPartialStateSavingOn(facesContext)) {
> > > viewRoot =
> > > viewHandler.restoreView(facesContext,newViewId);
> > > } else {
> > > viewRoot = viewHandler.createView(facesContext,
> > > newViewId);
> > > }
> > > facesContext.setViewRoot(viewRoot);
> > > facesContext.renderResponse();
> > > }
> > >
> > > In the above code, redirect happens properly however for a forward
> there
> > is
> > > no RequestDispatcher.forward or ExternalContext.dispatch called. So I
> do
> > not
> > > know where a forward happens.
> > >
> > > Regards,
> > > Madhav
> > >
> > > From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> > > Behalf Of Jakob Korherr
> > > >Hi Tomasz,
> > > >
> > > >That's all correct! However, I don't think he is using Facelets,
> because
> > > he
> > > >mentioned JSP-pages...
> > > >
> > > >Regards,
> > > >Jakob
> > > >
> > > >2010/1/12 Tomasz Pasierb <to...@poczta.fm>
> > > >
> > > > Hi,
> > > >
> > > > as I understand you use a commandButton and as a result a different
> > page
> > > (a
> > > > secured one) is rendered but spring security does not seem to
> intercept
> > > the
> > > > url, is that right?
> > > >
> > > > If so and if the solution used by you uses Facelets then this may be
> > the
> > > > problem.
> > > > When using Facelets as opposed to "pure" (older) jsf+jsp approach
> there
> > > is
> > > > no forward when a new view is rendered that is a result of a
> navigation
> > > case
> > > > forward. I've been investigating this recently. When JSP view handler
> > is
> > > > used it checks which view should be rendered next and does a forward
> to
> > > this
> > > > new view which spring security can intercept. The Facelet view
> handler
> > > > however seems to load the view (xhtml) and render it without making
> the
> > > > actual forward. As a result no interception can happen and usually it
> > is
> > > > triggered with the next request.
> > > > You need to either use redirects or make GET requests to logically
> > > separate
> > > > views - I know this is not natural with jsf versions prior to 2.0,
> but
> > > this
> > > > new spec seems to change everything :-) - use can easily generate GET
> > > > requests with the new version.
> > > >
> > > > Hope this helps ;)
> > > >
> > > > Regards,
> > > > Tom Pasierb
> > > >
> > > > Madhav Bhargava pisze:
> > > >
> > > > Hi All,
> > > >>
> > > >> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring
> security
> > > >> -2.0.5, WAS 6.0 (app server)
> > > >>
> > > >> I have configured spring security for my JSF application along with
> > > >> SiteMinder as an external authentication mechanism. It works fine
> till
> > a
> > > >> forward happens from within myfaces.
> > > >>
> > > >> Here is my spring servlet filter chain declaration:
> > > >> <filter>
> > > >> <description>
> > > >> Spring delegating filter which will
> > > >> initiate the spring
> > > >> security filter chain
> > > >> </description>
> > > >>
> <display-name>springSecurityFilterChain</display-name>
> > > >> <filter-name>springSecurityFilterChain</filter-name>
> > > >> <filter-class>
> > > >>
> > > >> org.springframework.web.filter.DelegatingFilterProxy
> > > >> </filter-class>
> > > >> </filter>
> > > >>
> > > >> <filter-mapping>
> > > >> <filter-name>springSecurityFilterChain</filter-name>
> > > >> <url-pattern>/*</url-pattern>
> > > >> <dispatcher>FORWARD</dispatcher>
> > > >> <dispatcher>REQUEST</dispatcher>
> > > >> </filter-mapping>
> > > >>
> > > >> And in my spring application context I have followed the advice from
> > > >> spring forums and done necessary settings:
> > > >> Excerpt is:
> > > >>
> > > >> <security:http
> > > >>
> > > >> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint"
> > > >> once-per-request="false">
> > > >> <security:intercept-url pattern="/index.jsp"
> > > filters="none"
> > > >> />
> > > >> <security:intercept-url pattern="/login.jsp"
> > > filters="none"
> > > >> />
> > > >> <security:intercept-url
> > pattern="/authenticationservlet"
> > > >> filters="none"/>
> > > >> <security:intercept-url pattern="**/jsp/common/**"
> > > >> filters="none"/>
> > > >> <security:intercept-url pattern="/**/css/**"
> > > >> filters="none"/>
> > > >> <security:intercept-url pattern="/**/*.js"
> > > filters="none"/>
> > > >> <security:intercept-url pattern="/images/**"
> > > >> filters="none"/>
> > > >> <security:intercept-url pattern="/**/secure/**"
> > > >> access="ROLE_USER" />
> > > >> <security:intercept-url pattern="/**/operations/**"
> > > >> access="ROLE_OPERATIONS"/>
> > > >> <security:intercept-url pattern="/**"
> > > >> access="IS_AUTHENTICATED_ANONYMOUSLY" />
> > > >> </security:http>
> > > >>
> > > >> Now when I forward a request from index.jsp to login.jsp then the
> > spring
> > > >> filters are called with the login.jsp URL even though the browser
> > shows
> > > the
> > > >> old URL.
> > > >>
> > > >> However when from within an action method a navigation case is
> handled
> > > >> then it is not intercepted by the spring filters at all. However if
> I
> > > give a
> > > >> <redirect/> then it is properly intercepted with the correct URL as
> > > >> expected.
> > > >>
> > > >> What can be the reason?
> > > >>
> > > >> Regards,
> > > >> Madhav
> > > >>
> > > >>
> > > >>
> > > >
> > >
> > >
> >
>
**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely
for the use of the addressee(s). If you are not the intended recipient, please
notify the sender by e-mail and delete the original message. Further, you are not
to copy, disclose, or distribute this e-mail or its contents to any other person and
any such actions are unlawful. This e-mail may contain viruses. Infosys has taken
every reasonable precaution to minimize this risk, but is not liable for any damage
you may sustain as a result of any virus in this e-mail. You should carry out your
own virus checks before opening the e-mail or attachment. Infosys reserves the
right to monitor and review the content of all messages sent to or from this e-mail
address. Messages sent to or from this e-mail address may be stored on the
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***
Re: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Jakob Korherr <ja...@gmail.com>.
»The spring security filters are not invoked at all when a JSF forward
happens.«
Then the issue has to be a misconfiguration problem, because a normal filter
is called for the JSF forward (I tested that). However, I don't know spring
security filters well enough to point out what the real problem is. sorry!
2010/1/18 Madhav Bhargava <Ma...@infosys.com>
> Sorry for the delay in response. The spring security filters are not
> invoked at all when a JSF forward happens.
> What we have done as a workaround is that login page has now been made a
> simple non JSF JSP. We redirect from login page to another page which is
> just a dummy page. This redirect causes spring security to set up
> SecurityContext properly. So we are able to use spring security component
> level authorizations properly. However the URL level authorization is still
> an issue.
>
> Regards,
> Madhav
>
> >From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> Behalf Of Jakob Korherr
> >
> Can you sort out if the filter itself is not called or if the filter
> behaves
> >wrong?
> >
> >
> >2010/1/13 Madhav Bhargava <Ma...@infosys.com>
> >
> > Yeah this is the place.
> > Back to the problem. I still cannot come up with a workaround :(
> >
> > From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> > Behalf Of Jakob Korherr
> > >The "magic" happens in JspViewHandlerImpl's renderView() method:
> > >
> > >public void renderView(FacesContext facesContext, UIViewRoot
> viewToRender)
> > > throws IOException, FacesException {
> > > externalContext.dispatch(viewId);
> > > ....
> > >
> > > }
> > >
> > >Regards,
> > >Jakob
> > >
> > >2010/1/13 Madhav Bhargava <Ma...@infosys.com>
> > >
> > > Yes, I am not using facelets.
> > > I had a look at the NavigationHandlerImpl and here is the excerpt from
> > it:
> > >
> > > Method: handleNavigation
> > >
> > > if (navigationCase != null)
> > > {
> > > if (log.isTraceEnabled())
> > > {
> > > log.trace("handleNavigation fromAction=" + fromAction +
> "
> > > outcome=" + outcome +
> > > " toViewId =" + navigationCase.getToViewId() +
> > > " redirect=" + navigationCase.isRedirect());
> > > }
> > > if (navigationCase.isRedirect() &&
> > > (!PortletUtil.isPortletRequest(facesContext)))
> > > { // Spec section 7.4.2 says "redirects not possible" in
> this
> > > case for portlets
> > > ExternalContext externalContext =
> > > facesContext.getExternalContext();
> > > ViewHandler viewHandler =
> > > facesContext.getApplication().getViewHandler();
> > > String redirectPath =
> > viewHandler.getActionURL(facesContext,
> > > navigationCase.getToViewId());
> > >
> > > try
> > > {
> > >
> > >
> externalContext.redirect(externalContext.encodeActionURL(redirectPath));
> > > }
> > > catch (IOException e)
> > > {
> > > throw new FacesException(e.getMessage(), e);
> > > }
> > > }
> > > else
> > > {
> > > ViewHandler viewHandler =
> > > facesContext.getApplication().getViewHandler();
> > > //create new view
> > > String newViewId = navigationCase.getToViewId();
> > > UIViewRoot viewRoot = null;
> > > if (isPartialStateSavingOn(facesContext)) {
> > > viewRoot =
> > > viewHandler.restoreView(facesContext,newViewId);
> > > } else {
> > > viewRoot = viewHandler.createView(facesContext,
> > > newViewId);
> > > }
> > > facesContext.setViewRoot(viewRoot);
> > > facesContext.renderResponse();
> > > }
> > >
> > > In the above code, redirect happens properly however for a forward
> there
> > is
> > > no RequestDispatcher.forward or ExternalContext.dispatch called. So I
> do
> > not
> > > know where a forward happens.
> > >
> > > Regards,
> > > Madhav
> > >
> > > From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> > > Behalf Of Jakob Korherr
> > > >Hi Tomasz,
> > > >
> > > >That's all correct! However, I don't think he is using Facelets,
> because
> > > he
> > > >mentioned JSP-pages...
> > > >
> > > >Regards,
> > > >Jakob
> > > >
> > > >2010/1/12 Tomasz Pasierb <to...@poczta.fm>
> > > >
> > > > Hi,
> > > >
> > > > as I understand you use a commandButton and as a result a different
> > page
> > > (a
> > > > secured one) is rendered but spring security does not seem to
> intercept
> > > the
> > > > url, is that right?
> > > >
> > > > If so and if the solution used by you uses Facelets then this may be
> > the
> > > > problem.
> > > > When using Facelets as opposed to "pure" (older) jsf+jsp approach
> there
> > > is
> > > > no forward when a new view is rendered that is a result of a
> navigation
> > > case
> > > > forward. I've been investigating this recently. When JSP view handler
> > is
> > > > used it checks which view should be rendered next and does a forward
> to
> > > this
> > > > new view which spring security can intercept. The Facelet view
> handler
> > > > however seems to load the view (xhtml) and render it without making
> the
> > > > actual forward. As a result no interception can happen and usually it
> > is
> > > > triggered with the next request.
> > > > You need to either use redirects or make GET requests to logically
> > > separate
> > > > views - I know this is not natural with jsf versions prior to 2.0,
> but
> > > this
> > > > new spec seems to change everything :-) - use can easily generate GET
> > > > requests with the new version.
> > > >
> > > > Hope this helps ;)
> > > >
> > > > Regards,
> > > > Tom Pasierb
> > > >
> > > > Madhav Bhargava pisze:
> > > >
> > > > Hi All,
> > > >>
> > > >> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring
> security
> > > >> -2.0.5, WAS 6.0 (app server)
> > > >>
> > > >> I have configured spring security for my JSF application along with
> > > >> SiteMinder as an external authentication mechanism. It works fine
> till
> > a
> > > >> forward happens from within myfaces.
> > > >>
> > > >> Here is my spring servlet filter chain declaration:
> > > >> <filter>
> > > >> <description>
> > > >> Spring delegating filter which will
> > > >> initiate the spring
> > > >> security filter chain
> > > >> </description>
> > > >>
> <display-name>springSecurityFilterChain</display-name>
> > > >> <filter-name>springSecurityFilterChain</filter-name>
> > > >> <filter-class>
> > > >>
> > > >> org.springframework.web.filter.DelegatingFilterProxy
> > > >> </filter-class>
> > > >> </filter>
> > > >>
> > > >> <filter-mapping>
> > > >> <filter-name>springSecurityFilterChain</filter-name>
> > > >> <url-pattern>/*</url-pattern>
> > > >> <dispatcher>FORWARD</dispatcher>
> > > >> <dispatcher>REQUEST</dispatcher>
> > > >> </filter-mapping>
> > > >>
> > > >> And in my spring application context I have followed the advice from
> > > >> spring forums and done necessary settings:
> > > >> Excerpt is:
> > > >>
> > > >> <security:http
> > > >>
> > > >> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint"
> > > >> once-per-request="false">
> > > >> <security:intercept-url pattern="/index.jsp"
> > > filters="none"
> > > >> />
> > > >> <security:intercept-url pattern="/login.jsp"
> > > filters="none"
> > > >> />
> > > >> <security:intercept-url
> > pattern="/authenticationservlet"
> > > >> filters="none"/>
> > > >> <security:intercept-url pattern="**/jsp/common/**"
> > > >> filters="none"/>
> > > >> <security:intercept-url pattern="/**/css/**"
> > > >> filters="none"/>
> > > >> <security:intercept-url pattern="/**/*.js"
> > > filters="none"/>
> > > >> <security:intercept-url pattern="/images/**"
> > > >> filters="none"/>
> > > >> <security:intercept-url pattern="/**/secure/**"
> > > >> access="ROLE_USER" />
> > > >> <security:intercept-url pattern="/**/operations/**"
> > > >> access="ROLE_OPERATIONS"/>
> > > >> <security:intercept-url pattern="/**"
> > > >> access="IS_AUTHENTICATED_ANONYMOUSLY" />
> > > >> </security:http>
> > > >>
> > > >> Now when I forward a request from index.jsp to login.jsp then the
> > spring
> > > >> filters are called with the login.jsp URL even though the browser
> > shows
> > > the
> > > >> old URL.
> > > >>
> > > >> However when from within an action method a navigation case is
> handled
> > > >> then it is not intercepted by the spring filters at all. However if
> I
> > > give a
> > > >> <redirect/> then it is properly intercepted with the correct URL as
> > > >> expected.
> > > >>
> > > >> What can be the reason?
> > > >>
> > > >> Regards,
> > > >> Madhav
> > > >>
> > > >>
> > > >>
> > > >
> > >
> > >
> >
>
RE: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Madhav Bhargava <Ma...@infosys.com>.
Sorry for the delay in response. The spring security filters are not invoked at all when a JSF forward happens.
What we have done as a workaround is that login page has now been made a simple non JSF JSP. We redirect from login page to another page which is just a dummy page. This redirect causes spring security to set up SecurityContext properly. So we are able to use spring security component level authorizations properly. However the URL level authorization is still an issue.
Regards,
Madhav
>From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On Behalf Of Jakob Korherr
>
Can you sort out if the filter itself is not called or if the filter behaves
>wrong?
>
>
>2010/1/13 Madhav Bhargava <Ma...@infosys.com>
>
> Yeah this is the place.
> Back to the problem. I still cannot come up with a workaround :(
>
> From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> Behalf Of Jakob Korherr
> >The "magic" happens in JspViewHandlerImpl's renderView() method:
> >
> >public void renderView(FacesContext facesContext, UIViewRoot viewToRender)
> > throws IOException, FacesException {
> > externalContext.dispatch(viewId);
> > ....
> >
> > }
> >
> >Regards,
> >Jakob
> >
> >2010/1/13 Madhav Bhargava <Ma...@infosys.com>
> >
> > Yes, I am not using facelets.
> > I had a look at the NavigationHandlerImpl and here is the excerpt from
> it:
> >
> > Method: handleNavigation
> >
> > if (navigationCase != null)
> > {
> > if (log.isTraceEnabled())
> > {
> > log.trace("handleNavigation fromAction=" + fromAction + "
> > outcome=" + outcome +
> > " toViewId =" + navigationCase.getToViewId() +
> > " redirect=" + navigationCase.isRedirect());
> > }
> > if (navigationCase.isRedirect() &&
> > (!PortletUtil.isPortletRequest(facesContext)))
> > { // Spec section 7.4.2 says "redirects not possible" in this
> > case for portlets
> > ExternalContext externalContext =
> > facesContext.getExternalContext();
> > ViewHandler viewHandler =
> > facesContext.getApplication().getViewHandler();
> > String redirectPath =
> viewHandler.getActionURL(facesContext,
> > navigationCase.getToViewId());
> >
> > try
> > {
> >
> > externalContext.redirect(externalContext.encodeActionURL(redirectPath));
> > }
> > catch (IOException e)
> > {
> > throw new FacesException(e.getMessage(), e);
> > }
> > }
> > else
> > {
> > ViewHandler viewHandler =
> > facesContext.getApplication().getViewHandler();
> > //create new view
> > String newViewId = navigationCase.getToViewId();
> > UIViewRoot viewRoot = null;
> > if (isPartialStateSavingOn(facesContext)) {
> > viewRoot =
> > viewHandler.restoreView(facesContext,newViewId);
> > } else {
> > viewRoot = viewHandler.createView(facesContext,
> > newViewId);
> > }
> > facesContext.setViewRoot(viewRoot);
> > facesContext.renderResponse();
> > }
> >
> > In the above code, redirect happens properly however for a forward there
> is
> > no RequestDispatcher.forward or ExternalContext.dispatch called. So I do
> not
> > know where a forward happens.
> >
> > Regards,
> > Madhav
> >
> > From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> > Behalf Of Jakob Korherr
> > >Hi Tomasz,
> > >
> > >That's all correct! However, I don't think he is using Facelets, because
> > he
> > >mentioned JSP-pages...
> > >
> > >Regards,
> > >Jakob
> > >
> > >2010/1/12 Tomasz Pasierb <to...@poczta.fm>
> > >
> > > Hi,
> > >
> > > as I understand you use a commandButton and as a result a different
> page
> > (a
> > > secured one) is rendered but spring security does not seem to intercept
> > the
> > > url, is that right?
> > >
> > > If so and if the solution used by you uses Facelets then this may be
> the
> > > problem.
> > > When using Facelets as opposed to "pure" (older) jsf+jsp approach there
> > is
> > > no forward when a new view is rendered that is a result of a navigation
> > case
> > > forward. I've been investigating this recently. When JSP view handler
> is
> > > used it checks which view should be rendered next and does a forward to
> > this
> > > new view which spring security can intercept. The Facelet view handler
> > > however seems to load the view (xhtml) and render it without making the
> > > actual forward. As a result no interception can happen and usually it
> is
> > > triggered with the next request.
> > > You need to either use redirects or make GET requests to logically
> > separate
> > > views - I know this is not natural with jsf versions prior to 2.0, but
> > this
> > > new spec seems to change everything :-) - use can easily generate GET
> > > requests with the new version.
> > >
> > > Hope this helps ;)
> > >
> > > Regards,
> > > Tom Pasierb
> > >
> > > Madhav Bhargava pisze:
> > >
> > > Hi All,
> > >>
> > >> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring security
> > >> -2.0.5, WAS 6.0 (app server)
> > >>
> > >> I have configured spring security for my JSF application along with
> > >> SiteMinder as an external authentication mechanism. It works fine till
> a
> > >> forward happens from within myfaces.
> > >>
> > >> Here is my spring servlet filter chain declaration:
> > >> <filter>
> > >> <description>
> > >> Spring delegating filter which will
> > >> initiate the spring
> > >> security filter chain
> > >> </description>
> > >> <display-name>springSecurityFilterChain</display-name>
> > >> <filter-name>springSecurityFilterChain</filter-name>
> > >> <filter-class>
> > >>
> > >> org.springframework.web.filter.DelegatingFilterProxy
> > >> </filter-class>
> > >> </filter>
> > >>
> > >> <filter-mapping>
> > >> <filter-name>springSecurityFilterChain</filter-name>
> > >> <url-pattern>/*</url-pattern>
> > >> <dispatcher>FORWARD</dispatcher>
> > >> <dispatcher>REQUEST</dispatcher>
> > >> </filter-mapping>
> > >>
> > >> And in my spring application context I have followed the advice from
> > >> spring forums and done necessary settings:
> > >> Excerpt is:
> > >>
> > >> <security:http
> > >>
> > >> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint"
> > >> once-per-request="false">
> > >> <security:intercept-url pattern="/index.jsp"
> > filters="none"
> > >> />
> > >> <security:intercept-url pattern="/login.jsp"
> > filters="none"
> > >> />
> > >> <security:intercept-url
> pattern="/authenticationservlet"
> > >> filters="none"/>
> > >> <security:intercept-url pattern="**/jsp/common/**"
> > >> filters="none"/>
> > >> <security:intercept-url pattern="/**/css/**"
> > >> filters="none"/>
> > >> <security:intercept-url pattern="/**/*.js"
> > filters="none"/>
> > >> <security:intercept-url pattern="/images/**"
> > >> filters="none"/>
> > >> <security:intercept-url pattern="/**/secure/**"
> > >> access="ROLE_USER" />
> > >> <security:intercept-url pattern="/**/operations/**"
> > >> access="ROLE_OPERATIONS"/>
> > >> <security:intercept-url pattern="/**"
> > >> access="IS_AUTHENTICATED_ANONYMOUSLY" />
> > >> </security:http>
> > >>
> > >> Now when I forward a request from index.jsp to login.jsp then the
> spring
> > >> filters are called with the login.jsp URL even though the browser
> shows
> > the
> > >> old URL.
> > >>
> > >> However when from within an action method a navigation case is handled
> > >> then it is not intercepted by the spring filters at all. However if I
> > give a
> > >> <redirect/> then it is properly intercepted with the correct URL as
> > >> expected.
> > >>
> > >> What can be the reason?
> > >>
> > >> Regards,
> > >> Madhav
> > >>
> > >>
> > >>
> > >
> >
> >
>
Re: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Jakob Korherr <ja...@gmail.com>.
Can you sort out if the filter itself is not called or if the filter behaves
wrong?
2010/1/13 Madhav Bhargava <Ma...@infosys.com>
> Yeah this is the place.
> Back to the problem. I still cannot come up with a workaround :(
>
> From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> Behalf Of Jakob Korherr
> >The "magic" happens in JspViewHandlerImpl's renderView() method:
> >
> >public void renderView(FacesContext facesContext, UIViewRoot viewToRender)
> > throws IOException, FacesException {
> > externalContext.dispatch(viewId);
> > ....
> >
> > }
> >
> >Regards,
> >Jakob
> >
> >2010/1/13 Madhav Bhargava <Ma...@infosys.com>
> >
> > Yes, I am not using facelets.
> > I had a look at the NavigationHandlerImpl and here is the excerpt from
> it:
> >
> > Method: handleNavigation
> >
> > if (navigationCase != null)
> > {
> > if (log.isTraceEnabled())
> > {
> > log.trace("handleNavigation fromAction=" + fromAction + "
> > outcome=" + outcome +
> > " toViewId =" + navigationCase.getToViewId() +
> > " redirect=" + navigationCase.isRedirect());
> > }
> > if (navigationCase.isRedirect() &&
> > (!PortletUtil.isPortletRequest(facesContext)))
> > { // Spec section 7.4.2 says "redirects not possible" in this
> > case for portlets
> > ExternalContext externalContext =
> > facesContext.getExternalContext();
> > ViewHandler viewHandler =
> > facesContext.getApplication().getViewHandler();
> > String redirectPath =
> viewHandler.getActionURL(facesContext,
> > navigationCase.getToViewId());
> >
> > try
> > {
> >
> > externalContext.redirect(externalContext.encodeActionURL(redirectPath));
> > }
> > catch (IOException e)
> > {
> > throw new FacesException(e.getMessage(), e);
> > }
> > }
> > else
> > {
> > ViewHandler viewHandler =
> > facesContext.getApplication().getViewHandler();
> > //create new view
> > String newViewId = navigationCase.getToViewId();
> > UIViewRoot viewRoot = null;
> > if (isPartialStateSavingOn(facesContext)) {
> > viewRoot =
> > viewHandler.restoreView(facesContext,newViewId);
> > } else {
> > viewRoot = viewHandler.createView(facesContext,
> > newViewId);
> > }
> > facesContext.setViewRoot(viewRoot);
> > facesContext.renderResponse();
> > }
> >
> > In the above code, redirect happens properly however for a forward there
> is
> > no RequestDispatcher.forward or ExternalContext.dispatch called. So I do
> not
> > know where a forward happens.
> >
> > Regards,
> > Madhav
> >
> > From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> > Behalf Of Jakob Korherr
> > >Hi Tomasz,
> > >
> > >That's all correct! However, I don't think he is using Facelets, because
> > he
> > >mentioned JSP-pages...
> > >
> > >Regards,
> > >Jakob
> > >
> > >2010/1/12 Tomasz Pasierb <to...@poczta.fm>
> > >
> > > Hi,
> > >
> > > as I understand you use a commandButton and as a result a different
> page
> > (a
> > > secured one) is rendered but spring security does not seem to intercept
> > the
> > > url, is that right?
> > >
> > > If so and if the solution used by you uses Facelets then this may be
> the
> > > problem.
> > > When using Facelets as opposed to "pure" (older) jsf+jsp approach there
> > is
> > > no forward when a new view is rendered that is a result of a navigation
> > case
> > > forward. I've been investigating this recently. When JSP view handler
> is
> > > used it checks which view should be rendered next and does a forward to
> > this
> > > new view which spring security can intercept. The Facelet view handler
> > > however seems to load the view (xhtml) and render it without making the
> > > actual forward. As a result no interception can happen and usually it
> is
> > > triggered with the next request.
> > > You need to either use redirects or make GET requests to logically
> > separate
> > > views - I know this is not natural with jsf versions prior to 2.0, but
> > this
> > > new spec seems to change everything :-) - use can easily generate GET
> > > requests with the new version.
> > >
> > > Hope this helps ;)
> > >
> > > Regards,
> > > Tom Pasierb
> > >
> > > Madhav Bhargava pisze:
> > >
> > > Hi All,
> > >>
> > >> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring security
> > >> -2.0.5, WAS 6.0 (app server)
> > >>
> > >> I have configured spring security for my JSF application along with
> > >> SiteMinder as an external authentication mechanism. It works fine till
> a
> > >> forward happens from within myfaces.
> > >>
> > >> Here is my spring servlet filter chain declaration:
> > >> <filter>
> > >> <description>
> > >> Spring delegating filter which will
> > >> initiate the spring
> > >> security filter chain
> > >> </description>
> > >> <display-name>springSecurityFilterChain</display-name>
> > >> <filter-name>springSecurityFilterChain</filter-name>
> > >> <filter-class>
> > >>
> > >> org.springframework.web.filter.DelegatingFilterProxy
> > >> </filter-class>
> > >> </filter>
> > >>
> > >> <filter-mapping>
> > >> <filter-name>springSecurityFilterChain</filter-name>
> > >> <url-pattern>/*</url-pattern>
> > >> <dispatcher>FORWARD</dispatcher>
> > >> <dispatcher>REQUEST</dispatcher>
> > >> </filter-mapping>
> > >>
> > >> And in my spring application context I have followed the advice from
> > >> spring forums and done necessary settings:
> > >> Excerpt is:
> > >>
> > >> <security:http
> > >>
> > >> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint"
> > >> once-per-request="false">
> > >> <security:intercept-url pattern="/index.jsp"
> > filters="none"
> > >> />
> > >> <security:intercept-url pattern="/login.jsp"
> > filters="none"
> > >> />
> > >> <security:intercept-url
> pattern="/authenticationservlet"
> > >> filters="none"/>
> > >> <security:intercept-url pattern="**/jsp/common/**"
> > >> filters="none"/>
> > >> <security:intercept-url pattern="/**/css/**"
> > >> filters="none"/>
> > >> <security:intercept-url pattern="/**/*.js"
> > filters="none"/>
> > >> <security:intercept-url pattern="/images/**"
> > >> filters="none"/>
> > >> <security:intercept-url pattern="/**/secure/**"
> > >> access="ROLE_USER" />
> > >> <security:intercept-url pattern="/**/operations/**"
> > >> access="ROLE_OPERATIONS"/>
> > >> <security:intercept-url pattern="/**"
> > >> access="IS_AUTHENTICATED_ANONYMOUSLY" />
> > >> </security:http>
> > >>
> > >> Now when I forward a request from index.jsp to login.jsp then the
> spring
> > >> filters are called with the login.jsp URL even though the browser
> shows
> > the
> > >> old URL.
> > >>
> > >> However when from within an action method a navigation case is handled
> > >> then it is not intercepted by the spring filters at all. However if I
> > give a
> > >> <redirect/> then it is properly intercepted with the correct URL as
> > >> expected.
> > >>
> > >> What can be the reason?
> > >>
> > >> Regards,
> > >> Madhav
> > >>
> > >>
> > >>
> > >
> >
> >
>
RE: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Madhav Bhargava <Ma...@infosys.com>.
Yeah this is the place.
Back to the problem. I still cannot come up with a workaround :(
From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On Behalf Of Jakob Korherr
>The "magic" happens in JspViewHandlerImpl's renderView() method:
>
>public void renderView(FacesContext facesContext, UIViewRoot viewToRender)
> throws IOException, FacesException {
> externalContext.dispatch(viewId);
> ....
>
> }
>
>Regards,
>Jakob
>
>2010/1/13 Madhav Bhargava <Ma...@infosys.com>
>
> Yes, I am not using facelets.
> I had a look at the NavigationHandlerImpl and here is the excerpt from it:
>
> Method: handleNavigation
>
> if (navigationCase != null)
> {
> if (log.isTraceEnabled())
> {
> log.trace("handleNavigation fromAction=" + fromAction + "
> outcome=" + outcome +
> " toViewId =" + navigationCase.getToViewId() +
> " redirect=" + navigationCase.isRedirect());
> }
> if (navigationCase.isRedirect() &&
> (!PortletUtil.isPortletRequest(facesContext)))
> { // Spec section 7.4.2 says "redirects not possible" in this
> case for portlets
> ExternalContext externalContext =
> facesContext.getExternalContext();
> ViewHandler viewHandler =
> facesContext.getApplication().getViewHandler();
> String redirectPath = viewHandler.getActionURL(facesContext,
> navigationCase.getToViewId());
>
> try
> {
>
> externalContext.redirect(externalContext.encodeActionURL(redirectPath));
> }
> catch (IOException e)
> {
> throw new FacesException(e.getMessage(), e);
> }
> }
> else
> {
> ViewHandler viewHandler =
> facesContext.getApplication().getViewHandler();
> //create new view
> String newViewId = navigationCase.getToViewId();
> UIViewRoot viewRoot = null;
> if (isPartialStateSavingOn(facesContext)) {
> viewRoot =
> viewHandler.restoreView(facesContext,newViewId);
> } else {
> viewRoot = viewHandler.createView(facesContext,
> newViewId);
> }
> facesContext.setViewRoot(viewRoot);
> facesContext.renderResponse();
> }
>
> In the above code, redirect happens properly however for a forward there is
> no RequestDispatcher.forward or ExternalContext.dispatch called. So I do not
> know where a forward happens.
>
> Regards,
> Madhav
>
> From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> Behalf Of Jakob Korherr
> >Hi Tomasz,
> >
> >That's all correct! However, I don't think he is using Facelets, because
> he
> >mentioned JSP-pages...
> >
> >Regards,
> >Jakob
> >
> >2010/1/12 Tomasz Pasierb <to...@poczta.fm>
> >
> > Hi,
> >
> > as I understand you use a commandButton and as a result a different page
> (a
> > secured one) is rendered but spring security does not seem to intercept
> the
> > url, is that right?
> >
> > If so and if the solution used by you uses Facelets then this may be the
> > problem.
> > When using Facelets as opposed to "pure" (older) jsf+jsp approach there
> is
> > no forward when a new view is rendered that is a result of a navigation
> case
> > forward. I've been investigating this recently. When JSP view handler is
> > used it checks which view should be rendered next and does a forward to
> this
> > new view which spring security can intercept. The Facelet view handler
> > however seems to load the view (xhtml) and render it without making the
> > actual forward. As a result no interception can happen and usually it is
> > triggered with the next request.
> > You need to either use redirects or make GET requests to logically
> separate
> > views - I know this is not natural with jsf versions prior to 2.0, but
> this
> > new spec seems to change everything :-) - use can easily generate GET
> > requests with the new version.
> >
> > Hope this helps ;)
> >
> > Regards,
> > Tom Pasierb
> >
> > Madhav Bhargava pisze:
> >
> > Hi All,
> >>
> >> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring security
> >> -2.0.5, WAS 6.0 (app server)
> >>
> >> I have configured spring security for my JSF application along with
> >> SiteMinder as an external authentication mechanism. It works fine till a
> >> forward happens from within myfaces.
> >>
> >> Here is my spring servlet filter chain declaration:
> >> <filter>
> >> <description>
> >> Spring delegating filter which will
> >> initiate the spring
> >> security filter chain
> >> </description>
> >> <display-name>springSecurityFilterChain</display-name>
> >> <filter-name>springSecurityFilterChain</filter-name>
> >> <filter-class>
> >>
> >> org.springframework.web.filter.DelegatingFilterProxy
> >> </filter-class>
> >> </filter>
> >>
> >> <filter-mapping>
> >> <filter-name>springSecurityFilterChain</filter-name>
> >> <url-pattern>/*</url-pattern>
> >> <dispatcher>FORWARD</dispatcher>
> >> <dispatcher>REQUEST</dispatcher>
> >> </filter-mapping>
> >>
> >> And in my spring application context I have followed the advice from
> >> spring forums and done necessary settings:
> >> Excerpt is:
> >>
> >> <security:http
> >>
> >> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint"
> >> once-per-request="false">
> >> <security:intercept-url pattern="/index.jsp"
> filters="none"
> >> />
> >> <security:intercept-url pattern="/login.jsp"
> filters="none"
> >> />
> >> <security:intercept-url pattern="/authenticationservlet"
> >> filters="none"/>
> >> <security:intercept-url pattern="**/jsp/common/**"
> >> filters="none"/>
> >> <security:intercept-url pattern="/**/css/**"
> >> filters="none"/>
> >> <security:intercept-url pattern="/**/*.js"
> filters="none"/>
> >> <security:intercept-url pattern="/images/**"
> >> filters="none"/>
> >> <security:intercept-url pattern="/**/secure/**"
> >> access="ROLE_USER" />
> >> <security:intercept-url pattern="/**/operations/**"
> >> access="ROLE_OPERATIONS"/>
> >> <security:intercept-url pattern="/**"
> >> access="IS_AUTHENTICATED_ANONYMOUSLY" />
> >> </security:http>
> >>
> >> Now when I forward a request from index.jsp to login.jsp then the spring
> >> filters are called with the login.jsp URL even though the browser shows
> the
> >> old URL.
> >>
> >> However when from within an action method a navigation case is handled
> >> then it is not intercepted by the spring filters at all. However if I
> give a
> >> <redirect/> then it is properly intercepted with the correct URL as
> >> expected.
> >>
> >> What can be the reason?
> >>
> >> Regards,
> >> Madhav
> >>
> >>
> >>
> >
>
>
Re: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Jakob Korherr <ja...@gmail.com>.
The "magic" happens in JspViewHandlerImpl's renderView() method:
public void renderView(FacesContext facesContext, UIViewRoot viewToRender)
throws IOException, FacesException {
...
externalContext.dispatch(viewId);
....
}
Regards,
Jakob
2010/1/13 Madhav Bhargava <Ma...@infosys.com>
> Yes, I am not using facelets.
> I had a look at the NavigationHandlerImpl and here is the excerpt from it:
>
> Method: handleNavigation
>
> if (navigationCase != null)
> {
> if (log.isTraceEnabled())
> {
> log.trace("handleNavigation fromAction=" + fromAction + "
> outcome=" + outcome +
> " toViewId =" + navigationCase.getToViewId() +
> " redirect=" + navigationCase.isRedirect());
> }
> if (navigationCase.isRedirect() &&
> (!PortletUtil.isPortletRequest(facesContext)))
> { // Spec section 7.4.2 says "redirects not possible" in this
> case for portlets
> ExternalContext externalContext =
> facesContext.getExternalContext();
> ViewHandler viewHandler =
> facesContext.getApplication().getViewHandler();
> String redirectPath = viewHandler.getActionURL(facesContext,
> navigationCase.getToViewId());
>
> try
> {
>
> externalContext.redirect(externalContext.encodeActionURL(redirectPath));
> }
> catch (IOException e)
> {
> throw new FacesException(e.getMessage(), e);
> }
> }
> else
> {
> ViewHandler viewHandler =
> facesContext.getApplication().getViewHandler();
> //create new view
> String newViewId = navigationCase.getToViewId();
> UIViewRoot viewRoot = null;
> if (isPartialStateSavingOn(facesContext)) {
> viewRoot =
> viewHandler.restoreView(facesContext,newViewId);
> } else {
> viewRoot = viewHandler.createView(facesContext,
> newViewId);
> }
> facesContext.setViewRoot(viewRoot);
> facesContext.renderResponse();
> }
>
> In the above code, redirect happens properly however for a forward there is
> no RequestDispatcher.forward or ExternalContext.dispatch called. So I do not
> know where a forward happens.
>
> Regards,
> Madhav
>
> From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On
> Behalf Of Jakob Korherr
> >Hi Tomasz,
> >
> >That's all correct! However, I don't think he is using Facelets, because
> he
> >mentioned JSP-pages...
> >
> >Regards,
> >Jakob
> >
> >2010/1/12 Tomasz Pasierb <to...@poczta.fm>
> >
> > Hi,
> >
> > as I understand you use a commandButton and as a result a different page
> (a
> > secured one) is rendered but spring security does not seem to intercept
> the
> > url, is that right?
> >
> > If so and if the solution used by you uses Facelets then this may be the
> > problem.
> > When using Facelets as opposed to "pure" (older) jsf+jsp approach there
> is
> > no forward when a new view is rendered that is a result of a navigation
> case
> > forward. I've been investigating this recently. When JSP view handler is
> > used it checks which view should be rendered next and does a forward to
> this
> > new view which spring security can intercept. The Facelet view handler
> > however seems to load the view (xhtml) and render it without making the
> > actual forward. As a result no interception can happen and usually it is
> > triggered with the next request.
> > You need to either use redirects or make GET requests to logically
> separate
> > views - I know this is not natural with jsf versions prior to 2.0, but
> this
> > new spec seems to change everything :-) - use can easily generate GET
> > requests with the new version.
> >
> > Hope this helps ;)
> >
> > Regards,
> > Tom Pasierb
> >
> > Madhav Bhargava pisze:
> >
> > Hi All,
> >>
> >> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring security
> >> -2.0.5, WAS 6.0 (app server)
> >>
> >> I have configured spring security for my JSF application along with
> >> SiteMinder as an external authentication mechanism. It works fine till a
> >> forward happens from within myfaces.
> >>
> >> Here is my spring servlet filter chain declaration:
> >> <filter>
> >> <description>
> >> Spring delegating filter which will
> >> initiate the spring
> >> security filter chain
> >> </description>
> >> <display-name>springSecurityFilterChain</display-name>
> >> <filter-name>springSecurityFilterChain</filter-name>
> >> <filter-class>
> >>
> >> org.springframework.web.filter.DelegatingFilterProxy
> >> </filter-class>
> >> </filter>
> >>
> >> <filter-mapping>
> >> <filter-name>springSecurityFilterChain</filter-name>
> >> <url-pattern>/*</url-pattern>
> >> <dispatcher>FORWARD</dispatcher>
> >> <dispatcher>REQUEST</dispatcher>
> >> </filter-mapping>
> >>
> >> And in my spring application context I have followed the advice from
> >> spring forums and done necessary settings:
> >> Excerpt is:
> >>
> >> <security:http
> >>
> >> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint"
> >> once-per-request="false">
> >> <security:intercept-url pattern="/index.jsp"
> filters="none"
> >> />
> >> <security:intercept-url pattern="/login.jsp"
> filters="none"
> >> />
> >> <security:intercept-url pattern="/authenticationservlet"
> >> filters="none"/>
> >> <security:intercept-url pattern="**/jsp/common/**"
> >> filters="none"/>
> >> <security:intercept-url pattern="/**/css/**"
> >> filters="none"/>
> >> <security:intercept-url pattern="/**/*.js"
> filters="none"/>
> >> <security:intercept-url pattern="/images/**"
> >> filters="none"/>
> >> <security:intercept-url pattern="/**/secure/**"
> >> access="ROLE_USER" />
> >> <security:intercept-url pattern="/**/operations/**"
> >> access="ROLE_OPERATIONS"/>
> >> <security:intercept-url pattern="/**"
> >> access="IS_AUTHENTICATED_ANONYMOUSLY" />
> >> </security:http>
> >>
> >> Now when I forward a request from index.jsp to login.jsp then the spring
> >> filters are called with the login.jsp URL even though the browser shows
> the
> >> old URL.
> >>
> >> However when from within an action method a navigation case is handled
> >> then it is not intercepted by the spring filters at all. However if I
> give a
> >> <redirect/> then it is properly intercepted with the correct URL as
> >> expected.
> >>
> >> What can be the reason?
> >>
> >> Regards,
> >> Madhav
> >>
> >>
> >>
> >
>
>
RE: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Madhav Bhargava <Ma...@infosys.com>.
Yes, I am not using facelets.
I had a look at the NavigationHandlerImpl and here is the excerpt from it:
Method: handleNavigation
if (navigationCase != null)
{
if (log.isTraceEnabled())
{
log.trace("handleNavigation fromAction=" + fromAction + " outcome=" + outcome +
" toViewId =" + navigationCase.getToViewId() +
" redirect=" + navigationCase.isRedirect());
}
if (navigationCase.isRedirect() &&
(!PortletUtil.isPortletRequest(facesContext)))
{ // Spec section 7.4.2 says "redirects not possible" in this case for portlets
ExternalContext externalContext = facesContext.getExternalContext();
ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
String redirectPath = viewHandler.getActionURL(facesContext, navigationCase.getToViewId());
try
{
externalContext.redirect(externalContext.encodeActionURL(redirectPath));
}
catch (IOException e)
{
throw new FacesException(e.getMessage(), e);
}
}
else
{
ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
//create new view
String newViewId = navigationCase.getToViewId();
UIViewRoot viewRoot = null;
if (isPartialStateSavingOn(facesContext)) {
viewRoot = viewHandler.restoreView(facesContext,newViewId);
} else {
viewRoot = viewHandler.createView(facesContext, newViewId);
}
facesContext.setViewRoot(viewRoot);
facesContext.renderResponse();
}
In the above code, redirect happens properly however for a forward there is no RequestDispatcher.forward or ExternalContext.dispatch called. So I do not know where a forward happens.
Regards,
Madhav
From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On Behalf Of Jakob Korherr
>Hi Tomasz,
>
>That's all correct! However, I don't think he is using Facelets, because he
>mentioned JSP-pages...
>
>Regards,
>Jakob
>
>2010/1/12 Tomasz Pasierb <to...@poczta.fm>
>
> Hi,
>
> as I understand you use a commandButton and as a result a different page (a
> secured one) is rendered but spring security does not seem to intercept the
> url, is that right?
>
> If so and if the solution used by you uses Facelets then this may be the
> problem.
> When using Facelets as opposed to "pure" (older) jsf+jsp approach there is
> no forward when a new view is rendered that is a result of a navigation case
> forward. I've been investigating this recently. When JSP view handler is
> used it checks which view should be rendered next and does a forward to this
> new view which spring security can intercept. The Facelet view handler
> however seems to load the view (xhtml) and render it without making the
> actual forward. As a result no interception can happen and usually it is
> triggered with the next request.
> You need to either use redirects or make GET requests to logically separate
> views - I know this is not natural with jsf versions prior to 2.0, but this
> new spec seems to change everything :-) - use can easily generate GET
> requests with the new version.
>
> Hope this helps ;)
>
> Regards,
> Tom Pasierb
>
> Madhav Bhargava pisze:
>
> Hi All,
>>
>> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring security
>> -2.0.5, WAS 6.0 (app server)
>>
>> I have configured spring security for my JSF application along with
>> SiteMinder as an external authentication mechanism. It works fine till a
>> forward happens from within myfaces.
>>
>> Here is my spring servlet filter chain declaration:
>> <filter>
>> <description>
>> Spring delegating filter which will
>> initiate the spring
>> security filter chain
>> </description>
>> <display-name>springSecurityFilterChain</display-name>
>> <filter-name>springSecurityFilterChain</filter-name>
>> <filter-class>
>>
>> org.springframework.web.filter.DelegatingFilterProxy
>> </filter-class>
>> </filter>
>>
>> <filter-mapping>
>> <filter-name>springSecurityFilterChain</filter-name>
>> <url-pattern>/*</url-pattern>
>> <dispatcher>FORWARD</dispatcher>
>> <dispatcher>REQUEST</dispatcher>
>> </filter-mapping>
>>
>> And in my spring application context I have followed the advice from
>> spring forums and done necessary settings:
>> Excerpt is:
>>
>> <security:http
>>
>> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint"
>> once-per-request="false">
>> <security:intercept-url pattern="/index.jsp" filters="none"
>> />
>> <security:intercept-url pattern="/login.jsp" filters="none"
>> />
>> <security:intercept-url pattern="/authenticationservlet"
>> filters="none"/>
>> <security:intercept-url pattern="**/jsp/common/**"
>> filters="none"/>
>> <security:intercept-url pattern="/**/css/**"
>> filters="none"/>
>> <security:intercept-url pattern="/**/*.js" filters="none"/>
>> <security:intercept-url pattern="/images/**"
>> filters="none"/>
>> <security:intercept-url pattern="/**/secure/**"
>> access="ROLE_USER" />
>> <security:intercept-url pattern="/**/operations/**"
>> access="ROLE_OPERATIONS"/>
>> <security:intercept-url pattern="/**"
>> access="IS_AUTHENTICATED_ANONYMOUSLY" />
>> </security:http>
>>
>> Now when I forward a request from index.jsp to login.jsp then the spring
>> filters are called with the login.jsp URL even though the browser shows the
>> old URL.
>>
>> However when from within an action method a navigation case is handled
>> then it is not intercepted by the spring filters at all. However if I give a
>> <redirect/> then it is properly intercepted with the correct URL as
>> expected.
>>
>> What can be the reason?
>>
>> Regards,
>> Madhav
>>
>>
>>
>
Re: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Jakob Korherr <ja...@gmail.com>.
Hi Tomasz,
That's all correct! However, I don't think he is using Facelets, because he
mentioned JSP-pages...
Regards,
Jakob
2010/1/12 Tomasz Pasierb <to...@poczta.fm>
> Hi,
>
> as I understand you use a commandButton and as a result a different page (a
> secured one) is rendered but spring security does not seem to intercept the
> url, is that right?
>
> If so and if the solution used by you uses Facelets then this may be the
> problem.
> When using Facelets as opposed to "pure" (older) jsf+jsp approach there is
> no forward when a new view is rendered that is a result of a navigation case
> forward. I've been investigating this recently. When JSP view handler is
> used it checks which view should be rendered next and does a forward to this
> new view which spring security can intercept. The Facelet view handler
> however seems to load the view (xhtml) and render it without making the
> actual forward. As a result no interception can happen and usually it is
> triggered with the next request.
> You need to either use redirects or make GET requests to logically separate
> views - I know this is not natural with jsf versions prior to 2.0, but this
> new spec seems to change everything :-) - use can easily generate GET
> requests with the new version.
>
> Hope this helps ;)
>
> Regards,
> Tom Pasierb
>
> Madhav Bhargava pisze:
>
> Hi All,
>>
>> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring security
>> -2.0.5, WAS 6.0 (app server)
>>
>> I have configured spring security for my JSF application along with
>> SiteMinder as an external authentication mechanism. It works fine till a
>> forward happens from within myfaces.
>>
>> Here is my spring servlet filter chain declaration:
>> <filter>
>> <description>
>> Spring delegating filter which will
>> initiate the spring
>> security filter chain
>> </description>
>> <display-name>springSecurityFilterChain</display-name>
>> <filter-name>springSecurityFilterChain</filter-name>
>> <filter-class>
>>
>> org.springframework.web.filter.DelegatingFilterProxy
>> </filter-class>
>> </filter>
>>
>> <filter-mapping>
>> <filter-name>springSecurityFilterChain</filter-name>
>> <url-pattern>/*</url-pattern>
>> <dispatcher>FORWARD</dispatcher>
>> <dispatcher>REQUEST</dispatcher>
>> </filter-mapping>
>>
>> And in my spring application context I have followed the advice from
>> spring forums and done necessary settings:
>> Excerpt is:
>>
>> <security:http
>>
>> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint"
>> once-per-request="false">
>> <security:intercept-url pattern="/index.jsp" filters="none"
>> />
>> <security:intercept-url pattern="/login.jsp" filters="none"
>> />
>> <security:intercept-url pattern="/authenticationservlet"
>> filters="none"/>
>> <security:intercept-url pattern="**/jsp/common/**"
>> filters="none"/>
>> <security:intercept-url pattern="/**/css/**"
>> filters="none"/>
>> <security:intercept-url pattern="/**/*.js" filters="none"/>
>> <security:intercept-url pattern="/images/**"
>> filters="none"/>
>> <security:intercept-url pattern="/**/secure/**"
>> access="ROLE_USER" />
>> <security:intercept-url pattern="/**/operations/**"
>> access="ROLE_OPERATIONS"/>
>> <security:intercept-url pattern="/**"
>> access="IS_AUTHENTICATED_ANONYMOUSLY" />
>> </security:http>
>>
>> Now when I forward a request from index.jsp to login.jsp then the spring
>> filters are called with the login.jsp URL even though the browser shows the
>> old URL.
>>
>> However when from within an action method a navigation case is handled
>> then it is not intercepted by the spring filters at all. However if I give a
>> <redirect/> then it is properly intercepted with the correct URL as
>> expected.
>>
>> What can be the reason?
>>
>> Regards,
>> Madhav
>>
>>
>>
>
Re: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Tomasz Pasierb <to...@poczta.fm>.
Hi,
as I understand you use a commandButton and as a result a different page
(a secured one) is rendered but spring security does not seem to
intercept the url, is that right?
If so and if the solution used by you uses Facelets then this may be the
problem.
When using Facelets as opposed to "pure" (older) jsf+jsp approach there
is no forward when a new view is rendered that is a result of a
navigation case forward. I've been investigating this recently. When JSP
view handler is used it checks which view should be rendered next and
does a forward to this new view which spring security can intercept. The
Facelet view handler however seems to load the view (xhtml) and render
it without making the actual forward. As a result no interception can
happen and usually it is triggered with the next request.
You need to either use redirects or make GET requests to logically
separate views - I know this is not natural with jsf versions prior to
2.0, but this new spec seems to change everything :-) - use can easily
generate GET requests with the new version.
Hope this helps ;)
Regards,
Tom Pasierb
Madhav Bhargava pisze:
> Hi All,
>
> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring security -2.0.5, WAS 6.0 (app server)
>
> I have configured spring security for my JSF application along with SiteMinder as an external authentication mechanism. It works fine till a forward happens from within myfaces.
>
> Here is my spring servlet filter chain declaration:
> <filter>
> <description>
> Spring delegating filter which will initiate the spring
> security filter chain
> </description>
> <display-name>springSecurityFilterChain</display-name>
> <filter-name>springSecurityFilterChain</filter-name>
> <filter-class>
> org.springframework.web.filter.DelegatingFilterProxy
> </filter-class>
> </filter>
>
> <filter-mapping>
> <filter-name>springSecurityFilterChain</filter-name>
> <url-pattern>/*</url-pattern>
> <dispatcher>FORWARD</dispatcher>
> <dispatcher>REQUEST</dispatcher>
> </filter-mapping>
>
> And in my spring application context I have followed the advice from spring forums and done necessary settings:
> Excerpt is:
>
> <security:http
> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint" once-per-request="false">
> <security:intercept-url pattern="/index.jsp" filters="none" />
> <security:intercept-url pattern="/login.jsp" filters="none" />
> <security:intercept-url pattern="/authenticationservlet" filters="none"/>
> <security:intercept-url pattern="**/jsp/common/**" filters="none"/>
> <security:intercept-url pattern="/**/css/**" filters="none"/>
> <security:intercept-url pattern="/**/*.js" filters="none"/>
> <security:intercept-url pattern="/images/**" filters="none"/>
> <security:intercept-url pattern="/**/secure/**" access="ROLE_USER" />
> <security:intercept-url pattern="/**/operations/**" access="ROLE_OPERATIONS"/>
> <security:intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
> </security:http>
>
> Now when I forward a request from index.jsp to login.jsp then the spring filters are called with the login.jsp URL even though the browser shows the old URL.
>
> However when from within an action method a navigation case is handled then it is not intercepted by the spring filters at all. However if I give a <redirect/> then it is properly intercepted with the correct URL as expected.
>
> What can be the reason?
>
> Regards,
> Madhav
>
>
Re: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Jakob Korherr <ja...@gmail.com>.
One more: Tried MyFilter in a JSF application which first renders index.jsp,
then a commandButton is hit and the action method "forwards" to index2.jsp.
Here is the filter-output of the first request:
Filter1 (forward + request) invoked for path /faces/index.jsp
Filter1 (forward + request) invoked for path /index.jsp
...and for the second request:
Filter1 (forward + request) invoked for path /faces/index.jsp
Filter1 (forward + request) invoked for path /index2.jsp
So here you can see the original faces request (1st lines, including
/faces/) and the rendering forward (2nd lines).
This shows that the filter is invoked properly. so your problem is maybe
related to spring...
2010/1/12 Jakob Korherr <ja...@gmail.com>
> I'm really sorry, but there seemed to be some configuration problem with my
> local tomcat. The filter _is_ called twice.
>
> My example:
>
> web.xml (excerpt):
>
> <servlet>
> <servlet-name>Servlet1</servlet-name>
> <servlet-class>at.jakobkorherr.servlets.Servlet1</servlet-class>
> </servlet>
> <servlet>
> <servlet-name>Servlet2</servlet-name>
> <servlet-class>at.jakobkorherr.servlets.Servlet2</servlet-class>
> </servlet>
> <servlet-mapping>
> <servlet-name>Servlet1</servlet-name>
> <url-pattern>/Servlet1</url-pattern>
> </servlet-mapping>
> <servlet-mapping>
> <servlet-name>Servlet2</servlet-name>
> <url-pattern>/Servlet2</url-pattern>
> </servlet-mapping>
> <filter>
> <filter-name>MyFilter</filter-name>
> <filter-class>at.jakobkorherr.filter.MyFilter</filter-class>
> </filter>
> <filter-mapping>
> <filter-name>MyFilter</filter-name>
>
> <url-pattern>/*</url-pattern>
> <dispatcher>FORWARD</dispatcher>
> <dispatcher>REQUEST</dispatcher>
> </filter-mapping>
>
> Servlet1.java (excerpt):
>
> public void service(ServletRequest request, ServletResponse response)
> throws ServletException, IOException
> {
> System.out.println("Servlet1");
> request.getRequestDispatcher("/Servlet2").forward(request,
> response);
> }
>
> Servlet2.java (excerpt):
>
> public void service(ServletRequest request, ServletResponse response)
> throws ServletException, IOException
> {
> System.out.println("Servlet2");
> response.getWriter().println("Servlet2");
> }
>
> MyFilter.java (excerpt):
>
> public void doFilter(ServletRequest request, ServletResponse response,
> FilterChain chain) throws IOException, ServletException
> {
> System.out.println("Filter1 (forward + request) invoked for path "
> + ((HttpServletRequest) request).getServletPath());
> chain.doFilter(request, response);
> }
>
>
> When requesting Servlet1, the following output is generated (on the
> console):
>
> Filter1 (forward + request) invoked for path /Servlet1
> Servlet1
> Filter1 (forward + request) invoked for path /Servlet2
> Servlet2
>
> So this should function properly.
>
>
> 2010/1/12 Jakob Korherr <ja...@gmail.com>
>
> "The filter for JSF forwards is not getting invoked at all."
>>
>> That's exactly what I was saying!!!! ...and it does not help you if you
>> set <security:http once-per-request="false"...>, because the filter is only
>> invoked once anyway.
>>
>> Madhav's problem is that the Filter itself is only invoked once for the
>> request (at the time when the user makes the request), although there is a
>> internal forward with the RequestDispatcher.
>>
>> So the problem is that the same Filter is not invoked twice for one
>> request (at first for REQUEST and then for FORWARD).
>>
>>
>> Regards,
>> Jakob
>>
>>
>> 2010/1/12 Madhav Bhargava <Ma...@infosys.com>
>>
>>> I had added spring security code in my workspace for debugging reasons
>>> and I suspected that how can a new page be shown when the URL passed to the
>>> filter at the server is old. So I put a dummy filter in front of spring
>>> security just to print out the URL that is getting intercepted by spring
>>> security filter chain.
>>>
>>> So now I find that when a JSF forward happens via NavigationHandler then
>>> there is no URL that is actually intercepted by the spring filter. What I
>>> saw during debugging was not the correct picture.
>>>
>>> SO I am back at the same problem. The filter for JSF forwards is not
>>> getting invoked at all.
>>>
>>> Regards,
>>> Madhav
>>>
>>> From: Madhav Bhargava
>>> >
>>> >Yes, I have made the appropriate configuration for spring security
>>> filters so that specially in the case that >you have described below this
>>> property will make sure that the authentication is done again.
>>> >
>>> >However I do not think that it has anything to do with a stale URL being
>>> passed to the filter at the server >side. I can understand that the browser
>>> will have an old URL but at the server side the URL intercepted by the
>>> >filter should not be stale. Moreover the control is being forwarded to the
>>> correct page and the page is visible >as well so do not know how can a old
>>> ULR be passed at the server side and a new page be displayed at the client
>>> >side.
>>> >
>>> >Thanks,
>>> >Madhav
>>> >
>>> >From: Michael Kurz [mailto:michi.kurz@gmx.at]
>>> >
>>> >Hm, I thought the same first but he has attribute once-per-request set
>>> >to false:
>>> >
>>> ><security:http once-per-request="false"...>
>>> >
>>> >- Michael
>>> >
>>> >Jakob Korherr schrieb:
>>> > Hi Madhav,
>>> >
>>> > I now know what the problem is. I wrote a small test webapp and came to
>>> the
>>> > following conclusion:
>>> >
>>> > JSF uses RequestDispatcher.forward(..) to render the second view. Thus
>>> the
>>> > filter should be invoked for the forward. However, the filter is/was
>>> already
>>> > invoked for the first request and it cannot be invoked twice for one
>>> > request.
>>> >
>>> > Only for test reasons, remove <dispatcher>REQUEST</dispatcher> from
>>> your
>>> > filter config in the web.xml and the filter will be invoked for
>>> > RequestDispatcher.forward(..), because it was not invoked for the
>>> original
>>> > request.
>>> >
>>> > I know this does not solve your problem, but I think there is maybe a
>>> > workaround for this.. I myself just don't know one..
>>> > Maybe define the filter twice would solve the problem, but that's just
>>> a
>>> > guess.
>>> >
>>> > Regards,
>>> > Jakob
>>> >
>>> > 2010/1/12 Madhav Bhargava <Ma...@infosys.com>
>>> >
>>> >>
>>> >> -----Original Message-----
>>> >> From: Michael Kurz [mailto:michi.kurz@gmx.at]
>>> >>
>>> >>> Madhav Bhargava schrieb:
>>> >>> To add if you see the spring security application config, I have the
>>> >> following set:
>>> >>> <security:http>
>>> >>> <security:intercept-url pattern="/**/secure/**"
>>> >> access="ROLE_USER" />
>>> >>> <security:intercept-url pattern="/**/operations/**"
>>> >> access="ROLE_OPERATIONS"/>
>>> >>> </security:http>
>>> >>>
>>> >>> The URL for the outcome to be forwarded to matches the second
>>> interceptor
>>> >> pattern which is "/jsp/operations/user/operationsLanding.iface"
>>> >>> However what the filter receives is "/jsp/secure/hprelanding.jspx"
>>> which
>>> >> is the old URL from where the control is being forwarded. This is not
>>> how it
>>> >> happens when using jsp:forward.
>>> >>
>>> >>> For clarification: Is the navigation to the new page
>>> >>> operationsLanding.iface performed (do you actually see it in the
>>> browser)?
>>> >>>
>>> >>> - Michael
>>> >> Yes,the request is properly forwarded to operationsLanding.jspx and I
>>> can
>>> >> view the page. I had put a breakpoint in one of the spring security
>>> classes
>>> >> and I could see the old URL which got successfully mapped against
>>> pattern
>>> >> /**/secure/** which should not have happened.
>>> >>
>>> >> If I have a normal JSP application where there is no JSF then it works
>>> >> fine. I meant the navigation is not handled by JSF.
>>> >>
>>> >> Regards,
>>> >> Madhav
>>> >>
>>> >
>>>
>>>
>>> **************** CAUTION - Disclaimer *****************
>>> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
>>> solely
>>> for the use of the addressee(s). If you are not the intended recipient,
>>> please
>>> notify the sender by e-mail and delete the original message. Further, you
>>> are not
>>> to copy, disclose, or distribute this e-mail or its contents to any other
>>> person and
>>> any such actions are unlawful. This e-mail may contain viruses. Infosys
>>> has taken
>>> every reasonable precaution to minimize this risk, but is not liable for
>>> any damage
>>> you may sustain as a result of any virus in this e-mail. You should carry
>>> out your
>>> own virus checks before opening the e-mail or attachment. Infosys
>>> reserves the
>>> right to monitor and review the content of all messages sent to or from
>>> this e-mail
>>> address. Messages sent to or from this e-mail address may be stored on
>>> the
>>> Infosys e-mail system.
>>> ***INFOSYS******** End of Disclaimer ********INFOSYS***
>>>
>>
>>
>
Re: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Jakob Korherr <ja...@gmail.com>.
I'm really sorry, but there seemed to be some configuration problem with my
local tomcat. The filter _is_ called twice.
My example:
web.xml (excerpt):
<servlet>
<servlet-name>Servlet1</servlet-name>
<servlet-class>at.jakobkorherr.servlets.Servlet1</servlet-class>
</servlet>
<servlet>
<servlet-name>Servlet2</servlet-name>
<servlet-class>at.jakobkorherr.servlets.Servlet2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Servlet1</servlet-name>
<url-pattern>/Servlet1</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Servlet2</servlet-name>
<url-pattern>/Servlet2</url-pattern>
</servlet-mapping>
<filter>
<filter-name>MyFilter</filter-name>
<filter-class>at.jakobkorherr.filter.MyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>MyFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
Servlet1.java (excerpt):
public void service(ServletRequest request, ServletResponse response)
throws ServletException, IOException
{
System.out.println("Servlet1");
request.getRequestDispatcher("/Servlet2").forward(request,
response);
}
Servlet2.java (excerpt):
public void service(ServletRequest request, ServletResponse response)
throws ServletException, IOException
{
System.out.println("Servlet2");
response.getWriter().println("Servlet2");
}
MyFilter.java (excerpt):
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException
{
System.out.println("Filter1 (forward + request) invoked for path " +
((HttpServletRequest) request).getServletPath());
chain.doFilter(request, response);
}
When requesting Servlet1, the following output is generated (on the
console):
Filter1 (forward + request) invoked for path /Servlet1
Servlet1
Filter1 (forward + request) invoked for path /Servlet2
Servlet2
So this should function properly.
2010/1/12 Jakob Korherr <ja...@gmail.com>
> "The filter for JSF forwards is not getting invoked at all."
>
> That's exactly what I was saying!!!! ...and it does not help you if you
> set <security:http once-per-request="false"...>, because the filter is only
> invoked once anyway.
>
> Madhav's problem is that the Filter itself is only invoked once for the
> request (at the time when the user makes the request), although there is a
> internal forward with the RequestDispatcher.
>
> So the problem is that the same Filter is not invoked twice for one request
> (at first for REQUEST and then for FORWARD).
>
>
> Regards,
> Jakob
>
>
> 2010/1/12 Madhav Bhargava <Ma...@infosys.com>
>
>> I had added spring security code in my workspace for debugging reasons and
>> I suspected that how can a new page be shown when the URL passed to the
>> filter at the server is old. So I put a dummy filter in front of spring
>> security just to print out the URL that is getting intercepted by spring
>> security filter chain.
>>
>> So now I find that when a JSF forward happens via NavigationHandler then
>> there is no URL that is actually intercepted by the spring filter. What I
>> saw during debugging was not the correct picture.
>>
>> SO I am back at the same problem. The filter for JSF forwards is not
>> getting invoked at all.
>>
>> Regards,
>> Madhav
>>
>> From: Madhav Bhargava
>> >
>> >Yes, I have made the appropriate configuration for spring security
>> filters so that specially in the case that >you have described below this
>> property will make sure that the authentication is done again.
>> >
>> >However I do not think that it has anything to do with a stale URL being
>> passed to the filter at the server >side. I can understand that the browser
>> will have an old URL but at the server side the URL intercepted by the
>> >filter should not be stale. Moreover the control is being forwarded to the
>> correct page and the page is visible >as well so do not know how can a old
>> ULR be passed at the server side and a new page be displayed at the client
>> >side.
>> >
>> >Thanks,
>> >Madhav
>> >
>> >From: Michael Kurz [mailto:michi.kurz@gmx.at]
>> >
>> >Hm, I thought the same first but he has attribute once-per-request set
>> >to false:
>> >
>> ><security:http once-per-request="false"...>
>> >
>> >- Michael
>> >
>> >Jakob Korherr schrieb:
>> > Hi Madhav,
>> >
>> > I now know what the problem is. I wrote a small test webapp and came to
>> the
>> > following conclusion:
>> >
>> > JSF uses RequestDispatcher.forward(..) to render the second view. Thus
>> the
>> > filter should be invoked for the forward. However, the filter is/was
>> already
>> > invoked for the first request and it cannot be invoked twice for one
>> > request.
>> >
>> > Only for test reasons, remove <dispatcher>REQUEST</dispatcher> from your
>> > filter config in the web.xml and the filter will be invoked for
>> > RequestDispatcher.forward(..), because it was not invoked for the
>> original
>> > request.
>> >
>> > I know this does not solve your problem, but I think there is maybe a
>> > workaround for this.. I myself just don't know one..
>> > Maybe define the filter twice would solve the problem, but that's just a
>> > guess.
>> >
>> > Regards,
>> > Jakob
>> >
>> > 2010/1/12 Madhav Bhargava <Ma...@infosys.com>
>> >
>> >>
>> >> -----Original Message-----
>> >> From: Michael Kurz [mailto:michi.kurz@gmx.at]
>> >>
>> >>> Madhav Bhargava schrieb:
>> >>> To add if you see the spring security application config, I have the
>> >> following set:
>> >>> <security:http>
>> >>> <security:intercept-url pattern="/**/secure/**"
>> >> access="ROLE_USER" />
>> >>> <security:intercept-url pattern="/**/operations/**"
>> >> access="ROLE_OPERATIONS"/>
>> >>> </security:http>
>> >>>
>> >>> The URL for the outcome to be forwarded to matches the second
>> interceptor
>> >> pattern which is "/jsp/operations/user/operationsLanding.iface"
>> >>> However what the filter receives is "/jsp/secure/hprelanding.jspx"
>> which
>> >> is the old URL from where the control is being forwarded. This is not
>> how it
>> >> happens when using jsp:forward.
>> >>
>> >>> For clarification: Is the navigation to the new page
>> >>> operationsLanding.iface performed (do you actually see it in the
>> browser)?
>> >>>
>> >>> - Michael
>> >> Yes,the request is properly forwarded to operationsLanding.jspx and I
>> can
>> >> view the page. I had put a breakpoint in one of the spring security
>> classes
>> >> and I could see the old URL which got successfully mapped against
>> pattern
>> >> /**/secure/** which should not have happened.
>> >>
>> >> If I have a normal JSP application where there is no JSF then it works
>> >> fine. I meant the navigation is not handled by JSF.
>> >>
>> >> Regards,
>> >> Madhav
>> >>
>> >
>>
>>
>> **************** CAUTION - Disclaimer *****************
>> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
>> solely
>> for the use of the addressee(s). If you are not the intended recipient,
>> please
>> notify the sender by e-mail and delete the original message. Further, you
>> are not
>> to copy, disclose, or distribute this e-mail or its contents to any other
>> person and
>> any such actions are unlawful. This e-mail may contain viruses. Infosys
>> has taken
>> every reasonable precaution to minimize this risk, but is not liable for
>> any damage
>> you may sustain as a result of any virus in this e-mail. You should carry
>> out your
>> own virus checks before opening the e-mail or attachment. Infosys reserves
>> the
>> right to monitor and review the content of all messages sent to or from
>> this e-mail
>> address. Messages sent to or from this e-mail address may be stored on the
>> Infosys e-mail system.
>> ***INFOSYS******** End of Disclaimer ********INFOSYS***
>>
>
>
Re: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Jakob Korherr <ja...@gmail.com>.
"The filter for JSF forwards is not getting invoked at all."
That's exactly what I was saying!!!! ...and it does not help you if you set
<security:http once-per-request="false"...>, because the filter is only
invoked once anyway.
Madhav's problem is that the Filter itself is only invoked once for the
request (at the time when the user makes the request), although there is a
internal forward with the RequestDispatcher.
So the problem is that the same Filter is not invoked twice for one request
(at first for REQUEST and then for FORWARD).
Regards,
Jakob
2010/1/12 Madhav Bhargava <Ma...@infosys.com>
> I had added spring security code in my workspace for debugging reasons and
> I suspected that how can a new page be shown when the URL passed to the
> filter at the server is old. So I put a dummy filter in front of spring
> security just to print out the URL that is getting intercepted by spring
> security filter chain.
>
> So now I find that when a JSF forward happens via NavigationHandler then
> there is no URL that is actually intercepted by the spring filter. What I
> saw during debugging was not the correct picture.
>
> SO I am back at the same problem. The filter for JSF forwards is not
> getting invoked at all.
>
> Regards,
> Madhav
>
> From: Madhav Bhargava
> >
> >Yes, I have made the appropriate configuration for spring security filters
> so that specially in the case that >you have described below this property
> will make sure that the authentication is done again.
> >
> >However I do not think that it has anything to do with a stale URL being
> passed to the filter at the server >side. I can understand that the browser
> will have an old URL but at the server side the URL intercepted by the
> >filter should not be stale. Moreover the control is being forwarded to the
> correct page and the page is visible >as well so do not know how can a old
> ULR be passed at the server side and a new page be displayed at the client
> >side.
> >
> >Thanks,
> >Madhav
> >
> >From: Michael Kurz [mailto:michi.kurz@gmx.at]
> >
> >Hm, I thought the same first but he has attribute once-per-request set
> >to false:
> >
> ><security:http once-per-request="false"...>
> >
> >- Michael
> >
> >Jakob Korherr schrieb:
> > Hi Madhav,
> >
> > I now know what the problem is. I wrote a small test webapp and came to
> the
> > following conclusion:
> >
> > JSF uses RequestDispatcher.forward(..) to render the second view. Thus
> the
> > filter should be invoked for the forward. However, the filter is/was
> already
> > invoked for the first request and it cannot be invoked twice for one
> > request.
> >
> > Only for test reasons, remove <dispatcher>REQUEST</dispatcher> from your
> > filter config in the web.xml and the filter will be invoked for
> > RequestDispatcher.forward(..), because it was not invoked for the
> original
> > request.
> >
> > I know this does not solve your problem, but I think there is maybe a
> > workaround for this.. I myself just don't know one..
> > Maybe define the filter twice would solve the problem, but that's just a
> > guess.
> >
> > Regards,
> > Jakob
> >
> > 2010/1/12 Madhav Bhargava <Ma...@infosys.com>
> >
> >>
> >> -----Original Message-----
> >> From: Michael Kurz [mailto:michi.kurz@gmx.at]
> >>
> >>> Madhav Bhargava schrieb:
> >>> To add if you see the spring security application config, I have the
> >> following set:
> >>> <security:http>
> >>> <security:intercept-url pattern="/**/secure/**"
> >> access="ROLE_USER" />
> >>> <security:intercept-url pattern="/**/operations/**"
> >> access="ROLE_OPERATIONS"/>
> >>> </security:http>
> >>>
> >>> The URL for the outcome to be forwarded to matches the second
> interceptor
> >> pattern which is "/jsp/operations/user/operationsLanding.iface"
> >>> However what the filter receives is "/jsp/secure/hprelanding.jspx"
> which
> >> is the old URL from where the control is being forwarded. This is not
> how it
> >> happens when using jsp:forward.
> >>
> >>> For clarification: Is the navigation to the new page
> >>> operationsLanding.iface performed (do you actually see it in the
> browser)?
> >>>
> >>> - Michael
> >> Yes,the request is properly forwarded to operationsLanding.jspx and I
> can
> >> view the page. I had put a breakpoint in one of the spring security
> classes
> >> and I could see the old URL which got successfully mapped against
> pattern
> >> /**/secure/** which should not have happened.
> >>
> >> If I have a normal JSP application where there is no JSF then it works
> >> fine. I meant the navigation is not handled by JSF.
> >>
> >> Regards,
> >> Madhav
> >>
> >
>
>
> **************** CAUTION - Disclaimer *****************
> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
> solely
> for the use of the addressee(s). If you are not the intended recipient,
> please
> notify the sender by e-mail and delete the original message. Further, you
> are not
> to copy, disclose, or distribute this e-mail or its contents to any other
> person and
> any such actions are unlawful. This e-mail may contain viruses. Infosys has
> taken
> every reasonable precaution to minimize this risk, but is not liable for
> any damage
> you may sustain as a result of any virus in this e-mail. You should carry
> out your
> own virus checks before opening the e-mail or attachment. Infosys reserves
> the
> right to monitor and review the content of all messages sent to or from
> this e-mail
> address. Messages sent to or from this e-mail address may be stored on the
> Infosys e-mail system.
> ***INFOSYS******** End of Disclaimer ********INFOSYS***
>
RE: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Madhav Bhargava <Ma...@infosys.com>.
I had added spring security code in my workspace for debugging reasons and I suspected that how can a new page be shown when the URL passed to the filter at the server is old. So I put a dummy filter in front of spring security just to print out the URL that is getting intercepted by spring security filter chain.
So now I find that when a JSF forward happens via NavigationHandler then there is no URL that is actually intercepted by the spring filter. What I saw during debugging was not the correct picture.
SO I am back at the same problem. The filter for JSF forwards is not getting invoked at all.
Regards,
Madhav
From: Madhav Bhargava
>
>Yes, I have made the appropriate configuration for spring security filters so that specially in the case that >you have described below this property will make sure that the authentication is done again.
>
>However I do not think that it has anything to do with a stale URL being passed to the filter at the server >side. I can understand that the browser will have an old URL but at the server side the URL intercepted by the >filter should not be stale. Moreover the control is being forwarded to the correct page and the page is visible >as well so do not know how can a old ULR be passed at the server side and a new page be displayed at the client >side.
>
>Thanks,
>Madhav
>
>From: Michael Kurz [mailto:michi.kurz@gmx.at]
>
>Hm, I thought the same first but he has attribute once-per-request set
>to false:
>
><security:http once-per-request="false"...>
>
>- Michael
>
>Jakob Korherr schrieb:
> Hi Madhav,
>
> I now know what the problem is. I wrote a small test webapp and came to the
> following conclusion:
>
> JSF uses RequestDispatcher.forward(..) to render the second view. Thus the
> filter should be invoked for the forward. However, the filter is/was already
> invoked for the first request and it cannot be invoked twice for one
> request.
>
> Only for test reasons, remove <dispatcher>REQUEST</dispatcher> from your
> filter config in the web.xml and the filter will be invoked for
> RequestDispatcher.forward(..), because it was not invoked for the original
> request.
>
> I know this does not solve your problem, but I think there is maybe a
> workaround for this.. I myself just don't know one..
> Maybe define the filter twice would solve the problem, but that's just a
> guess.
>
> Regards,
> Jakob
>
> 2010/1/12 Madhav Bhargava <Ma...@infosys.com>
>
>>
>> -----Original Message-----
>> From: Michael Kurz [mailto:michi.kurz@gmx.at]
>>
>>> Madhav Bhargava schrieb:
>>> To add if you see the spring security application config, I have the
>> following set:
>>> <security:http>
>>> <security:intercept-url pattern="/**/secure/**"
>> access="ROLE_USER" />
>>> <security:intercept-url pattern="/**/operations/**"
>> access="ROLE_OPERATIONS"/>
>>> </security:http>
>>>
>>> The URL for the outcome to be forwarded to matches the second interceptor
>> pattern which is "/jsp/operations/user/operationsLanding.iface"
>>> However what the filter receives is "/jsp/secure/hprelanding.jspx" which
>> is the old URL from where the control is being forwarded. This is not how it
>> happens when using jsp:forward.
>>
>>> For clarification: Is the navigation to the new page
>>> operationsLanding.iface performed (do you actually see it in the browser)?
>>>
>>> - Michael
>> Yes,the request is properly forwarded to operationsLanding.jspx and I can
>> view the page. I had put a breakpoint in one of the spring security classes
>> and I could see the old URL which got successfully mapped against pattern
>> /**/secure/** which should not have happened.
>>
>> If I have a normal JSP application where there is no JSF then it works
>> fine. I meant the navigation is not handled by JSF.
>>
>> Regards,
>> Madhav
>>
>
**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely
for the use of the addressee(s). If you are not the intended recipient, please
notify the sender by e-mail and delete the original message. Further, you are not
to copy, disclose, or distribute this e-mail or its contents to any other person and
any such actions are unlawful. This e-mail may contain viruses. Infosys has taken
every reasonable precaution to minimize this risk, but is not liable for any damage
you may sustain as a result of any virus in this e-mail. You should carry out your
own virus checks before opening the e-mail or attachment. Infosys reserves the
right to monitor and review the content of all messages sent to or from this e-mail
address. Messages sent to or from this e-mail address may be stored on the
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***
RE: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Madhav Bhargava <Ma...@infosys.com>.
Yes, I have made the appropriate configuration for spring security filters so that specially in the case that you have described below this property will make sure that the authentication is done again.
However I do not think that it has anything to do with a stale URL being passed to the filter at the server side. I can understand that the browser will have an old URL but at the server side the URL intercepted by the filter should not be stale. Moreover the control is being forwarded to the correct page and the page is visible as well so do not know how can a old ULR be passed at the server side and a new page be displayed at the client side.
Thanks,
Madhav
From: Michael Kurz [mailto:michi.kurz@gmx.at]
>
>Hm, I thought the same first but he has attribute once-per-request set
>to false:
>
><security:http once-per-request="false"...>
>
>- Michael
>
>Jakob Korherr schrieb:
> Hi Madhav,
>
> I now know what the problem is. I wrote a small test webapp and came to the
> following conclusion:
>
> JSF uses RequestDispatcher.forward(..) to render the second view. Thus the
> filter should be invoked for the forward. However, the filter is/was already
> invoked for the first request and it cannot be invoked twice for one
> request.
>
> Only for test reasons, remove <dispatcher>REQUEST</dispatcher> from your
> filter config in the web.xml and the filter will be invoked for
> RequestDispatcher.forward(..), because it was not invoked for the original
> request.
>
> I know this does not solve your problem, but I think there is maybe a
> workaround for this.. I myself just don't know one..
> Maybe define the filter twice would solve the problem, but that's just a
> guess.
>
> Regards,
> Jakob
>
> 2010/1/12 Madhav Bhargava <Ma...@infosys.com>
>
>>
>> -----Original Message-----
>> From: Michael Kurz [mailto:michi.kurz@gmx.at]
>>
>>> Madhav Bhargava schrieb:
>>> To add if you see the spring security application config, I have the
>> following set:
>>> <security:http>
>>> <security:intercept-url pattern="/**/secure/**"
>> access="ROLE_USER" />
>>> <security:intercept-url pattern="/**/operations/**"
>> access="ROLE_OPERATIONS"/>
>>> </security:http>
>>>
>>> The URL for the outcome to be forwarded to matches the second interceptor
>> pattern which is "/jsp/operations/user/operationsLanding.iface"
>>> However what the filter receives is "/jsp/secure/hprelanding.jspx" which
>> is the old URL from where the control is being forwarded. This is not how it
>> happens when using jsp:forward.
>>
>>> For clarification: Is the navigation to the new page
>>> operationsLanding.iface performed (do you actually see it in the browser)?
>>>
>>> - Michael
>> Yes,the request is properly forwarded to operationsLanding.jspx and I can
>> view the page. I had put a breakpoint in one of the spring security classes
>> and I could see the old URL which got successfully mapped against pattern
>> /**/secure/** which should not have happened.
>>
>> If I have a normal JSP application where there is no JSF then it works
>> fine. I meant the navigation is not handled by JSF.
>>
>> Regards,
>> Madhav
>>
>
Re: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Michael Kurz <mi...@gmx.at>.
Hm, I thought the same first but he has attribute once-per-request set
to false:
<security:http once-per-request="false"...>
- Michael
Jakob Korherr schrieb:
> Hi Madhav,
>
> I now know what the problem is. I wrote a small test webapp and came to the
> following conclusion:
>
> JSF uses RequestDispatcher.forward(..) to render the second view. Thus the
> filter should be invoked for the forward. However, the filter is/was already
> invoked for the first request and it cannot be invoked twice for one
> request.
>
> Only for test reasons, remove <dispatcher>REQUEST</dispatcher> from your
> filter config in the web.xml and the filter will be invoked for
> RequestDispatcher.forward(..), because it was not invoked for the original
> request.
>
> I know this does not solve your problem, but I think there is maybe a
> workaround for this.. I myself just don't know one..
> Maybe define the filter twice would solve the problem, but that's just a
> guess.
>
> Regards,
> Jakob
>
> 2010/1/12 Madhav Bhargava <Ma...@infosys.com>
>
>>
>> -----Original Message-----
>> From: Michael Kurz [mailto:michi.kurz@gmx.at]
>>
>>> Madhav Bhargava schrieb:
>>> To add if you see the spring security application config, I have the
>> following set:
>>> <security:http>
>>> <security:intercept-url pattern="/**/secure/**"
>> access="ROLE_USER" />
>>> <security:intercept-url pattern="/**/operations/**"
>> access="ROLE_OPERATIONS"/>
>>> </security:http>
>>>
>>> The URL for the outcome to be forwarded to matches the second interceptor
>> pattern which is "/jsp/operations/user/operationsLanding.iface"
>>> However what the filter receives is "/jsp/secure/hprelanding.jspx" which
>> is the old URL from where the control is being forwarded. This is not how it
>> happens when using jsp:forward.
>>
>>> For clarification: Is the navigation to the new page
>>> operationsLanding.iface performed (do you actually see it in the browser)?
>>>
>>> - Michael
>> Yes,the request is properly forwarded to operationsLanding.jspx and I can
>> view the page. I had put a breakpoint in one of the spring security classes
>> and I could see the old URL which got successfully mapped against pattern
>> /**/secure/** which should not have happened.
>>
>> If I have a normal JSP application where there is no JSF then it works
>> fine. I meant the navigation is not handled by JSF.
>>
>> Regards,
>> Madhav
>>
>
Re: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Jakob Korherr <ja...@gmail.com>.
Hi Madhav,
I now know what the problem is. I wrote a small test webapp and came to the
following conclusion:
JSF uses RequestDispatcher.forward(..) to render the second view. Thus the
filter should be invoked for the forward. However, the filter is/was already
invoked for the first request and it cannot be invoked twice for one
request.
Only for test reasons, remove <dispatcher>REQUEST</dispatcher> from your
filter config in the web.xml and the filter will be invoked for
RequestDispatcher.forward(..), because it was not invoked for the original
request.
I know this does not solve your problem, but I think there is maybe a
workaround for this.. I myself just don't know one..
Maybe define the filter twice would solve the problem, but that's just a
guess.
Regards,
Jakob
2010/1/12 Madhav Bhargava <Ma...@infosys.com>
>
>
> -----Original Message-----
> From: Michael Kurz [mailto:michi.kurz@gmx.at]
>
> >Madhav Bhargava schrieb:
> > To add if you see the spring security application config, I have the
> following set:
> >
> > <security:http>
> > <security:intercept-url pattern="/**/secure/**"
> access="ROLE_USER" />
> > <security:intercept-url pattern="/**/operations/**"
> access="ROLE_OPERATIONS"/>
> > </security:http>
> >
> > The URL for the outcome to be forwarded to matches the second interceptor
> pattern which is "/jsp/operations/user/operationsLanding.iface"
> >
> > However what the filter receives is "/jsp/secure/hprelanding.jspx" which
> is the old URL from where the control is being forwarded. This is not how it
> happens when using jsp:forward.
>
> >For clarification: Is the navigation to the new page
> >operationsLanding.iface performed (do you actually see it in the browser)?
> >
> >- Michael
>
> Yes,the request is properly forwarded to operationsLanding.jspx and I can
> view the page. I had put a breakpoint in one of the spring security classes
> and I could see the old URL which got successfully mapped against pattern
> /**/secure/** which should not have happened.
>
> If I have a normal JSP application where there is no JSF then it works
> fine. I meant the navigation is not handled by JSF.
>
> Regards,
> Madhav
>
RE: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Madhav Bhargava <Ma...@infosys.com>.
-----Original Message-----
From: Michael Kurz [mailto:michi.kurz@gmx.at]
>Madhav Bhargava schrieb:
> To add if you see the spring security application config, I have the following set:
>
> <security:http>
> <security:intercept-url pattern="/**/secure/**" access="ROLE_USER" />
> <security:intercept-url pattern="/**/operations/**" access="ROLE_OPERATIONS"/>
> </security:http>
>
> The URL for the outcome to be forwarded to matches the second interceptor pattern which is "/jsp/operations/user/operationsLanding.iface"
>
> However what the filter receives is "/jsp/secure/hprelanding.jspx" which is the old URL from where the control is being forwarded. This is not how it happens when using jsp:forward.
>For clarification: Is the navigation to the new page
>operationsLanding.iface performed (do you actually see it in the browser)?
>
>- Michael
Yes,the request is properly forwarded to operationsLanding.jspx and I can view the page. I had put a breakpoint in one of the spring security classes and I could see the old URL which got successfully mapped against pattern /**/secure/** which should not have happened.
If I have a normal JSP application where there is no JSF then it works fine. I meant the navigation is not handled by JSF.
Regards,
Madhav
Re: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Michael Kurz <mi...@gmx.at>.
Madhav Bhargava schrieb:
> To add if you see the spring security application config, I have the following set:
>
> <security:http>
> <security:intercept-url pattern="/**/secure/**" access="ROLE_USER" />
> <security:intercept-url pattern="/**/operations/**" access="ROLE_OPERATIONS"/>
> </security:http>
>
> The URL for the outcome to be forwarded to matches the second interceptor pattern which is "/jsp/operations/user/operationsLanding.iface"
>
> However what the filter receives is "/jsp/secure/hprelanding.jspx" which is the old URL from where the control is being forwarded. This is not how it happens when using jsp:forward.
For clarification: Is the navigation to the new page
operationsLanding.iface performed (do you actually see it in the browser)?
- Michael
RE: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Madhav Bhargava <Ma...@infosys.com>.
To add if you see the spring security application config, I have the following set:
<security:http>
<security:intercept-url pattern="/**/secure/**" access="ROLE_USER" />
<security:intercept-url pattern="/**/operations/**" access="ROLE_OPERATIONS"/>
</security:http>
The URL for the outcome to be forwarded to matches the second interceptor pattern which is "/jsp/operations/user/operationsLanding.iface"
However what the filter receives is "/jsp/secure/hprelanding.jspx" which is the old URL from where the control is being forwarded. This is not how it happens when using jsp:forward.
Regards,
Madhav
-----Original Message-----
>From: Madhav Bhargava
>
>Hi Michael,
>
>Following are the servlet mappings:
>
><servlet-mapping>
> <servlet-name>Faces Servlet</servlet-name>
> <url-pattern>*.faces</url-pattern>
> </servlet-mapping>
>
> <servlet-mapping>
> <servlet-name>Faces Servlet</servlet-name>
> <url-pattern>*.jspx</url-pattern>
> </servlet-mapping>
>
> <!-- Persistent Faces Servlet Mapping -->
> <servlet-mapping>
> <servlet-name>Persistent Faces Servlet</servlet-name>
> <url-pattern>*.iface</url-pattern>
> </servlet-mapping>
>
>The navigation case in faces-config.xml is:
>
><navigation-rule>
> <navigation-case>
> <from-outcome>OPERATION_LANDING</from-outcome>
> <to-view-id>/jsp/operations/user/operationsLanding.iface</to-view-id>
> </navigation-case>
></navigation-rule>
>
>This has been configured as per the icefaces documentation. If we disregard spring security filter issue the >forward happens properly. Spring security filter gets invoked once after the return "OPERATION_LANDING" from >within the action method has been executed. The strange part is that the URL is still the previous one.
>
>It is strange because when using jsp:forward from index.jsp to login.jsp spring security filter gets both the >URL's.
>
>What could be the issue?
>
>Regards,
>Madhav
>
>
>From: Michael Kurz [mailto:michi.kurz@gmx.at]
>Hi,
>
>which mapping do you use for your faces servlet: postfix (like *.jsf) or
>prefix (like /faces/*)? Maybe the "real" JSF urls are not listed in your
>intercepter config.
>
>regards
>Michael
>
>Madhav Bhargava schrieb:
> Hi All,
>
> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring security -2.0.5, WAS 6.0 (app server)
>
> I have configured spring security for my JSF application along with SiteMinder as an external authentication mechanism. It works fine till a forward happens from within myfaces.
>
> Here is my spring servlet filter chain declaration:
> <filter>
> <description>
> Spring delegating filter which will initiate the spring
> security filter chain
> </description>
> <display-name>springSecurityFilterChain</display-name>
> <filter-name>springSecurityFilterChain</filter-name>
> <filter-class>
> org.springframework.web.filter.DelegatingFilterProxy
> </filter-class>
> </filter>
>
> <filter-mapping>
> <filter-name>springSecurityFilterChain</filter-name>
> <url-pattern>/*</url-pattern>
> <dispatcher>FORWARD</dispatcher>
> <dispatcher>REQUEST</dispatcher>
> </filter-mapping>
>
> And in my spring application context I have followed the advice from spring forums and done necessary settings:
> Excerpt is:
>
> <security:http
> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint" once-per-request="false">
> <security:intercept-url pattern="/index.jsp" filters="none" />
> <security:intercept-url pattern="/login.jsp" filters="none" />
> <security:intercept-url pattern="/authenticationservlet" filters="none"/>
> <security:intercept-url pattern="**/jsp/common/**" filters="none"/>
> <security:intercept-url pattern="/**/css/**" filters="none"/>
> <security:intercept-url pattern="/**/*.js" filters="none"/>
> <security:intercept-url pattern="/images/**" filters="none"/>
> <security:intercept-url pattern="/**/secure/**" access="ROLE_USER" />
> <security:intercept-url pattern="/**/operations/**" access="ROLE_OPERATIONS"/>
> <security:intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
> </security:http>
>
> Now when I forward a request from index.jsp to login.jsp then the spring filters are called with the login.jsp URL even though the browser shows the old URL.
>
> However when from within an action method a navigation case is handled then it is not intercepted by the spring filters at all. However if I give a <redirect/> then it is properly intercepted with the correct URL as expected.
>
> What can be the reason?
>
> Regards,
> Madhav
>
RE: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Madhav Bhargava <Ma...@infosys.com>.
Hi Michael,
Following are the servlet mappings:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jspx</url-pattern>
</servlet-mapping>
<!-- Persistent Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Persistent Faces Servlet</servlet-name>
<url-pattern>*.iface</url-pattern>
</servlet-mapping>
The navigation case in faces-config.xml is:
<navigation-rule>
<navigation-case>
<from-outcome>OPERATION_LANDING</from-outcome>
<to-view-id>/jsp/operations/user/operationsLanding.iface</to-view-id>
</navigation-case>
</navigation-rule>
This has been configured as per the icefaces documentation. If we disregard spring security filter issue the forward happens properly. Spring security filter gets invoked once after the return "OPERATION_LANDING" from within the action method has been executed. The strange part is that the URL is still the previous one.
It is strange because when using jsp:forward from index.jsp to login.jsp spring security filter gets both the URL's.
What could be the issue?
Regards,
Madhav
From: Michael Kurz [mailto:michi.kurz@gmx.at]
>Hi,
>
>which mapping do you use for your faces servlet: postfix (like *.jsf) or
>prefix (like /faces/*)? Maybe the "real" JSF urls are not listed in your
>intercepter config.
>
>regards
>Michael
>
>Madhav Bhargava schrieb:
> Hi All,
>
> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring security -2.0.5, WAS 6.0 (app server)
>
> I have configured spring security for my JSF application along with SiteMinder as an external authentication mechanism. It works fine till a forward happens from within myfaces.
>
> Here is my spring servlet filter chain declaration:
> <filter>
> <description>
> Spring delegating filter which will initiate the spring
> security filter chain
> </description>
> <display-name>springSecurityFilterChain</display-name>
> <filter-name>springSecurityFilterChain</filter-name>
> <filter-class>
> org.springframework.web.filter.DelegatingFilterProxy
> </filter-class>
> </filter>
>
> <filter-mapping>
> <filter-name>springSecurityFilterChain</filter-name>
> <url-pattern>/*</url-pattern>
> <dispatcher>FORWARD</dispatcher>
> <dispatcher>REQUEST</dispatcher>
> </filter-mapping>
>
> And in my spring application context I have followed the advice from spring forums and done necessary settings:
> Excerpt is:
>
> <security:http
> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint" once-per-request="false">
> <security:intercept-url pattern="/index.jsp" filters="none" />
> <security:intercept-url pattern="/login.jsp" filters="none" />
> <security:intercept-url pattern="/authenticationservlet" filters="none"/>
> <security:intercept-url pattern="**/jsp/common/**" filters="none"/>
> <security:intercept-url pattern="/**/css/**" filters="none"/>
> <security:intercept-url pattern="/**/*.js" filters="none"/>
> <security:intercept-url pattern="/images/**" filters="none"/>
> <security:intercept-url pattern="/**/secure/**" access="ROLE_USER" />
> <security:intercept-url pattern="/**/operations/**" access="ROLE_OPERATIONS"/>
> <security:intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
> </security:http>
>
> Now when I forward a request from index.jsp to login.jsp then the spring filters are called with the login.jsp URL even though the browser shows the old URL.
>
> However when from within an action method a navigation case is handled then it is not intercepted by the spring filters at all. However if I give a <redirect/> then it is properly intercepted with the correct URL as expected.
>
> What can be the reason?
>
> Regards,
> Madhav
>
**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely
for the use of the addressee(s). If you are not the intended recipient, please
notify the sender by e-mail and delete the original message. Further, you are not
to copy, disclose, or distribute this e-mail or its contents to any other person and
any such actions are unlawful. This e-mail may contain viruses. Infosys has taken
every reasonable precaution to minimize this risk, but is not liable for any damage
you may sustain as a result of any virus in this e-mail. You should carry out your
own virus checks before opening the e-mail or attachment. Infosys reserves the
right to monitor and review the content of all messages sent to or from this e-mail
address. Messages sent to or from this e-mail address may be stored on the
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***
Re: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Michael Kurz <mi...@gmx.at>.
Hi,
which mapping do you use for your faces servlet: postfix (like *.jsf) or
prefix (like /faces/*)? Maybe the "real" JSF urls are not listed in your
intercepter config.
regards
Michael
Madhav Bhargava schrieb:
> Hi All,
>
> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring security -2.0.5, WAS 6.0 (app server)
>
> I have configured spring security for my JSF application along with SiteMinder as an external authentication mechanism. It works fine till a forward happens from within myfaces.
>
> Here is my spring servlet filter chain declaration:
> <filter>
> <description>
> Spring delegating filter which will initiate the spring
> security filter chain
> </description>
> <display-name>springSecurityFilterChain</display-name>
> <filter-name>springSecurityFilterChain</filter-name>
> <filter-class>
> org.springframework.web.filter.DelegatingFilterProxy
> </filter-class>
> </filter>
>
> <filter-mapping>
> <filter-name>springSecurityFilterChain</filter-name>
> <url-pattern>/*</url-pattern>
> <dispatcher>FORWARD</dispatcher>
> <dispatcher>REQUEST</dispatcher>
> </filter-mapping>
>
> And in my spring application context I have followed the advice from spring forums and done necessary settings:
> Excerpt is:
>
> <security:http
> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint" once-per-request="false">
> <security:intercept-url pattern="/index.jsp" filters="none" />
> <security:intercept-url pattern="/login.jsp" filters="none" />
> <security:intercept-url pattern="/authenticationservlet" filters="none"/>
> <security:intercept-url pattern="**/jsp/common/**" filters="none"/>
> <security:intercept-url pattern="/**/css/**" filters="none"/>
> <security:intercept-url pattern="/**/*.js" filters="none"/>
> <security:intercept-url pattern="/images/**" filters="none"/>
> <security:intercept-url pattern="/**/secure/**" access="ROLE_USER" />
> <security:intercept-url pattern="/**/operations/**" access="ROLE_OPERATIONS"/>
> <security:intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" />
> </security:http>
>
> Now when I forward a request from index.jsp to login.jsp then the spring filters are called with the login.jsp URL even though the browser shows the old URL.
>
> However when from within an action method a navigation case is handled then it is not intercepted by the spring filters at all. However if I give a <redirect/> then it is properly intercepted with the correct URL as expected.
>
> What can be the reason?
>
> Regards,
> Madhav
>
RE: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Madhav Bhargava <Ma...@infosys.com>.
Thanks for your response Jakob.
What you have mentioned is already known to me. That is the reason I have put a <dispatcher>FORWARD</dispatcher>
For Spring security filter.
I should have made it a little more clear. Apologies for that. The forward from index.jsp to login.jsp is via <jsp:forward>. These are not JSF pages. This forward is captured by Spring security filter. However when a forward happens from within JSF via NavigationHandler then this forward is not caught by spring security filter. I am not sure why a jsp:forward forward will be caught every time and not when done via myfaces.
So essentially I not worried about browser showing me the previous URL because that is an expected behavior but the new URL is always caught by the filter which in my case is the exact problem.
Regards,
Madhav
>-----Original Message-----
>From: sethfromaustria@gmail.com [mailto:sethfromaustria@gmail.com] On Behalf Of Jakob Korherr
>Sent: Tuesday, January 12, 2010 4:21 AM
>To: MyFaces Discussion
>Subject: Re: Spring FilterSecurityInterceptor not been called for myfaces forwards
>
>Hi Madhav,
>
>JSF always submits back to the original view, if you hit a h:commandButton
>or h:commandLink. So if you are on index.jsp and hit for example a
>h:commandLink, you will get a request for index.jsp. However, after the
>action method on the server is finished, the server renders the new view,
>depending on the outcome of the action method, in your case login.jsp. But
>your browser still displays index.jsp in the address bar, because that was
>the page you requested.
>
>When you add <redirect /> in the faces-config, JSF will instead of just
>rendering the new view, redirect to it. Thus you have a second http round
>trip and your browser's address bar will display the new view.
>
>I hope this explains things.
>
>Regards,
>Jakob Korherr
2010/1/11 Madhav Bhargava <Ma...@infosys.com>
> Hi All,
>
> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring security
> -2.0.5, WAS 6.0 (app server)
>
> I have configured spring security for my JSF application along with
> SiteMinder as an external authentication mechanism. It works fine till a
> forward happens from within myfaces.
>
> Here is my spring servlet filter chain declaration:
> <filter>
> <description>
> Spring delegating filter which will initiate
> the spring
> security filter chain
> </description>
> <display-name>springSecurityFilterChain</display-name>
> <filter-name>springSecurityFilterChain</filter-name>
> <filter-class>
>
> org.springframework.web.filter.DelegatingFilterProxy
> </filter-class>
> </filter>
>
> <filter-mapping>
> <filter-name>springSecurityFilterChain</filter-name>
> <url-pattern>/*</url-pattern>
> <dispatcher>FORWARD</dispatcher>
> <dispatcher>REQUEST</dispatcher>
> </filter-mapping>
>
> And in my spring application context I have followed the advice from spring
> forums and done necessary settings:
> Excerpt is:
>
> <security:http
> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint"
> once-per-request="false">
> <security:intercept-url pattern="/index.jsp" filters="none"
> />
> <security:intercept-url pattern="/login.jsp" filters="none"
> />
> <security:intercept-url pattern="/authenticationservlet"
> filters="none"/>
> <security:intercept-url pattern="**/jsp/common/**"
> filters="none"/>
> <security:intercept-url pattern="/**/css/**"
> filters="none"/>
> <security:intercept-url pattern="/**/*.js" filters="none"/>
> <security:intercept-url pattern="/images/**"
> filters="none"/>
> <security:intercept-url pattern="/**/secure/**"
> access="ROLE_USER" />
> <security:intercept-url pattern="/**/operations/**"
> access="ROLE_OPERATIONS"/>
> <security:intercept-url pattern="/**"
> access="IS_AUTHENTICATED_ANONYMOUSLY" />
> </security:http>
>
> Now when I forward a request from index.jsp to login.jsp then the spring
> filters are called with the login.jsp URL even though the browser shows the
> old URL.
>
> However when from within an action method a navigation case is handled then
> it is not intercepted by the spring filters at all. However if I give a
> <redirect/> then it is properly intercepted with the correct URL as
> expected.
>
> What can be the reason?
>
> Regards,
> Madhav
>
Re: Spring FilterSecurityInterceptor not been called for myfaces
forwards
Posted by Jakob Korherr <ja...@gmail.com>.
Hi Madhav,
JSF always submits back to the original view, if you hit a h:commandButton
or h:commandLink. So if you are on index.jsp and hit for example a
h:commandLink, you will get a request for index.jsp. However, after the
action method on the server is finished, the server renders the new view,
depending on the outcome of the action method, in your case login.jsp. But
your browser still displays index.jsp in the address bar, because that was
the page you requested.
When you add <redirect /> in the faces-config, JSF will instead of just
rendering the new view, redirect to it. Thus you have a second http round
trip and your browser's address bar will display the new view.
I hope this explains things.
Regards,
Jakob Korherr
2010/1/11 Madhav Bhargava <Ma...@infosys.com>
> Hi All,
>
> I am using myfaces 1.1, icefaces 1.8.1, spring 2.5.6, spring security
> -2.0.5, WAS 6.0 (app server)
>
> I have configured spring security for my JSF application along with
> SiteMinder as an external authentication mechanism. It works fine till a
> forward happens from within myfaces.
>
> Here is my spring servlet filter chain declaration:
> <filter>
> <description>
> Spring delegating filter which will initiate
> the spring
> security filter chain
> </description>
> <display-name>springSecurityFilterChain</display-name>
> <filter-name>springSecurityFilterChain</filter-name>
> <filter-class>
>
> org.springframework.web.filter.DelegatingFilterProxy
> </filter-class>
> </filter>
>
> <filter-mapping>
> <filter-name>springSecurityFilterChain</filter-name>
> <url-pattern>/*</url-pattern>
> <dispatcher>FORWARD</dispatcher>
> <dispatcher>REQUEST</dispatcher>
> </filter-mapping>
>
> And in my spring application context I have followed the advice from spring
> forums and done necessary settings:
> Excerpt is:
>
> <security:http
> entry-point-ref="preAuthenticatedProcessingFilterEntryPoint"
> once-per-request="false">
> <security:intercept-url pattern="/index.jsp" filters="none"
> />
> <security:intercept-url pattern="/login.jsp" filters="none"
> />
> <security:intercept-url pattern="/authenticationservlet"
> filters="none"/>
> <security:intercept-url pattern="**/jsp/common/**"
> filters="none"/>
> <security:intercept-url pattern="/**/css/**"
> filters="none"/>
> <security:intercept-url pattern="/**/*.js" filters="none"/>
> <security:intercept-url pattern="/images/**"
> filters="none"/>
> <security:intercept-url pattern="/**/secure/**"
> access="ROLE_USER" />
> <security:intercept-url pattern="/**/operations/**"
> access="ROLE_OPERATIONS"/>
> <security:intercept-url pattern="/**"
> access="IS_AUTHENTICATED_ANONYMOUSLY" />
> </security:http>
>
> Now when I forward a request from index.jsp to login.jsp then the spring
> filters are called with the login.jsp URL even though the browser shows the
> old URL.
>
> However when from within an action method a navigation case is handled then
> it is not intercepted by the spring filters at all. However if I give a
> <redirect/> then it is properly intercepted with the correct URL as
> expected.
>
> What can be the reason?
>
> Regards,
> Madhav
>