[jboss-cvs] jboss-seam/src/main/org/jboss/seam/web ...

Gavin King gavin.king at jboss.com
Tue Jun 19 16:08:14 EDT 2007


  User: gavin   
  Date: 07/06/19 16:08:14

  Modified:    src/main/org/jboss/seam/web      Parameters.java
                        RedirectFilter.java ServletContexts.java
  Added:       src/main/org/jboss/seam/web      IsUserInRole.java
                        UserPrincipal.java
  Log:
  more repackaging
  
  Revision  Changes    Path
  1.2       +1 -1      jboss-seam/src/main/org/jboss/seam/web/Parameters.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Parameters.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/web/Parameters.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- Parameters.java	19 Jun 2007 19:02:37 -0000	1.1
  +++ Parameters.java	19 Jun 2007 20:08:14 -0000	1.2
  @@ -16,7 +16,7 @@
   import org.jboss.seam.annotations.Name;
   import org.jboss.seam.annotations.Scope;
   
  - at Name("org.jboss.seam.core.parameters")
  + at Name("org.jboss.seam.web.parameters")
   @Intercept(InterceptionType.NEVER)
   @Scope(ScopeType.STATELESS)
   @Install(precedence=BUILT_IN)
  
  
  
  1.11      +2 -2      jboss-seam/src/main/org/jboss/seam/web/RedirectFilter.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: RedirectFilter.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/web/RedirectFilter.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- RedirectFilter.java	19 Jun 2007 19:02:37 -0000	1.10
  +++ RedirectFilter.java	19 Jun 2007 20:08:14 -0000	1.11
  @@ -22,7 +22,7 @@
   import org.jboss.seam.annotations.Scope;
   import org.jboss.seam.annotations.Startup;
   import org.jboss.seam.contexts.Contexts;
  -import org.jboss.seam.faces.JsfManager;
  +import org.jboss.seam.faces.FacesManager;
   import org.jboss.seam.navigation.Pages;
   
   /**
  @@ -63,7 +63,7 @@
                     {
                        url = Pages.instance().encodePageParameters( FacesContext.getCurrentInstance(), url, viewId );
                     }
  -                  url = JsfManager.instance().appendConversationIdFromRedirectFilter(url, viewId);
  +                  url = FacesManager.instance().appendConversationIdFromRedirectFilter(url, viewId);
                  }
               }
               super.sendRedirect(url);
  
  
  
  1.2       +1 -1      jboss-seam/src/main/org/jboss/seam/web/ServletContexts.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ServletContexts.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/web/ServletContexts.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- ServletContexts.java	19 Jun 2007 19:02:37 -0000	1.1
  +++ ServletContexts.java	19 Jun 2007 20:08:14 -0000	1.2
  @@ -26,7 +26,7 @@
    * @author Gavin King
    */
   @Scope(ScopeType.EVENT)
  - at Name("org.jboss.seam.core.httpServletRequest")
  + at Name("org.jboss.seam.web.servletContexts")
   @Intercept(InterceptionType.NEVER)
   @Install(precedence=BUILT_IN)
   public class ServletContexts 
  
  
  
  1.1      date: 2007/06/19 20:08:14;  author: gavin;  state: Exp;jboss-seam/src/main/org/jboss/seam/web/IsUserInRole.java
  
  Index: IsUserInRole.java
  ===================================================================
  package org.jboss.seam.web;
  
  import static org.jboss.seam.InterceptionType.NEVER;
  import static org.jboss.seam.annotations.Install.BUILT_IN;
  
  import java.util.AbstractMap;
  import java.util.Map;
  import java.util.Set;
  
  import javax.servlet.ServletRequest;
  import javax.servlet.http.HttpServletRequest;
  
  import org.jboss.seam.ScopeType;
  import org.jboss.seam.annotations.Install;
  import org.jboss.seam.annotations.Intercept;
  import org.jboss.seam.annotations.Name;
  import org.jboss.seam.annotations.Scope;
  import org.jboss.seam.annotations.Unwrap;
  
  /**
   * Manager component for a map of roles assigned
   * to the current user, as exposed via the JSF
   * ExternalContext.
   * 
   * @author Gavin King
   */
  @Scope(ScopeType.APPLICATION)
  @Intercept(NEVER)
  @Name("org.jboss.seam.web.isUserInRole")
  @Install(precedence=BUILT_IN)
  public class IsUserInRole
  {
     @Unwrap
     public Map<String, Boolean> getMap()
     {
        return new AbstractMap<String, Boolean>()
        {
           @Override
           public Set<Map.Entry<String, Boolean>> entrySet() {
              throw new UnsupportedOperationException();
           }
  
           @Override
           public Boolean get(Object key)
           {
              if ( !(key instanceof String ) ) return false;
              String role = (String) key;
              return isUserInRole(role);
           }
           
        };
     }
  
     protected Boolean isUserInRole(String role)
     {
        ServletRequest servletRequest = ServletContexts.instance().getRequest();
        if ( servletRequest != null )
        {
           return ( (HttpServletRequest) servletRequest ).isUserInRole(role);
        }
        return null;
     }
     
  }
  
  
  
  1.1      date: 2007/06/19 20:08:14;  author: gavin;  state: Exp;jboss-seam/src/main/org/jboss/seam/web/UserPrincipal.java
  
  Index: UserPrincipal.java
  ===================================================================
  package org.jboss.seam.web;
  
  import static org.jboss.seam.InterceptionType.NEVER;
  import static org.jboss.seam.annotations.Install.BUILT_IN;
  
  import java.security.Principal;
  
  import javax.servlet.ServletRequest;
  import javax.servlet.http.HttpServletRequest;
  
  import org.jboss.seam.Component;
  import org.jboss.seam.ScopeType;
  import org.jboss.seam.annotations.Install;
  import org.jboss.seam.annotations.Intercept;
  import org.jboss.seam.annotations.Name;
  import org.jboss.seam.annotations.Scope;
  import org.jboss.seam.annotations.Unwrap;
  import org.jboss.seam.contexts.Contexts;
  
  /**
   * Manager component for the current user Principal
   * exposed via the JSF ExternalContext.
   * 
   * @author Gavin King
   */
  @Scope(ScopeType.APPLICATION)
  @Intercept(NEVER)
  @Name("org.jboss.seam.web.userPrincipal")
  @Install(precedence=BUILT_IN)
  public class UserPrincipal
  {
     @Unwrap
     public Principal getUserPrincipal()
     {
        ServletRequest servletRequest = ServletContexts.instance().getRequest();
        if ( servletRequest != null )
        {
           return ( (HttpServletRequest) servletRequest ).getUserPrincipal();
        }
        
        return null;
     }
     
     public static Principal instance()
     {
        if ( !Contexts.isApplicationContextActive() )
        {
           throw new IllegalStateException("No active application scope");
        }
        return (Principal) Component.getInstance(UserPrincipal.class, ScopeType.APPLICATION);
     }
     
  }
  
  
  



More information about the jboss-cvs-commits mailing list