incubator-adffaces-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cagatay Civici" <cagatay.civ...@gmail.com>
Subject Re: Trinidad, Facelets and Acegi
Date Thu, 22 Mar 2007 15:42:42 GMT
Hello Kuno,

org.acegisecurity.context.SecurityContextImpl has nothing to do with the
org.apache.myfaces.SECURITY_CONTEXT, just similar names.

The easiest way to use myfaces SecurityContext with Acegi basically you need
two things;

* Latest MyFaces Sandbox
* Configuration of acegi's SecurityContextHolderAwareRequestFilter. Just add
this one to your filter list.
* Do not configure the context-param org.apache.myfaces.SECURITY_CONTEXT, so
that default impl will be picked up.

Hope this helps,

Regards,

Cagatay

On 3/22/07, Kuno Baeriswyl <kuno.baeriswyl@bkw-fmb.ch> wrote:
>
> Hi,
>
> ok, I agree with you. I didn't know this option.
>
> I've added folowing context param to my web.xml
>         <context-param>
>             <param-name>org.apache.myfaces.SECURITY_CONTEXT</param-name>
>
> <param-value>org.acegisecurity.context.SecurityContextImpl</param-value>
>         </context-param>
>
> I've found the org.acegisecurity.context.SecurityContextImpl class by
> accident in the acegi library.
>
> But, I don't get any securityContext parameter in my facelet:
> <tr:commandNavigationItem text="Warenkorb" action="showOrder"
> rendered="#{securityContext.ifNotGranted['ROLE_ADMIN']}"/>
>
> The component is never rendered!
>
> Do I need to configure anything else?
>
> Many Thanks in advance!
>
> Kuno
>
> On Thu, 2007-03-22 at 14:45 +0200, Cagatay Civici wrote:
> > Hi,
> >
> > I agree with Matthias and strongly suggest to use the securitycontext el
> > extension, it'll be much simpler.
> >
> > Regards,
> >
> > Cagatay
> >
> > On 3/22/07, Matthias Wessendorf <matzew@apache.org> wrote:
> > >
> > > Hey Kuno,
> > >
> > > the issue is, that the component expects a <tr:commandNavigationItem>
> > > component.
> > > The point is, you wrap it by using <acegijsf:authorize>.
> > >
> > > It would be good, if you could *nest* the <acegijsf:authorize> inside
> > > other components.
> > >
> > > <tr:commandNavigationItem>
> > >   <acegijsf:authorize />
> > > </tr:commandNavigationItem>
> > >
> > > See see blog discussion, that using tabs might be not the best way of
> > > doing this security stuff.
> > >
> > > There is also something like:
> > > http://wiki.apache.org/myfaces/SecurityContext
> > > in myfaces, for using EL based sec. checks.
> > >
> > > -M
> > > On 3/22/07, Kuno Baeriswyl <kuno.baeriswyl@bkw-fmb.ch> wrote:
> > > > Hi Cafatay!
> > > >
> > > > Thanks for your hint! I've found an example application
> > > >
> > >
> http://www.nabble.com/Appfuse-+-facelets-+-other-goodies-t1019957s2369.htmlandadded the
facelets JSP taglib mapping to my
> > > web.xml
> > > >
> > > >         <context-param>
> > > >                 <param-name>facelets.LIBRARIES</param-name>
> > > >
> <param-value>/WEB-INF/acegijsf.taglib.xml</param-value>
> > > >         </context-param>
> > > >
> > > > But, I still get an error:
> > > >
> > > > 22.03.2007 09:41:53
> > > >
> > >
> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.NavigationPaneRendererrenderContent
> > > > SCHWERWIEGEND: Warning: illegal component hierarchy detected,
> expected
> > > > UIXCommand but found another type of component instead.
> > > > java.lang.ClassCastException: net.sf.jsfcomp.acegijsf.Authorize
> > > >
> > > > Do you have any idea?
> > > >
> > > > Kuno
> > > >
> > > > On Thu, 2007-03-22 at 10:04 +0200, Cagatay Civici wrote:
> > > > > Hi,
> > > > >
> > > > > Have you defined the acegijsf components in your facelets-taglib
> > > config?
> > > > >
> > > > > Cagatay
> > > > >
> > > > > On 3/22/07, Kuno Baeriswyl <kuno.baeriswyl@bkw-fmb.ch> wrote:
> > > > > >
> > > > > > Hello everybody,
> > > > > >
> > > > > > I like to put trinidad, facelets and acegi together. The
> appserver
> > > > > > compiles the HTML page, but complains about an unvalid type:
> > > > > >
> > > > > > 22.03.2007 08:35:21 com.sun.facelets.tag.jsf.ComponentRulewarnAttr
> > > > > > WARNUNG: /layout.xhtml @7,42
> > > > > > xmlns:authz="http://acegisecurity.org/authz" Property 'authz'
is
> not
> > > on
> > > > > > type: org.apache.myfaces.trinidad.component.core.CoreDocument
> > > > > > 22.03.2007 08:35:23
> > > > > >
> > > > > >
> > >
> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.NavigationPaneRendererrenderContent
> > > > > > SCHWERWIEGEND: Warning: illegal component hierarchy detected,
> > > expected
> > > > > > UIXCommand but found another type of component instead.
> > > > > > java.lang.ClassCastException:
> > > com.sun.facelets.compiler.UILiteralText
> > > > > >
> > > > > > I've found an promising acegi-jsf component to solve that
> problem :
> > > > > >
> > > > > >
> > >
> http://www.jroller.com/page/cagataycivici?entry=acegi_jsf_components_hit_the
> > > > > >
> > > > > > But, I still get the same error:
> > > > > >
> > > > > > 22.03.2007 08:52:35 com.sun.facelets.tag.jsf.ComponentRulewarnAttr
> > > > > > WARNUNG: /layout.xhtml @7,42
> > > > > > xmlns:acegijsf="
> http://sourceforge.net/projects/jsf-comp/acegijsf"
> > > > > > Property 'acegijsf' is not on type:
> > > > > > org.apache.myfaces.trinidad.component.core.CoreDocument
> > > > > > 22.03.2007 08:52:41
> > > > > >
> > > > > >
> > >
> org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.NavigationPaneRendererrenderContent
> > > > > > SCHWERWIEGEND: Warning: illegal component hierarchy detected,
> > > expected
> > > > > > UIXCommand but found another type of component instead.
> > > > > > java.lang.ClassCastException:
> > > com.sun.facelets.compiler.UILiteralText
> > > > > >
> > > > > > I think I still get the same error. Can any body help me?
> > > > > >
> > > > > > Here is my facelet and faces-config.xml:
> > > > > >
> > > > > > << START template.xhtml  >>
> > > > > > <tr:document
> > > > > >    xmlns:ui="http://java.sun.com/jsf/facelets"
> > > > > >    xmlns:h="http://java.sun.com/jsf/html"
> > > > > >    xmlns:f="http://java.sun.com/jsf/core"
> > > > > >    xmlns:tr="http://myfaces.apache.org/trinidad"
> > > > > >    xmlns:acegijsf="
> http://sourceforge.net/projects/jsf-comp/acegijsf
> > > "
> > > > > >    title="OPIZ - Pizza online bestellen">
> > > > > >           <tr:panelGroupLayout layout="vertical">
> > > > > >             <f:facet name="separator">
> > > > > >               <tr:separator/>
> > > > > >             </f:facet>
> > > > > >             <tr:commandLink immediate="true" text="Home"
> > > > > >                 action="home"/>
> > > > > >             <tr:outputFormatted styleUsage="instruction"
> > > > > >                                value="BKW Intranet"/>
> > > > > >             <tr:panelPage >
> > > > > >               <f:facet name="navigation1">
> > > > > >                        <tr:form>
> > > > > >                <tr:navigationPane hint="tabs" shortDesc="Wähle
> Tab">
> > > > > >                   <tr:commandNavigationItem text="home"
> > > action="home"/>
> > > > > >                                   <acegijsf:authorize
> > > > > > ifNotGranted="ROLE_ADMIN">
> > > > > >
> <tr:commandNavigationItem
> > > > > > text="Warenkorb" action="showOrder"/>
> > > > > >                                   </acegijsf:authorize>
> > > > > >                           <acegijsf:authorize
> > > > > > ifNotGranted="ROLE_CUSTOMER,ROLE_ADMIN">
> > > > > >
> <tr:commandNavigationItem
> > > > > > text="Registrieren" action="register"/>
> > > > > >
> <tr:commandNavigationItem
> > > > > > text="Anmelden"
> > > > > > action="login"/>
> > > > > >                                   </acegijsf:authorize>
> > > > > >                                   <acegijsf:authorize
> > > > > > ifAnyGranted="ROLE_ADMIN">
> > > > > >
> <tr:commandNavigationItem
> > > > > > text="Kundenliste"
> > > > > > action="showCustomer"/>
> > > > > >                                   </acegijsf:authorize>
> > > > > >                                   <acegijsf:authorize
> > > > > > ifAnyGranted="ROLE_CUSTOMER">
> > > > > >
> <tr:commandNavigationItem
> > > > > > text="Meine Daten"
> > > > > > action="#{customerAction.editCustomer}"/>
> > > > > >
> <tr:commandNavigationItem
> > > > > > text="Meine Bestellungen"
> > > > > > action="orderHistory"/>
> > > > > >                                   </acegijsf:authorize>
> > > > > >                                   <acegijsf:authorize
> > > > > > ifAnyGranted="ROLE_CUSTOMER,ROLE_ADMIN">
> > > > > >
> <tr:commandNavigationItem
> > > > > > text="Abmelden"
> > > > > > action="logout"/>
> > > > >
> >                                          <acegijsf:authentication
> > > > > > operation="username"/>
> > > > > >                                   </acegijsf:authorize>
> > > > > >                 </tr:navigationPane>
> > > > > >                </tr:form>
> > > > > >               </f:facet>
> > > > > >               <f:facet name="navigationGlobal">
> > > > > >                 <tr:navigationPane hint="buttons">
> > > > > >                   <tr:commandNavigationItem text="help"
> > > > > >
> icon="/images/globalhelp.gif"
> > > > > >                                     action="guide.navigationPane
> "/>
> > > > > >                   <tr:commandNavigationItem text="help more"
> > > > > >
> icon="/images/globalhelp.gif"
> > > > > >                                     action="guide.navigationPane
> "/>
> > > > > >                   <tr:commandNavigationItem text="Disabled"
> > > > > >
> icon="/images/globalhelp.gif"
> > > > > >                                     action="guide.navigationPane
> "
> > > > > > disabled="true"/>
> > > > > >                   <tr:commandNavigationItem text="Disabled"
> > > > > >
> icon="/images/globalhelp.gif"
> > > > > >                                     action="guide.navigationPane
> "
> > > > > > disabled="true"/>
> > > > > >                 </tr:navigationPane>
> > > > > >               </f:facet>
> > > > > >               <f:facet name="branding">
> > > > > >                 <tr:outputFormatted value="OPIZ - Pizza online
> > > > > > bestellen"
> > > > >
> >                                    styleUsage="inContextBranding"/>
> > > > > >               </f:facet>
> > > > > >               <f:facet name="appCopyright">
> > > > > >                 <tr:outputText value="copyright by BKW Energie
> AG
> > > > > > 2007"/>
> > > > > >               </f:facet>
> > > > > >               <f:facet name="appPrivacy">
> > > > > >                 <tr:commandLink text="privacy" action="
> action.none"
> > > />
> > > > > >               </f:facet>
> > > > > >               <f:facet name="appAbout">
> > > > > >                 <tr:commandLink text="about" action="action.none"
> />
> > > > > >               </f:facet>
> > > > > >
> > > > > >               <ui:insert name="content">
> > > > > >               <ui:include src=""/>
> > > > > >               </ui:insert>
> > > > > >             </tr:panelPage>
> > > > > >           </tr:panelGroupLayout>
> > > > > > </tr:document>
> > > > > >
> > > > > > << END template.xhtml  >>
> > > > > >
> > > > > > << START faces-config.xml  >>
> > > > > > <?xml version="1.0"?>
> > > > > >
> > > > > > <!DOCTYPE faces-config PUBLIC
> > > > > >   "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0
> //EN"
> > > > > >   "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
> > > > > >
> > > > > > <faces-config>
> > > > > >
> > > > > >   <application>
> > > > > >     <variable-resolver>
> > > > > >       org.springframework.web.jsf.DelegatingVariableResolver
> > > > > >     </variable-resolver>
> > > > > >     <locale-config>
> > > > > >       <default-locale>de_DE</default-locale>
> > > > > >       <supported-locale>de</supported-locale>
> > > > > >       <supported-locale>en</supported-locale>
> > > > > >     </locale-config>
> > > > > >     <default-render-kit-id>
> > > > > >       org.apache.myfaces.trinidad.core
> > > > > >     </default-render-kit-id>
> > > > > >   </application>
> > > > > >
> > > > > >     <component>
> > > > > >
> > > > > > <component-type>net.sf.jsfcomp.acegijsf.Authorize
> </component-type>
> > > > > >
> > > > > > <component-class>net.sf.jsfcomp.acegijsf.Authorize
> </component-class>
> > > > > >     </component>
> > > > > >
> > > > > >     <component>
> > > > > >
> > > > > > <component-type>net.sf.jsfcomp.acegijsf.Authentication
> > > </component-type>
> > > > > >
> > > > > > <component-class>net.sf.jsfcomp.acegijsf.Authentication
> > > </component-class>
> > > > > >     </component>
> > > > > >
> > > > > >   <navigation-rule>
> > > > > >     <from-view-id>/*</from-view-id>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>logout</from-outcome>
> > > > > >       <to-view-id>/j_acegi_logout.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >   </navigation-rule>
> > > > > >   <navigation-rule>
> > > > > >     <from-view-id>/opiz/*</from-view-id>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>home</from-outcome>
> > > > > >       <to-view-id>/opiz/choosePizza.xhtml</to-view-id>
> > > > > >     </navigation-case>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>register</from-outcome>
> > > > > >       <to-view-id>/opiz/register.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>login</from-outcome>
> > > > > >       <to-view-id>/opiz/login.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>showOrder</from-outcome>
> > > > > >       <to-view-id>/opiz/showOrder.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>showCustomer</from-outcome>
> > > > > >       <to-view-id>/opiz/showCustomer.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>editCustomer</from-outcome>
> > > > > >       <to-view-id>/opiz/editCustomer.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>orderHistory</from-outcome>
> > > > > >       <to-view-id>/opiz/showOrderHistory.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >   </navigation-rule>
> > > > > >   <navigation-rule>
> > > > > >     <from-view-id>/opiz/login.jsp</from-view-id>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>login</from-outcome>
> > > > > >       <to-view-id>/j_acegi_security_check.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >   </navigation-rule>
> > > > > >   <navigation-rule>
> > > > > >     <from-view-id>/opiz/register.jsp</from-view-id>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>register</from-outcome>
> > > > > >       <to-view-id>/opiz/showRegistration.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>cancel</from-outcome>
> > > > > >       <to-view-id>/opiz/choosePizza.xhtml</to-view-id>
> > > > > >     </navigation-case>
> > > > > >   </navigation-rule>
> > > > > >   <navigation-rule>
> > > > > >     <from-view-id>/opiz/choosePizza.xhtml</from-view-id>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>add</from-outcome>
> > > > > >       <to-view-id>/opiz/showOrder.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>customize</from-outcome>
> > > > > >       <to-view-id>/opiz/topPizza.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>cancel</from-outcome>
> > > > > >       <to-view-id>/opiz/cancel.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >   </navigation-rule>
> > > > > >   <navigation-rule>
> > > > > >     <from-view-id>/opiz/topPizza.jsp</from-view-id>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>add</from-outcome>
> > > > > >       <to-view-id>/opiz/showOrder.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>cancel</from-outcome>
> > > > > >       <to-view-id>/opiz/cancel.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >   </navigation-rule>
> > > > > >   <navigation-rule>
> > > > > >     <from-view-id>/opiz/showOrder.jsp</from-view-id>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>order</from-outcome>
> > > > > >       <to-view-id>/opiz/order.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>cancel</from-outcome>
> > > > > >       <to-view-id>/opiz/cancel.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>continue</from-outcome>
> > > > > >       <to-view-id>/opiz/choosePizza.xhtml</to-view-id>
> > > > > >     </navigation-case>
> > > > > >   </navigation-rule>
> > > > > >   <navigation-rule>
> > > > > >     <from-view-id>/opiz/order.jsp</from-view-id>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>deliver</from-outcome>
> > > > > >       <to-view-id>/opiz/deliver.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>cancel</from-outcome>
> > > > > >       <to-view-id>/opiz/cancel.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >   </navigation-rule>
> > > > > >   <navigation-rule>
> > > > > >     <from-view-id>/opiz/showOrderHistory.jsp</from-view-id>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>cancel</from-outcome>
> > > > > >       <to-view-id>/opiz/cancel.jsp</to-view-id>
> > > > > >     </navigation-case>
> > > > > >   </navigation-rule>
> > > > > >   <navigation-rule>
> > > > > >     <from-view-id>/opiz/editCustomer.jsp</from-view-id>
> > > > > >     <navigation-case>
> > > > > >       <from-outcome>cancel</from-outcome>
> > > > > >       <to-view-id>/opiz/choosePizza.xhtml</to-view-id>
> > > > > >     </navigation-case>
> > > > > >   </navigation-rule>
> > > > > >
> > > > > >   <converter>
> > > > > >     <converter-id>pizzaConverter</converter-id>
> > > > > >     <converter-class>
> > > > > >       de.hanser.buch.opiz.web.jsf.PizzaConverter
> > > > > >     </converter-class>
> > > > > >   </converter>
> > > > > >   <converter>
> > > > > >     <converter-for-class>
> > > > > >       de.hanser.buch.opiz.domain.Topping
> > > > > >     </converter-for-class>
> > > > > >     <converter-class>
> > > > > >       de.hanser.buch.opiz.web.jsf.ToppingConverter
> > > > > >     </converter-class>
> > > > > >   </converter>
> > > > > >
> > > > > > </faces-config>
> > > > > >
> > > > > > << END faces-config.xml  >>
> > > > > >
> > > >
> > >
> > >
> > > --
> > > Matthias Wessendorf
> > > http://tinyurl.com/fmywh
> > >
> > > further stuff:
> > > blog: http://jroller.com/page/mwessendorf
> > > mail: mwessendorf-at-gmail-dot-com
> > >
>
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message