2 Replies Latest reply on Oct 13, 2009 10:48 AM by Kevin Gusnadi

    How to make our own Identity

    Kevin Gusnadi Newbie

      Greetings .


      I'm new to seam and i'd like to ask about org.jboss.seam.security.Identity .


      Let's say i have this class


      import org.jboss.seam.security.Identity;
      
      @Name("org.jboss.seam.security.identity")  
      @Scope(ScopeType.SESSION)  
      @Install(precedence = Install.APPLICATION)  
      @BypassInterceptors  
      @Startup 
      public class CustomIdentity extends Identity
      {
         public boolean hasPrivileges(String privilege){
                 
            if(privilege.equals("admin")
                return true;
            else
                return false;
         }
      }
      



      and then in the pages.xml i have


      <page view-id="/admin/user/test.xhtml">
          <restrict>#{s:hasPrivileges('admin')}</restrict>
      </page>
      



      when i try to call test.xhtml from my browser i got jboss debug.mvn page that said the following exception :


      Caused by javax.el.ELException with message: Function 's:hasPrivileges' not found


      org.jboss.el.lang.ExpressionBuilder.visit(ExpressionBuilder.java:187)
      org.jboss.el.parser.SimpleNode.accept(SimpleNode.java:129)
      org.jboss.el.lang.ExpressionBuilder.prepare(ExpressionBuilder.java:138)
      org.jboss.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:152)
      org.jboss.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:206)
      org.jboss.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:68)
      org.jboss.seam.el.SeamExpressionFactory.createValueExpression(SeamExpressionFactory.java:98)
      org.jboss.seam.core.Expressions$1.createExpression(Expressions.java:107)
      org.jboss.seam.core.Expressions$1.toUnifiedValueExpression(Expressions.java:91)
      org.jboss.seam.core.Expressions$1.getValue(Expressions.java:112)
      org.jboss.seam.security.Identity.evaluateExpression(Identity.java:644)
      org.jboss.seam.security.Identity.checkRestriction(Identity.java:210)
      org.jboss.seam.navigation.Page.checkPermission(Page.java:263)
      org.jboss.seam.navigation.Page.preRender(Page.java:283)
      org.jboss.seam.navigation.Pages.preRender(Pages.java:350)
      org.jboss.seam.jsf.SeamPhaseListener.preRenderPage(SeamPhaseListener.java:561)
      org.jboss.seam.jsf.SeamPhaseListener.beforeRenderResponse(SeamPhaseListener.java:472)
      org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:148)
      org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:118)
      com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
      com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)
      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      org.jboss.seam.web.RewriteFilter.doFilter(RewriteFilter.java:63)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
      org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
      org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:368)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
      org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
      org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
      org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
      org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      java.lang.Thread.run(Thread.java:613)
      



      Anybody can share some pointers ?


      Thanks and regards :)