Coverage report

  %line %branch
org.apache.jetspeed.security.PortalResourcePermission
0% 
0% 

 1  
 /* 
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
 *
 9  
 *     http://www.apache.org/licenses/LICENSE-2.0
 10  
 *
 11  
 * Unless required by applicable law or agreed to in writing, software
 12  
 * distributed under the License is distributed on an "AS IS" BASIS,
 13  
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
 * See the License for the specific language governing permissions and
 15  
 * limitations under the License.
 16  
 */
 17  
 package org.apache.jetspeed.security;
 18  
 
 19  
 import org.apache.jetspeed.JetspeedActions;
 20  
 
 21  
 import java.security.Permission;
 22  
 import java.security.PermissionCollection;
 23  
 
 24  
 /**
 25  
  * <p>Generalized Portlet Resoure permission.</p>
 26  
  * <p>This code was partially inspired from articles from:</p>
 27  
  * <ul>
 28  
  * <li><a href="http://www-106.ibm.com/developerworks/library/j-jaas/">
 29  
  * Extend JAAS for class instance-level authorization.</a></li>
 30  
  * </ul>
 31  
  *
 32  
  * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
 33  
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
 34  
  */
 35  
 public abstract class PortalResourcePermission extends Permission
 36  
 {
 37  
     /**
 38  
      * <p>Mask used for determining what actions are allowed or requested.</p>
 39  
      */
 40  
     protected final int mask;
 41  
 
 42  
     /**
 43  
      * <p>Constructor for PortletPermission.</p>
 44  
      *
 45  
      * @param name    The portlet name.
 46  
      * @param actions The actions on the portlet.
 47  
      */
 48  
     public PortalResourcePermission(String name, String actions)
 49  
     {
 50  0
         super(name);
 51  0
         mask = parseActions(actions);
 52  0
     }
 53  
 
 54  
     /**
 55  
      * <p>Constructor for PortletPermission.</p>
 56  
      *
 57  
      * @param name The portlet name.
 58  
      * @param mask The mask representing actions on the portlet.
 59  
      */
 60  
     public PortalResourcePermission(String name, int mask)
 61  
     {
 62  0
         super(name);
 63  0
         this.mask = mask;
 64  0
     }
 65  
 
 66  
     /**
 67  
      * @see java.security.Permission#hashCode()
 68  
      */
 69  
     public int hashCode()
 70  
     {
 71  0
         StringBuffer value = new StringBuffer(getName());
 72  0
         return value.toString().hashCode() ^ mask;
 73  
     }
 74  
 
 75  
     /**
 76  
      * @see java.security.Permission#getActions()
 77  
      */
 78  
     public String getActions()
 79  
     {
 80  0
         return JetspeedActions.getContainerActions(mask);
 81  
     }
 82  
 
 83  
     /* (non-Javadoc)
 84  
      * @see java.security.Permission#implies(java.security.Permission)
 85  
      */
 86  
     public boolean implies(Permission permission)
 87  
     {
 88  0
         throw new IllegalStateException("Permission class did not implement implies");
 89  
     }
 90  
 
 91  
     /**
 92  
      * <p>Parses the actions string.</p>
 93  
      * <p>Actions are separated by commas or white space.</p>
 94  
      *
 95  
      * @param actions The actions
 96  
      */
 97  
     public static int parseActions(String actions)
 98  
     {
 99  0
         return JetspeedActions.getContainerActionsMask(actions);
 100  
     }
 101  
 
 102  
     /**
 103  
      * <p>Overrides <code>Permission.newPermissionCollection()</code>.</p>
 104  
      *
 105  
      * @see java.security.Permission#newPermissionCollection()
 106  
      */
 107  
     public PermissionCollection newPermissionCollection()
 108  
     {
 109  0
         return new PortalResourcePermissionCollection();
 110  
     }
 111  
 }

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