11 Replies Latest reply on Jun 8, 2007 3:45 PM by joeyxxx

    Extending Identity/RuleBasedIdentity

    joeyxxx

      Where might one find comprehensive directions on how to extend Identity.
      I've seen a couple of examples posted here but annotations don't seem to be consistent in the examples given.

      If I override a @Create method, do I need to annotate the sub class method as well?

        • 1. Re: Extending Identity/RuleBasedIdentity
          gavin.king

           

          If I override a @Create method, do I need to annotate the sub class method as well?


          No, you do not, indeed, Seam will throw an exception if you do. (Actually I think the exception is not elegant behavior and I should fix that.)

          • 2. Re: Extending Identity/RuleBasedIdentity
            joeyxxx

            Where do you configure Seam Identity/RulesBasedIdentity is being used?
            I've extended RulebasedIdentity to include a couple of fields that handle form input fields presented on the login page.
            Each time I go to the login page, I get the ff error:

            javax.faces.el.PropertyNotFoundException: /login.xhtml @32,64 value="#{identity.destination}": Bean: org.jboss.seam.security.RuleBasedIdentity, property: destination
            at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:58)

            @Name("org.jboss.seam.core.identity")
            @Scope(ScopeType.SESSION)
            @Intercept(InterceptionType.AFTER_RESTORE_VIEW)
            @Startup
            public class MyIdentity extends RulesBasedIdentity {
            
             private String destination;
            
             public void create(){
             super.create();
             destination="";
             }
            
             public String getDestination() {
             return destination;
             }
            
             public void setDestination(String destination) {
             this.destination = destination;
             }
            }
            


            • 3. Re: Extending Identity/RuleBasedIdentity
              joeyxxx

              Hmm I'll try outjecting destination and see if that helps.

              • 4. Re: Extending Identity/RuleBasedIdentity
                joeyxxx

                Well obviously that didn't help :-) I'll try injecting some sleep.

                • 5. Re: Extending Identity/RuleBasedIdentity
                  gavin.king

                  That should be enough to do the trick. Make sure you have seam.properties in the jar that you are deploying your component in.

                  • 6. Re: Extending Identity/RuleBasedIdentity
                    shane.bryzak

                    And it should be org.jboss.seam.security.identity, not org.jboss.seam.core.identity.

                    • 7. Re: Extending Identity/RuleBasedIdentity
                      joeyxxx

                      Thanks for your time guys.
                      When I use

                      @Name("org.jboss.seam.security.identity")

                      I get the ff error.
                      javax.faces.el.EvaluationException: /layout/menu.xhtml @13,95 rendered="#{identity.loggedIn}": Exception getting value of property loggedIn of base of type : com.baisidirect.action.MyIdentity_$$_javassist_5

                      If I extend Identity instead, then deployment fails entirely. I also verified that seam.properties is at the root of jar that contains MyIdentity

                      What gives?.

                      • 8. Re: Extending Identity/RuleBasedIdentity
                        joeyxxx

                        I keep getting the ff error.

                        javax.faces.el.PropertyNotFoundException: /login.xhtml @32,66 value="#{identity.myDestination}": Bean: org.jboss.seam.security.RuleBasedIdentity, property: myDestination
                         at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:58)
                         at javax.faces.component.UIOutput.getValue(UIOutput.java:77)
                        


                        I've tried different combinations of annotations on myDestination yet nothing seems to work.

                        The ff is the code for the subclass I want to use in place of the default identity object

                        @Name("org.jboss.seam.core.identity")
                        @Scope(ScopeType.SESSION)
                        @Intercept(InterceptionType.AFTER_RESTORE_VIEW)
                        @Startup
                        public class MyIdentity extends RuleBasedIdentity {
                        
                         private String myDestination;
                        
                         @Logger Log log;
                        
                         public void create(){
                        
                         super.create();
                         this.myDestination="xxx is not null";
                         log.info("My create is called and destination is set to:"+ myDestination);
                         }
                        
                         public String getMyDestination() {
                         return myDestination;
                         }
                        
                         public void setMyDestination(String destination) {
                         this.myDestination = destination;
                         }
                        }
                        


                        The ff is the code in the facelets template
                        <h:outputLabel for="myDestination">Destination</h:outputLabel>
                         <h:inputText id="myDestination"
                         value="#{identity.myDestination}"/>
                        


                        From the JBoss server logs, the ff entries indicate that an instance of MYIdentity is loaded and that the @Create method is invoked.
                        10:33:01,484 INFO [Component] Component: org.jboss.seam.core.identity, scope: SESSION, type: JAVA_BEAN, class: com.baisidirect.action.MyIdentity
                        10:39:10,616 INFO [MyIdentity] My create is called and myDestination is set to:xxx is not null
                        


                        • 9. Re: Extending Identity/RuleBasedIdentity
                          joeyxxx

                          A workaround is to do away with the sub class and just use another bean for all fields on the login page that cannot be bound to identity but thats not as neat.

                          • 10. Re: Extending Identity/RuleBasedIdentity
                            gavin.king

                            Nonsense. That is not the solution you need. The problem is that you are *still* using "org.jboss.seam.core.identity" in your code instead of "org.jboss.seam.security.identity".

                            • 11. Re: Extending Identity/RuleBasedIdentity
                              joeyxxx

                              Thanks a bunch. Your help is very much appreciated. It works perfectly now. I started of with security.identity and I forgot to change it back after following a tip to use core.identity.