Coverage report

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

 1  
 package org.apache.turbine.om.security;
 2  
 
 3  
 /*
 4  
  * Copyright 2001-2004 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.PermissionSet;
 24  
 import org.apache.turbine.util.security.TurbineSecurityException;
 25  
 
 26  
 /**
 27  
  * This class represents a role played by the User associated with the
 28  
  * current Session.
 29  
  *
 30  
  * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
 31  
  * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
 32  
  * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
 33  
  * @version $Id: TurbineRole.java,v 1.6.2.2 2004/05/20 03:05:17 seade Exp $
 34  
  */
 35  
 public class TurbineRole extends SecurityObject implements Role
 36  
 {
 37  
     /**
 38  
      * Constructs a new Role
 39  
      */
 40  
     public TurbineRole()
 41  
     {
 42  0
         super();
 43  0
     }
 44  
 
 45  
     /**
 46  
      * Constructs a new Role with the sepcified name.
 47  
      *
 48  
      * @param name The name of the new object.
 49  
      */
 50  
     public TurbineRole(String name)
 51  
     {
 52  0
         super(name);
 53  0
     }
 54  
 
 55  
     /** The permissions for this role. */
 56  0
     private PermissionSet permissionSet = null;
 57  
 
 58  
     /**
 59  
      * Returns the set of Permissions associated with this Role.
 60  
      *
 61  
      * @return A PermissionSet.
 62  
      * @exception Exception a generic exception.
 63  
      */
 64  
     public PermissionSet getPermissions()
 65  
             throws Exception
 66  
     {
 67  0
         return permissionSet;
 68  
     }
 69  
 
 70  
     /**
 71  
      * Sets the Permissions associated with this Role.
 72  
      *
 73  
      * @param permissionSet A PermissionSet.
 74  
      */
 75  
     public void setPermissions(PermissionSet permissionSet)
 76  
     {
 77  0
         this.permissionSet = permissionSet;
 78  0
     }
 79  
 
 80  
     // These following methods are wrappers around TurbineSecurity
 81  
 
 82  
     /**
 83  
      * Creates a new Role in the system.
 84  
      *
 85  
      * @param name The name of the new Role.
 86  
      * @return An object representing the new Role.
 87  
      * @throws TurbineSecurityException if the Role could not be created.
 88  
      */
 89  
     public Role create(String name)
 90  
             throws TurbineSecurityException
 91  
     {
 92  
         //Role role = new Role(name);
 93  0
         Role role = new TurbineRole(name);
 94  0
         TurbineSecurity.addRole(role);
 95  0
         return role;
 96  
     }
 97  
 
 98  
     /**
 99  
      * Makes changes made to the Role attributes permanent.
 100  
      *
 101  
      * @throws TurbineSecurityException if there is a problem while
 102  
      *  saving data.
 103  
      */
 104  
     public void save()
 105  
             throws TurbineSecurityException
 106  
     {
 107  0
         TurbineSecurity.saveRole(this);
 108  0
     }
 109  
 
 110  
     /**
 111  
      * not implemented
 112  
      *
 113  
      * @param conn
 114  
      * @throws Exception
 115  
      */
 116  
     public void save(Connection conn) throws Exception
 117  
     {
 118  0
         throw new Exception("not implemented");
 119  
     }
 120  
 
 121  
     /**
 122  
      * not implemented
 123  
      *
 124  
      * @param dbname
 125  
      * @throws Exception
 126  
      */
 127  
     public void save(String dbname) throws Exception
 128  
     {
 129  0
         throw new Exception("not implemented");
 130  
     }
 131  
 
 132  
     /**
 133  
      * Removes a role from the system.
 134  
      *
 135  
      * @throws TurbineSecurityException if the Role could not be removed.
 136  
      */
 137  
     public void remove()
 138  
             throws TurbineSecurityException
 139  
     {
 140  0
         TurbineSecurity.removeRole(this);
 141  0
     }
 142  
 
 143  
     /**
 144  
      * Renames the role.
 145  
      *
 146  
      * @param name The new Role name.
 147  
      * @throws TurbineSecurityException if the Role could not be renamed.
 148  
      */
 149  
     public void rename(String name)
 150  
             throws TurbineSecurityException
 151  
     {
 152  0
         TurbineSecurity.renameRole(this, name);
 153  0
     }
 154  
 
 155  
     /**
 156  
      * Grants a Permission to this Role.
 157  
      *
 158  
      * @param permission A Permission.
 159  
      * @throws TurbineSecurityException if there is a problem while assigning
 160  
      * the Permission.
 161  
      */
 162  
     public void grant(Permission permission)
 163  
             throws TurbineSecurityException
 164  
     {
 165  0
         TurbineSecurity.grant(this, permission);
 166  0
     }
 167  
 
 168  
     /**
 169  
      * Grants Permissions from a PermissionSet to this Role.
 170  
      *
 171  
      * @param permissionSet A PermissionSet.
 172  
      * @throws TurbineSecurityException if there is a problem while assigning
 173  
      * the Permissions.
 174  
      */
 175  
     public void grant(PermissionSet permissionSet)
 176  
             throws TurbineSecurityException
 177  
     {
 178  0
         for (Iterator permissions = permissionSet.iterator(); permissions.hasNext();)
 179  
         {
 180  0
             TurbineSecurity.grant(this, (Permission) permissions.next());
 181  
         }
 182  0
     }
 183  
 
 184  
     /**
 185  
      * Revokes a Permission from this Role.
 186  
      *
 187  
      * @param permission A Permission.
 188  
      * @throws TurbineSecurityException if there is a problem while unassigning
 189  
      * the Permission.
 190  
      */
 191  
     public void revoke(Permission permission)
 192  
             throws TurbineSecurityException
 193  
     {
 194  0
         TurbineSecurity.revoke(this, permission);
 195  0
     }
 196  
 
 197  
     /**
 198  
      * Revokes Permissions from a PermissionSet from this Role.
 199  
      *
 200  
      * @param permissionSet A PermissionSet.
 201  
      * @throws TurbineSecurityException if there is a problem while unassigning
 202  
      * the Permissions.
 203  
      */
 204  
     public void revoke(PermissionSet permissionSet)
 205  
             throws TurbineSecurityException
 206  
     {
 207  0
         for (Iterator permissions = permissionSet.iterator(); permissions.hasNext();)
 208  
         {
 209  0
             TurbineSecurity.revoke(this, (Permission) permissions.next());
 210  
         }
 211  0
     }
 212  
 }

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