10 Replies Latest reply on Feb 15, 2012 4:59 PM by Jason Porter

    How to make ViewConfig work

    Feng Jiang Newbie

      Hi, everyone:

            

           I have a demand on Seam Security ViewConfig.  If the user has logged in that a request for the views  on  /pages/*  would be granted.  if not , the user will be redirected to the login view  /login.xhtml.

       

      my @ViewConfig interface as follows:

       

      @ViewConfig
      public interface Pages {
      
                static enum page{
      
              @ViewPattern("/*")
              @LoginView("/login.xhtml")
              @AccessDeniedView("/item/list.xhtml")
              ALL,
      
              @ViewPattern("/pages/*")
              @LoginView("/login.xhtml")
              @User
               User;
                }
      }
      

       

      the User annotation create by @SecurityBindingType

       

      @SecurityBindingType
      @Retention(RetentionPolicy.RUNTIME)
      @Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
      public @interface User {
      }
      

       

      The authorization method annotated with @Secure

       

      public class SecurityRules {
      
                public @Secures @User boolean userChecker(Identity identity) {
                     if (identity.getUser() == null) {
                               return false;
                     } else {
                               return true;
                     }
                }
      }
      

       

      Now there are some problem. When i request the view /pages/test.xhtml , the authorization method userChecker will be invoked , but whether false or true it return .  The  access also be granted.

       

      How would i to do with the ViewConfig?

       

      I used the seam 3.1.0.final and jboss as 7.0.2.final