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

Shane Bryzak Shane_Bryzak at symantec.com
Mon Oct 9 19:27:27 EDT 2006


  User: sbryzak2
  Date: 06/10/09 19:27:27

  Modified:    src/main/org/jboss/seam/security   Authentication.java
  Added:       src/main/org/jboss/seam/security   SeamSecurityManager.java
  Log:
  Role-based domain security
  
  Revision  Changes    Path
  1.5       +17 -0     jboss-seam/src/main/org/jboss/seam/security/Authentication.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Authentication.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/security/Authentication.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- Authentication.java	24 Aug 2006 00:07:23 -0000	1.4
  +++ Authentication.java	9 Oct 2006 23:27:27 -0000	1.5
  @@ -57,4 +57,21 @@
     {
       valid = false;
     }
  +
  +  /**
  +   * Checks if the authenticated user contains the specified role.
  +   *
  +   * @param role String
  +   * @return boolean Returns true if the authenticated user contains the role,
  +   * or false if otherwise.
  +   */
  +  public boolean isUserInRole(String role)
  +  {
  +    for (String r : getRoles())
  +    {
  +      if (r.equals(role))
  +        return true;
  +    }
  +    return false;
  +  }
   }
  
  
  
  1.1      date: 2006/10/09 23:27:27;  author: sbryzak2;  state: Exp;jboss-seam/src/main/org/jboss/seam/security/SeamSecurityManager.java
  
  Index: SeamSecurityManager.java
  ===================================================================
  package org.jboss.seam.security;
  
  import org.jboss.seam.annotations.Name;
  import org.jboss.seam.annotations.Scope;
  import static org.jboss.seam.ScopeType.APPLICATION;
  import org.jboss.seam.contexts.Contexts;
  import org.jboss.seam.Component;
  import org.jboss.seam.ScopeType;
  
  /**
   *
   *
   * @author Shane Bryzak
   */
  @Scope(APPLICATION)
  @Name("org.jboss.seam.securityManager")
  public class SeamSecurityManager
  {
  
  
    public static SeamSecurityManager instance()
    {
      if (!Contexts.isApplicationContextActive())
         throw new IllegalStateException("No active application context");
  
      SeamSecurityManager instance = (SeamSecurityManager) Component.getInstance(
          SeamSecurityManager.class, ScopeType.APPLICATION, true);
  
      if (instance==null)
      {
        throw new IllegalStateException(
            "No SeamSecurityManager could be created, make sure the Component exists in application scope");
      }
  
      return instance;
    }
  
  }
  
  
  



More information about the jboss-cvs-commits mailing list