1 Reply Latest reply on Feb 15, 2010 3:08 AM by Ray Nawara

    How to call custom evaluate methods from in pages.xml

    Patrick Madden Newbie

      Hi, I'm integrating my site with openid. I am trying to write some custom navigation from the generated openid.xhtml page view.


      The 2.1.1.GA documentation in section 15.13.3 and 15.13.4 describes immediate login and deferring login with openid. I'm am opting for deferred login after making sure the user has registered with our site etc.


      The navigation for immediate login is as follows


      <page view-id="/openid.xhtml">
      <navigation evaluate="#{openid.loginImmediately()}">
      <rule if-outcome="true">
      <redirect view-id="/main.xhtml">
      <message>OpenID login successful...</message>
      </redirect>
      </rule>
      <rule if-outcome="false">
      <redirect view-id="/main.xhtml">
      <message>OpenID login rejected...</message>
      </redirect>
      </rule>
      </navigation>
      </page>



      However I would like to do something like the following using my own CUSTOM EVALUATOR method:



          <!-- There is no openid.xhtml in our code - its is automatically generated by Seam -->
           <page view-id="/openid.xhtml">
                <navigation evaluate="#{openidAuthenticator.authenticate}">
                     <rule if-outcome="registerFirst">
                          <redirect view-id="/registerOpenidUser.xhtml">
                               <message>Please verify your existence...</message>
                          </redirect>
                     </rule>          
                     <rule if-outcome="success">
                          <redirect view-id="/openidValidated.xhtml">
                               <message>OpenID Login validated...</message>
                          </redirect>
                     </rule>
                     <rule if-outcome="failure">
                          <redirect view-id="/login.xhtml">
                               <message>OpenID Login rejected...</message>
                          </redirect>
                     </rule>               
                </navigation>
           </page>




      @Name("openidAuthenticator")
      @Install(precedence=Install.BUILT_IN, classDependencies="org.openid4java.consumer.ConsumerManager")
      public class OpenidAuthenticator {
           @Logger
           private Log log;
      
           @In
           Identity identity;
      
           // This seamOpenid name is an alias defined in components.xml
           @In
           OpenId seamOpenid;
           
           /**
            * Gets called from pages.xml
            * 
            * @return
            */     
           public String authenticate()
           {
                if (seamOpenid.isValid())
                {
                     
                     if (check the database and see if this person has registered)
                     {
                          return "success";
                     }
                     else
                     {
                          // check for valid email address and register the user
                          return "registerFirst";
                     }
                     
                }
                else
                {
                     return "failure";
                }
           }
      ...
      }




      However, when I try this I get the following stack trace:
      
      INFO   | jvm 1    | 2009/01/22 15:09:54 | 15:09:54,256 INFO  [ConsumerManager] Verification succeeded for: https://foobar.myopenid.com/
      INFO   | jvm 1    | 2009/01/22 15:09:54 | 15:09:54,256 INFO  [STDOUT] *** EXT: []
      INFO   | jvm 1    | 2009/01/22 15:09:54 | 15:09:54,264 WARN  [lifecycle] JSF1053: (Listener: org.jboss.seam.security.openid.OpenIdPhaseListener.beforePhase(), P
      hase ID: RENDER_RESPONSE 6,  View ID: /openid.xhtml) Exception thrown during phase-listener execution: javax.el.PropertyNotFoundException: Property 'authenticat
      e' not found on type com.tomsawyer.search.pub.ejb.session.OpenidAuthenticator_$$_javassist_2
      INFO   | jvm 1    | 2009/01/22 15:09:54 | 15:09:54,264 WARN  [lifecycle] javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:193)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:170)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | javax.el.BeanELResolver.property(BeanELResolver.java:279)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | javax.el.BeanELResolver.getValue(BeanELResolver.java:60)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.core.Expressions$1.getValue(Expressions.java:112)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.navigation.Navigation.navigate(Navigation.java:50)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.navigation.Pages.navigate(Pages.java:203)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.jsf.SeamNavigationHandler.handleNavigation(SeamNavigationHandler.java:42)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.navigation.Pages.handleOutcome(Pages.java:668)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.security.openid.OpenIdPhaseListener.beforePhase(OpenIdPhaseListener.java:46)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.web.RewriteFilter.doFilter(RewriteFilter.java:63)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
      INFO   | jvm 1    | 2009/01/22 15:09:54 | java.lang.Thread.run(Thread.java:619)
      INFO   | jvm 1    | 2009/01/22 15:09:54 |




      Is there anything special I need to do. I've tried changing the return method for my own authenticate method to boolean instead of string but I get the same error. I don't see where OpenId.authenticate method is anything different from my own but I can call its isValid and loginImmediately methods from pages.xml.


      Thanks in advance!!!


      PVM