Coverage report

  %line %branch
org.apache.turbine.om.security.TurbineGroup
0% 
0% 

 1  
 package org.apache.turbine.om.security;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2005 The Apache Software Foundation.
 5  
  *
 6  
  * Licensed under the Apache License, Version 2.0 (the "License")
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 import java.sql.Connection;
 20  
 import java.util.Iterator;
 21  
 
 22  
 import org.apache.turbine.services.security.TurbineSecurity;
 23  
 import org.apache.turbine.util.security.RoleSet;
 24  
 import org.apache.turbine.util.security.TurbineSecurityException;
 25  
 
 26  
 /**
 27  
  * This class represents a Group of Users in the system that are associated
 28  
  * with specific entity or resource. The users belonging to the Group may have
 29  
  * various Roles. The Permissions to perform actions upon the resource depend
 30  
  * on the Roles in the Group that they are assigned.
 31  
  *
 32  
  * <a name="global">
 33  
  * <p> Certain Roles that the Users may have in the system may are not related
 34  
  * to any specific resource nor entity.
 35  
  * They are assigned within a special group named 'global' that can be
 36  
  * referenced in the code as {@link #GLOBAL_GROUP_NAME}.
 37  
  * <br>
 38  
  *
 39  
  * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
 40  
  * @version $Id: TurbineGroup.java 278822 2005-09-05 19:53:05Z henning $
 41  
  */
 42  
 public class TurbineGroup extends SecurityObject implements Group
 43  
 {
 44  
     /** Serial Version UID */
 45  
     private static final long serialVersionUID = -6034684697021752649L;
 46  
 
 47  
     /**
 48  
      * Constructs a new Group.
 49  
      */
 50  
     public TurbineGroup()
 51  
     {
 52  0
         super();
 53  0
     }
 54  
 
 55  
     /**
 56  
      * Constructs a new Group with the specified name.
 57  
      *
 58  
      * @param name The name of the new object.
 59  
      */
 60  
     public TurbineGroup(String name)
 61  
     {
 62  0
         super(name);
 63  0
     }
 64  
 
 65  
     // These following methods are wrappers around TurbineSecurity
 66  
 
 67  
     /**
 68  
      * Makes changes made to the Group attributes permanent.
 69  
      *
 70  
      * @throws TurbineSecurityException if there is a problem while saving data.
 71  
      */
 72  
     public void save() throws TurbineSecurityException
 73  
     {
 74  0
         TurbineSecurity.saveGroup(this);
 75  0
     }
 76  
 
 77  
     /**
 78  
      * not implemented
 79  
      *
 80  
      * @param conn
 81  
      * @throws Exception
 82  
      */
 83  
     public void save(Connection conn) throws Exception
 84  
     {
 85  0
         throw new Exception("not implemented");
 86  
     }
 87  
 
 88  
     /**
 89  
      * not implemented
 90  
      *
 91  
      * @param dbname
 92  
      * @throws Exception
 93  
      */
 94  
     public void save(String dbname) throws Exception
 95  
     {
 96  0
         throw new Exception("not implemented");
 97  
     }
 98  
 
 99  
     /**
 100  
      * Removes a group from the system.
 101  
      *
 102  
      * @throws TurbineSecurityException if the Group could not be removed.
 103  
      */
 104  
     public void remove() throws TurbineSecurityException
 105  
     {
 106  0
         TurbineSecurity.removeGroup(this);
 107  0
     }
 108  
 
 109  
     /**
 110  
      * Renames the role.
 111  
      *
 112  
      * @param name The new Group name.
 113  
      * @throws TurbineSecurityException if the Group could not be renamed.
 114  
      */
 115  
     public void rename(String name) throws TurbineSecurityException
 116  
     {
 117  0
         TurbineSecurity.renameGroup(this, name);
 118  0
     }
 119  
 
 120  
     /**
 121  
      * Grants a Role in this Group to an User.
 122  
      *
 123  
      * @param user An User.
 124  
      * @param role A Role.
 125  
      * @throws TurbineSecurityException if there is a problem while assigning
 126  
      * the Role.
 127  
      */
 128  
     public void grant(User user, Role role) throws TurbineSecurityException
 129  
     {
 130  0
         TurbineSecurity.grant(user, this, role);
 131  0
     }
 132  
 
 133  
     /**
 134  
      * Grants Roles in this Group to an User.
 135  
      *
 136  
      * @param user An User.
 137  
      * @param roleSet A RoleSet.
 138  
      * @throws TurbineSecurityException if there is a problem while assigning
 139  
      * the Roles.
 140  
      */
 141  
     public void grant(User user, RoleSet roleSet)
 142  
             throws TurbineSecurityException
 143  
     {
 144  0
         for (Iterator roles = roleSet.iterator(); roles.hasNext();)
 145  
         {
 146  0
             TurbineSecurity.grant(user, this, (Role) roles.next());
 147  
         }
 148  0
     }
 149  
 
 150  
     /**
 151  
      * Revokes a Role in this Group from an User.
 152  
      *
 153  
      * @param user An User.
 154  
      * @param role A Role.
 155  
      * @throws TurbineSecurityException if there is a problem while unassigning
 156  
      * the Role.
 157  
      */
 158  
     public void revoke(User user, Role role) throws TurbineSecurityException
 159  
     {
 160  0
         TurbineSecurity.revoke(user, this, role);
 161  0
     }
 162  
 
 163  
     /**
 164  
      * Revokes Roles in this group from an User.
 165  
      *
 166  
      * @param user An User.
 167  
      * @param roleSet a RoleSet.
 168  
      * @throws TurbineSecurityException if there is a problem while unassigning
 169  
      * the Roles.
 170  
      */
 171  
     public void revoke(User user, RoleSet roleSet)
 172  
             throws TurbineSecurityException
 173  
     {
 174  0
         for (Iterator roles = roleSet.iterator(); roles.hasNext();)
 175  
         {
 176  0
             TurbineSecurity.revoke(user, this, (Role) roles.next());
 177  
         }
 178  0
     }
 179  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.