You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jv...@apache.org on 2001/07/10 02:39:16 UTC

cvs commit: jakarta-turbine/src/adapter/org/apache/turbine/util/security AccessControlException.java AccessControlList.java DataBackendException.java EntityExistsException.java GroupSet.java PasswordMismatchException.java PermissionSet.java RoleSet.java TurbineSecurityException.java UnknownEntityException.java

jvanzyl     01/07/09 17:39:16

  Added:       src/adapter/org/apache/turbine/util/security
                        AccessControlException.java AccessControlList.java
                        DataBackendException.java
                        EntityExistsException.java GroupSet.java
                        PasswordMismatchException.java PermissionSet.java
                        RoleSet.java TurbineSecurityException.java
                        UnknownEntityException.java
  Log:
  - adapter code, these should be moved as per the security prop
  
  Revision  Changes    Path
  1.1                  jakarta-turbine/src/adapter/org/apache/turbine/util/security/AccessControlException.java
  
  Index: AccessControlException.java
  ===================================================================
  package org.apache.turbine.util.security;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and 
   *    "Apache Turbine" must not be used to endorse or promote products 
   *    derived from this software without prior written permission. For 
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without 
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /**
   * Thrown to indicate that the User attempted to perform an operation that
   * was not permitted by the security settings.
   *
   * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
   * @version $Id: AccessControlException.java,v 1.1 2001/07/10 00:39:15 jvanzyl Exp $
   */
  public class AccessControlException
      extends TurbineSecurityException
  {
      /**
       * Construct an AccessControlException with specified detail message.
       *
       * @param msg The detail message.
       */
      public AccessControlException( String msg )
      {
          super(msg);
      }
  };
  
  
  
  1.1                  jakarta-turbine/src/adapter/org/apache/turbine/util/security/AccessControlList.java
  
  Index: AccessControlList.java
  ===================================================================
  package org.apache.turbine.util.security;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and 
   *    "Apache Turbine" must not be used to endorse or promote products 
   *    derived from this software without prior written permission. For 
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without 
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import java.io.Serializable;
  
  import java.util.Map;
  import java.util.Set;
  import java.util.Iterator;
  
  import org.apache.turbine.om.security.Group;
  import org.apache.turbine.om.security.Permission;
  import org.apache.turbine.om.security.Role;
  
  import org.apache.turbine.services.security.TurbineSecurity;
  
  /**
   * This is a control class that makes it easy to find out if a
   * particular User has a given Permission.  It also determines if a
   * User has a a particular Role.
   *
   * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
   * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
   * @author <a href="mailto:greg@shwoop.com">Greg Ritter</a>
   * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
   * @version $Id: AccessControlList.java,v 1.1 2001/07/10 00:39:15 jvanzyl Exp $
   */
  public class AccessControlList implements Serializable
  {
      /** The sets of roles that the user has in different groups */
      private Map roleSets;
  
      /** The sets of permissions that the user has in different groups */
      private Map permissionSets;
  
      public static java.lang.String SESSION_KEY = "turbine.AccessControlList";
  
      /**
       * Constructs a new AccessControlList.
       *
       * This class follows 'immutable' pattern - it's objects can't be modified
       * once they are created. This means that the permissions the users have are
       * in effect form the moment they log in to the moment they log out, and 
       * changes made to the security settings in that time are not reflected
       * in the state of this object. If you need to reset an user's permissions
       * you need to invalidate his session. <br>
       * The objects that constructs an AccessControlList must supply hashtables 
       * of role/permission sets keyed with group objects. <br>
       *
       * @param roleSets a hashtable containing RoleSet objects keyed with Group objects
       * @param permissionSets a hashtable containing PermissionSet objects keyed with Group objects
       */
      public AccessControlList( Map roleSets, Map permissionSets )
      {
          this.roleSets = roleSets;
          this.permissionSets = permissionSets;
      }
  
      /**
       * Retrieves a set of Roles an user is assigned in a Group.
       *
       * @param group the Group 
       * @return the set of Roles this user has within the Group.
       */
      public RoleSet getRoles( Group group )
      {
          if(group == null)
              return null;
          return (RoleSet)roleSets.get(group);
      }
  
      /**
       * Retrieves a set of Roles an user is assigned in the global Group.
       *
       * @param group the Group 
       * @return the set of Roles this user has within the global Group.
       */
      public RoleSet getRoles()
      {
          return getRoles(TurbineSecurity.getGlobalGroup());
      }
  
      /**
       * Retrieves a set of Permissions an user is assigned in a Group.
       *
       * @param group the Group 
       * @return the set of Permissions this user has within the Group.
       */
      public PermissionSet getPermissions( Group group )
      {
          if(group == null)
              return null;
          return (PermissionSet)permissionSets.get(group);
      }
  
      /**
       * Retrieves a set of Permissions an user is assigned in the global Group.
       *
       * @param group the Group 
       * @return the set of Permissions this user has within the global Group.
       */
      public PermissionSet getPermissions()
      {
          return getPermissions(TurbineSecurity.getGlobalGroup());
      }
  
      /**
       * Checks if the user is assigned a specific Role in the Group.
       * 
       * @param role the Role
       * @param group the Group
       * @return <code>true</code> if the user is assigned the Role in the Group.
       */
      public boolean hasRole( Role role, Group group )
      {
          RoleSet set = getRoles(group);
          if(set == null || role == null)
              return false;
          return set.contains(role);
      }
  
      /**
       * Checks if the user is assigned a specific Role in any of the given 
       * Groups
       *
       * @param role the Role
       * @param groupset a Groupset
       * @return <code>true</code> if the user is assigned the Role in any of 
       *         the given Groups.
       */
      public boolean hasRole( Role role, GroupSet groupset )
      {
          if(role == null)
          {
              return false;
          }
          Iterator groups = groupset.elements();
          while(groups.hasNext()) 
          {
              Group group = (Group)groups.next();
              RoleSet roles = getRoles(group);
              if(roles != null) 
              {
                  if(roles.contains(role))
                  {
                      return true;
                  }
              }
          }
          return false;
      }
  
      /**
       * Checks if the user is assigned a specific Role in the Group.
       * 
       * @param role the Role
       * @param group the Group
       * @return <code>true</code> if the user is assigned the Role in the Group.
       */
      public boolean hasRole( String role, String group )
      {
          try
          {
              return hasRole(TurbineSecurity.getRole(role), TurbineSecurity.getGroup(group));
          }
          catch(Exception e)
          {
              return false;
          }
      }
  
      /**
       * Checks if the user is assigned a specifie Role in any of the given 
       * Groups
       *
       * @param rolename the name of the Role
       * @param groupset a Groupset
       * @return <code>true</code> if the user is assigned the Role in any of 
       *         the given Groups.
       */
      public boolean hasRole( String rolename, GroupSet groupset )
      {
          Role role;
          try
          {
              role = TurbineSecurity.getRole(rolename);
          }
          catch(TurbineSecurityException e)
          {
              return false;
          }
          if(role == null)
          {
              return false;
          }
          Iterator groups = groupset.elements();
          while(groups.hasNext()) 
          {
              Group group = (Group)groups.next();
              RoleSet roles = getRoles(group);
              if(roles != null) 
              {
                  if(roles.contains(role))
                  {
                      return true;
                  }
              }
          }
          return false;
      }
  
      /**
       * Checks if the user is assigned a specific Role in the global Group.
       * 
       * @param role the Role
       * @param group the Group
       * @return <code>true</code> if the user is assigned the Role in the global Group.
       */
      public boolean hasRole( Role role )
      {
          return hasRole(role, TurbineSecurity.getGlobalGroup());
      }
  
      /**
       * Checks if the user is assigned a specific Role in the global Group.
       * 
       * @param role the Role
       * @param group the Group
       * @return <code>true</code> if the user is assigned the Role in the global Group.
       */
      public boolean hasRole( String role )
      {
          try
          {
              return hasRole(TurbineSecurity.getRole(role));
          }
          catch(Exception e)
          {
              return false;
          }
      }
  
      /**
       * Checks if the user is assigned a specific Permission in the Group.
       * 
       * @param permission the Permission
       * @param group the Group
       * @return <code>true</code> if the user is assigned the Permission in the Group.
       */
      public boolean hasPermission( Permission permission, Group group )
      {
          PermissionSet set = getPermissions(group);
          if(set == null || permission == null)
              return false;
          return set.contains(permission);
      }
  
      /**
       * Checks if the user is assigned a specific Permission in any of the given 
       * Groups
       *
       * @param permission the Permission
       * @param groupset a Groupset
       * @return <code>true</code> if the user is assigned the Permission in any 
       *         of the given Groups.
       */
      public boolean hasPermission( Permission permission, GroupSet groupset )
      {
          if(permission == null)
          {
              return false;
          }
          Iterator groups = groupset.elements();
          while(groups.hasNext()) 
          {
              Group group = (Group)groups.next();
              PermissionSet permissions = getPermissions(group);
              if(permissions != null) 
              {
                  if(permissions.contains(permission))
                  {
                      return true;
                  }
              }
          }
          return false;
      }
  
      /**
       * Checks if the user is assigned a specific Permission in the Group.
       * 
       * @param permission the Permission
       * @param group the Group
       * @return <code>true</code> if the user is assigned the Permission in the Group.
       */
      public boolean hasPermission( String permission, String group )
      {
          try
          {
              return hasPermission(TurbineSecurity.getPermission(permission), 
                                   TurbineSecurity.getGroup(group));
          }
          catch(Exception e)
          {
              return false;
          }
      }
  
      /**
       * Checks if the user is assigned a specific Permission in the Group.
       * 
       * @param permission the Permission
       * @param group the Group
       * @return <code>true</code> if the user is assigned the Permission in the Group.
       */
      public boolean hasPermission( String permission, Group group )
      {
          try
          {
              return hasPermission(
                  TurbineSecurity.getPermission(permission), group);
          }
          catch(Exception e)
          {
              return false;
          }
      }
  
      /**
       * Checks if the user is assigned a specifie Permission in any of the given 
       * Groups
       *
       * @param permissionName the name of the Permission
       * @param groupset a Groupset
       * @return <code>true</code> if the user is assigned the Permission in any 
       *         of the given Groups.
       */
      public boolean hasPermission( String permissionName, GroupSet groupset )
      {
          Permission permission;
          try
          {
              permission = TurbineSecurity.getPermission(permissionName);
          }
          catch(TurbineSecurityException e)
          {
              return false;
          }
          if(permission == null)
          {
              return false;
          }
          Iterator groups = groupset.elements();
          while(groups.hasNext()) 
          {
              Group group = (Group)groups.next();
              PermissionSet permissions = getPermissions(group);
              if(permissions != null) 
              {
                  if(permissions.contains(permission))
                  {
                      return true;
                  }
              }
          }
          return false;
      }
  
      /**
       * Checks if the user is assigned a specific Permission in the global Group.
       * 
       * @param permission the Permission
       * @param group the Group
       * @return <code>true</code> if the user is assigned the Permission in the global Group.
       */
      public boolean hasPermission( Permission permission )
      {
          return hasPermission(permission, TurbineSecurity.getGlobalGroup());
      }
  
      /**
       * Checks if the user is assigned a specific Permission in the global Group.
       * 
       * @param permission the Permission
       * @param group the Group
       * @return <code>true</code> if the user is assigned the Permission in the global Group.
       */
      public boolean hasPermission( String permission )
      {
          try
          {
              return hasPermission(TurbineSecurity.getPermission(permission));
          }
          catch(Exception e)
          {
              return false;
          }
      }
  
      /**
       * Returns all groups definded in the system.
       *
       * This is useful for debugging, when you want to display all roles
       * and permissions an user is assingned. This method is needed
       * because you can't call static methods of TurbineSecurity class
       * from within WebMacro/Velocity template
       */
      public Group[] getAllGroups()
      {
          try 
          {
              return TurbineSecurity.getAllGroups().getGroupsArray();
          }
          catch(TurbineSecurityException e) 
          {
              return new Group[0];
          }
      }
  }
  
  
  
  1.1                  jakarta-turbine/src/adapter/org/apache/turbine/util/security/DataBackendException.java
  
  Index: DataBackendException.java
  ===================================================================
  package org.apache.turbine.util.security;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and 
   *    "Apache Turbine" must not be used to endorse or promote products 
   *    derived from this software without prior written permission. For 
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without 
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /**
   * Thrown to indicate that there was an error accessing the data
   * backend of the SecurityService.
   *
   * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
   * @version $Id: DataBackendException.java,v 1.1 2001/07/10 00:39:15 jvanzyl Exp $
   */
  public class DataBackendException
      extends TurbineSecurityException
  {
      /**
       * Construct an DataBackendException with specified detail message.
       *
       * @param msg The detail message.
       * @param nested the exception or error that caused this exception 
       *               to be thrown.
       */
      public DataBackendException( String msg )
      {
          super(msg);
      }
  
      /**
       * Construct an DataBackendException with specified detail message
       * and nested <code>Throwable</code>.
       *
       * @param msg The detail message.
       * @param nested the exception or error that caused this exception 
       *               to be thrown.
       */
      public DataBackendException( String msg, Throwable nested )
      {
          super(msg, nested);
      }
  };
  
  
  
  1.1                  jakarta-turbine/src/adapter/org/apache/turbine/util/security/EntityExistsException.java
  
  Index: EntityExistsException.java
  ===================================================================
  package org.apache.turbine.util.security;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and 
   *    "Apache Turbine" must not be used to endorse or promote products 
   *    derived from this software without prior written permission. For 
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without 
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /**
   * Thrown upon an attempt to create an User,Role,Group or Permission that
   * already exists.
   *
   * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
   * @version $Id: EntityExistsException.java,v 1.1 2001/07/10 00:39:15 jvanzyl Exp $
   */
  public class EntityExistsException
      extends TurbineSecurityException
  {
      /**
       * Construct an EntityExistsException with specified detail message.
       *
       * @param msg The detail message.
       */
      public EntityExistsException( String msg )
      {
          super(msg);
      }
  };
  
  
  
  1.1                  jakarta-turbine/src/adapter/org/apache/turbine/util/security/GroupSet.java
  
  Index: GroupSet.java
  ===================================================================
  package org.apache.turbine.util.security;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and 
   *    "Apache Turbine" must not be used to endorse or promote products 
   *    derived from this software without prior written permission. For 
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without 
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import java.io.Serializable;
  
  import java.util.AbstractCollection;
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.TreeSet;
  
  import org.apache.turbine.om.security.Group;
  
  /**
   * This class represents a set of Groups. It's useful for building
   * administration UI.  It wraps a TreeSet object to enforce that only
   * Group objects are allowed in the set and only relevant methods
   * are available.  TreeSet's contain only unique Objects (no
   * duplicates).
   *
   * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
   * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
   * @version $Id: GroupSet.java,v 1.1 2001/07/10 00:39:15 jvanzyl Exp $
   */
  public class GroupSet implements Serializable
  {
      /** Set to hold the Group Set */
      private TreeSet set;
  
      /**
       * Constructs an empty GroupSet
       */
      public GroupSet()
      {
          set = new TreeSet();
      }
      
      /**
       * Constructs a new GroupSet with specifed contents.
       * 
       * If the given collection contains multiple objects that are
       * identical WRT equals() method, some objects will be overwriten.
       *
       * @param groups A collection of groups to be contained in the set.
       */
      public GroupSet(Collection groups)
      {
          this();
          add(groups);
      }
  
      /**
       * Adds a Group to this GroupSet.
       *
       * @param group A Group.
       * @return True if Group was added; false if GroupSet
       * already contained the Group.
       */
      public boolean add(Group group)
      {
          return set.add( (Object)group );
      }
  
      /**
       * Adds the Groups in a Collection to this GroupSet.
       *
       * @param groupSet A Collection of Groups.
       * @return True if this GroupSet changed as a result; false
       * if no change to this GroupSet occurred (this GroupSet
       * already contained all members of the added GroupSet).
       */
      public boolean add(Collection groups)
      {
          return set.addAll(groups);
      }
  
      /**
       * Adds the Groups in another GroupSet to this GroupSet.
       *
       * @param groupSet A GroupSet.
       * @return True if this GroupSet changed as a result; false
       * if no change to this GroupSet occurred (this GroupSet
       * already contained all members of the added GroupSet).
       */
      public boolean add(GroupSet groupSet)
      {
          return add((Collection)groupSet.set);
      }
  
      /**
       * Removes a Group from this GroupSet.
       *
       * @param group A Group.
       * @return True if this GroupSet contained the Group
       * before it was removed.
       */
      public boolean remove(Group group)
      {
          return set.remove( (Object)group );
      }
  
      /**
       * Removes all Groups from this GroupSet.
       */
      public void clear()
      {
          set.clear();
      }
  
      /**
       * Checks whether this GroupSet contains a Group.
       *
       * @param group A Group.
       * @return True if this GroupSet contains the Group,
       * false otherwise.
       */
      public boolean contains(Group group)
      {
          return set.contains( (Object)group );
      }
  
      /**
       * Compares by name a Group with the Groups contained in
       * this GroupSet.
       *
       * @param groupName Name of Group.
       * @return True if argument matched a Group in this
       * GroupSet; false if no match.
       */
      public boolean contains(String groupName)
      {
          Iterator iter = set.iterator();
          while ( iter.hasNext() )
          {
              Group group = (Group)iter.next();
              if ( groupName != null  &&
                   groupName.equals( group.getName() ) )
              {
                  return true;
              }
          }
          return false;
      }
  
      /**
       * Returns a Group with the given name, if it is contained in
       * this GroupSet.
       *
       * @param groupName Name of Group.
       * @return Group if argument matched a Group in this
       * GroupSet; null if no match.
       */
      public Group getGroup(String groupName)
      {
          Iterator iter = set.iterator();
          while ( iter.hasNext() )
          {
              Group group = (Group)iter.next();
              if ( groupName != null  &&
                   groupName.equals( group.getName() ) )
              {
                  return group;
              }
          }
          return null;
      }
  
      /**
       * Returns an Groups[] of Groups in this GroupSet.
       *
       * @return A Group[].
       */
      public Group[] getGroupsArray()
      {
          return (Group[])set.toArray(new Group[0]);
      }
  
      /**
       * Returns an Iterator for Groups in this GroupSet.
       */
      public Iterator elements()
      {
          return set.iterator();
      }
  
      /**
       * Returns size (cardinality) of this set.
       *
       * @return The cardinality of this GroupSet.
       */
      public int size()
      {
          return set.size();
      }
  }
  
  
  
  1.1                  jakarta-turbine/src/adapter/org/apache/turbine/util/security/PasswordMismatchException.java
  
  Index: PasswordMismatchException.java
  ===================================================================
  package org.apache.turbine.util.security;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and 
   *    "Apache Turbine" must not be used to endorse or promote products 
   *    derived from this software without prior written permission. For 
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without 
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /**
   * Thrown to indicate that the password supplied by user was incorrect. 
   *
   * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
   * @version $Id: PasswordMismatchException.java,v 1.1 2001/07/10 00:39:16 jvanzyl Exp $
   */
  public class PasswordMismatchException
      extends TurbineSecurityException
  {
      /**
       * Construct an PasswordMismatchException with specified detail message.
       *
       * @param msg The detail message.
       */
      public PasswordMismatchException( String msg )
      {
          super(msg);
      }
  };
  
  
  
  1.1                  jakarta-turbine/src/adapter/org/apache/turbine/util/security/PermissionSet.java
  
  Index: PermissionSet.java
  ===================================================================
  package org.apache.turbine.util.security;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import java.io.Serializable;
  
  import java.util.AbstractCollection;
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.TreeSet;
  
  import org.apache.turbine.om.security.Permission;
  import org.apache.turbine.om.security.SecurityEntity;
  
  /**
   * This class represents a set of Permissions.  It makes it easy to
   * build a UI that would allow someone to add a group of Permissions
   * to a Role.  It wraps a TreeSet object to enforce that only
   * Permission objects are allowed in the set and only relevant methods
   * are available.  TreeSet's contain only unique Objects (no
   * duplicates).
   *
   * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
   * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
   * @version $Id: PermissionSet.java,v 1.1 2001/07/10 00:39:16 jvanzyl Exp $
   */
  public class PermissionSet implements Serializable
  {
      /** Set to hold the Permission Set */
      private TreeSet set;
  
      /**
       * Constructs an empty PermissionSet
       */
      public PermissionSet()
      {
          set = new TreeSet();
      }
  
      /**
       * Constructs a new PermissionSet with specifed contents.
       *
       * If the given collection contains multiple objects that are
       * identical WRT equals() method, some objects will be overwriten.
       *
       * @param permissions A collection of permissions to be contained in the set.
       */
      public PermissionSet(Collection permissions)
      {
          this();
          add(permissions);
      }
  
      /**
       * Adds a Permission to this PermissionSet.
       *
       * @param group A Permission.
       * @return True if Permission was added; false if PermissionSet
       * already contained the Permission.
       */
      public boolean add(Permission permission)
      {
          return set.add( (Object)permission );
      }
  
      /**
       * Adds the Permissions in a Collection to this PermissionSet.
       *
       * @param permissionSet A Collection of Permissions.
       * @return True if this PermissionSet changed as a result; false
       * if no change to this PermissionSet occurred (this PermissionSet
       * already contained all members of the added PermissionSet).
       */
      public boolean add(Collection permissions)
      {
          return set.addAll(permissions);
      }
  
      /**
       * Adds the Permissions in another PermissionSet to this
       * PermissionSet.
       *
       * @param groupSet A PermissionSet.
       * @return True if this PermissionSet changed as a result; false
       * if no change to this PermissionSet occurred (this PermissionSet
       * already contained all members of the added PermissionSet).
       */
      public boolean add(PermissionSet permissionSet)
      {
          return set.addAll(  (Collection) permissionSet.set );
      }
  
      /**
       * Removes a Permission from this PermissionSet.
       *
       * @param group A Permission.
       * @return True if this PermissionSet contained the Permission
       * before it was removed.
       */
      public boolean remove(Permission permission)
      {
          return set.remove( (Object)permission );
      }
  
      /**
       * Removes all Permissions from this PermissionSet.
       */
      public void clear()
      {
          set.clear();
      }
  
      /**
       * Checks whether this PermissionSet contains a Permission.
       *
       * @param group A Permission.
       * @return True if this PermissionSet contains the Permission,
       * false otherwise.
       */
      public boolean contains(Permission permission)
      {
          return set.contains( (Object)permission );
      }
  
      /**
       * Compares by name a Permission with the Permissions contained in
       * this PermissionSet.
       *
       * @param groupName Name of Permission.
       * @return True if argument matched a Permission in this
       * PermissionSet; false if no match.
       */
      public boolean contains(String permissionName)
      {
          Iterator iter = set.iterator();
          while ( iter.hasNext() )
          {
              Permission permission = (Permission)iter.next();
              if ( permissionName != null  &&
                   permissionName.equals( ((SecurityEntity)permission).getName() ) )
              {
                  return true;
              }
          }
          return false;
      }
  
      /**
       * Returns a Permission with the given name, if it is contained in
       * this PermissionSet.
       *
       * @param groupName Name of Permission.
       * @return Permission if argument matched a Permission in this
       * PermissionSet; null if no match.
       */
      public Permission getPermission(String permissionName)
      {
          Iterator iter = set.iterator();
          while ( iter.hasNext() )
          {
              Permission permission = (Permission)iter.next();
              if ( permissionName != null  &&
                   permissionName.equals( ((SecurityEntity)permission).getName() ) )
              {
                  return permission;
              }
          }
          return null;
      }
  
      /**
       * Returns an Permissions[] of Permissions in this PermissionSet.
       *
       * @return A Permission[].
       */
      public Permission[] getPermissionsArray()
      {
          return (Permission[])set.toArray(new Permission[0]);
      }
  
      /**
       * Returns an Iterator for Permissions in this PermissionSet.
       */
      public Iterator elements()
      {
          return set.iterator();
      }
  
      /**
       * Returns size (cardinality) of this set.
       *
       * @return The cardinality of this PermissionSet.
       */
      public int size()
      {
          return set.size();
      }
  }
  
  
  
  1.1                  jakarta-turbine/src/adapter/org/apache/turbine/util/security/RoleSet.java
  
  Index: RoleSet.java
  ===================================================================
  package org.apache.turbine.util.security;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and 
   *    "Apache Turbine" must not be used to endorse or promote products 
   *    derived from this software without prior written permission. For 
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without 
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import java.io.Serializable;
  
  import java.util.AbstractCollection;
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.TreeSet;
  
  import org.apache.turbine.om.security.Role;
  import org.apache.turbine.om.security.SecurityEntity;
  
  /**
   * This class represents a set of Roles.  It makes it easy to build a
   * UI that would allow someone to add a group of Roles to a User.  It
   * wraps a TreeSet object to enforce that only Role objects are
   * allowed in the set and only relevant methods are available.
   * TreeSet's contain only unique Objects (no duplicates).
   *
   * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
   * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
   * @version $Id: RoleSet.java,v 1.1 2001/07/10 00:39:16 jvanzyl Exp $
   */
  public class RoleSet implements Serializable
  {
      /** Set to hold the Role Set */
      private TreeSet set;
  
      /**
       * Constructs an empty RoleSet
       */
      public RoleSet()
      {
          set = new TreeSet();
      }
      
      /**
       * Constructs a new RoleSet with specifed contents.
       * 
       * If the given collection contains multiple objects that are
       * identical WRT equals() method, some objects will be overwriten.
       *
       * @param roles A collection of roles to be contained in the set.
       */
      public RoleSet(Collection roles)
      {
          this();
          add(roles);
      }
  
      /**
       * Adds a Role to this RoleSet.
       *
       * @param role A Role.
       * @return True if Role was added; false if RoleSet already
       * contained the Role.
       */
      public boolean add(Role role)
      {
          return set.add( (Object)role );
      }
  
      /**
       * Adds the Roles in a Collection to this RoleSet.
       *
       * @param roleSet A Collection of Roles.
       * @return True if this RoleSet changed as a result; false
       * if no change to this RoleSet occurred (this RoleSet
       * already contained all members of the added RoleSet).
       */
      public boolean add(Collection roles)
      {
          return set.addAll(roles);
      }
  
      /**
       * Adds the Roles in another RoleSet to this RoleSet.
       *
       * @param roleSet A RoleSet.
       * @return True if this RoleSet changed as a result; false if no
       * change to this RoleSet occurred (this RoleSet already contained
       * all members of the added RoleSet).
       */
      public boolean add(RoleSet roleSet)
      {
          return set.add((Collection)roleSet.set);
      }
  
      /**
       * Removes a Role from this RoleSet.
       *
       * @param role A Role.
       * @return True if this RoleSet contained the Role before it was
       * removed.
       */
      public boolean remove(Role role)
      {
          return set.remove( (Object)role );
      }
  
      /**
       * Removes all Roles from this RoleSet.
       */
      public void clear()
      {
          set.clear();
      }
  
      /**
       * Checks whether this RoleSet contains a Role.
       *
       * @param role A Role.
       * @return True if this RoleSet contains the Role, false
       * otherwise.
       */
      public boolean contains(Role role)
      {
          return set.contains( (Object)role );
      }
  
      /**
       * Compares by name a Role with the Roles contained in this
       * RoleSet.
       *
       * @param roleName Name of Role.
       * @return True if argument matched a Role in this RoleSet; false
       * if no match.
       */
      public boolean contains(String roleName)
      {
          Iterator iter = set.iterator();
          while ( iter.hasNext() )
          {
              Role role = (Role)iter.next();
              if ( roleName != null  &&
                   roleName.equals( role.getName() ) )
              {
                  return true;
              }
          }
          return false;
      }
  
      /**
       * Returns a Role with the given name, if it is contained in this
       * RoleSet.
       *
       * @param roleName Name of Role.
       * @return Role if argument matched a Role in this RoleSet; null
       * if no match.
       */
      public Role getRole(String roleName)
      {
          Iterator iter = set.iterator();
          while ( iter.hasNext() )
          {
              Role role = (Role)iter.next();
              if ( roleName != null  &&
                   roleName.equals( role.getName() ) )
              {
                  return role;
              }
          }
          return null;
      }
  
      /**
       * Returns an Roles[] of Roles in this RoleSet.
       *
       * @return A Role[].
       */
      public Role[] getRolesArray()
      {
          return (Role[])set.toArray(new Role[0]);
      }
  
      /**
       * Returns an Iterator for Roles in this RoleSet.  
       */
      public Iterator elements()
      {
          return set.iterator();
      }
  
      /**
       * Returns size (cardinality) of this set.
       *
       * @return The cardinality of this RoleSet.
       */
      public int size()
      {
          return set.size();
      }
  }
  
  
  
  1.1                  jakarta-turbine/src/adapter/org/apache/turbine/util/security/TurbineSecurityException.java
  
  Index: TurbineSecurityException.java
  ===================================================================
  package org.apache.turbine.util.security;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and 
   *    "Apache Turbine" must not be used to endorse or promote products 
   *    derived from this software without prior written permission. For 
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without 
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import org.apache.turbine.util.TurbineException;
  
  /**
   * Thrown by SecurityService methods to indicate various problems. 
   *
   * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
   * @version $Id: TurbineSecurityException.java,v 1.1 2001/07/10 00:39:16 jvanzyl Exp $
   */
  public class TurbineSecurityException
      extends TurbineException
  {
      /**
       * Construct an SecurityException with specified detail message.
       *
       * @param msg The detail message.
       */
      public TurbineSecurityException( String msg )
      {
          super(msg);
      }
  
      /**
       * Construct an SecurityException with specified detail message
       * and nested <code>Throwable</code>.
       *
       * @param msg The detail message.
       * @param nested the exception or error that caused this exception 
       *               to be thrown.
       */
      public TurbineSecurityException( String msg, Throwable nested )
      {
          super(msg, nested);
      }
  };
  
  
  
  1.1                  jakarta-turbine/src/adapter/org/apache/turbine/util/security/UnknownEntityException.java
  
  Index: UnknownEntityException.java
  ===================================================================
  package org.apache.turbine.util.security;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and 
   *    "Apache Turbine" must not be used to endorse or promote products 
   *    derived from this software without prior written permission. For 
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without 
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /**
   * Thrown to indicate that the User,Role,Group or Permission that
   * was requested does not exist.
   *
   * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
   * @version $Id: UnknownEntityException.java,v 1.1 2001/07/10 00:39:16 jvanzyl Exp $
   */
  public class UnknownEntityException
      extends TurbineSecurityException
  {
      /**
       * Construct an UnknownEntityException with specified detail message.
       *
       * @param msg The detail message.
       */
      public UnknownEntityException( String msg )
      {
          super(msg);
      }
  
      /**
       * Construct an UnknownEntityException with specified detail message
       * and nested <code>Throwable</code>.
       *
       * @param msg The detail message.
       * @param nested the exception or error that caused this exception 
       *               to be thrown.
       */
      public UnknownEntityException( String msg, Throwable nested )
      {
          super(msg, nested);
      }
  };
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org