Clover coverage report - Acegi Security System for Spring - 1.0.0-RC1
Coverage timestamp: Mon Dec 5 2005 09:05:15 EST
file stats: LOC: 112   Methods: 4
NCLOC: 58   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SimpleAclEntry.java 100% 100% 100% 100%
coverage
 1    /* Copyright 2004 Acegi Technology Pty Limited
 2    *
 3    * Licensed under the Apache License, Version 2.0 (the "License");
 4    * you may not use this file except in compliance with the License.
 5    * You may obtain a copy of the License at
 6    *
 7    * http://www.apache.org/licenses/LICENSE-2.0
 8    *
 9    * Unless required by applicable law or agreed to in writing, software
 10    * distributed under the License is distributed on an "AS IS" BASIS,
 11    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    * See the License for the specific language governing permissions and
 13    * limitations under the License.
 14    */
 15   
 16    package org.acegisecurity.acl.basic;
 17   
 18    import org.apache.commons.logging.Log;
 19    import org.apache.commons.logging.LogFactory;
 20   
 21   
 22    /**
 23    * Stores some privileges typical of a domain object.
 24    *
 25    * @author Ben Alex
 26    * @version $Id: SimpleAclEntry.java,v 1.2 2005/11/17 00:55:47 benalex Exp $
 27    */
 28    public class SimpleAclEntry extends AbstractBasicAclEntry {
 29    //~ Static fields/initializers =============================================
 30   
 31    private static final Log logger = LogFactory.getLog(SimpleAclEntry.class);
 32   
 33    // Base permissions we permit
 34    public static final int NOTHING = 0;
 35    public static final int ADMINISTRATION = (int) Math.pow(2, 0);
 36    public static final int READ = (int) Math.pow(2, 1);
 37    public static final int WRITE = (int) Math.pow(2, 2);
 38    public static final int CREATE = (int) Math.pow(2, 3);
 39    public static final int DELETE = (int) Math.pow(2, 4);
 40   
 41    // Combinations of base permissions we permit
 42    public static final int READ_WRITE_CREATE_DELETE = READ | WRITE | CREATE
 43    | DELETE;
 44    public static final int READ_WRITE_CREATE = READ | WRITE | CREATE;
 45    public static final int READ_WRITE = READ | WRITE;
 46    public static final int READ_WRITE_DELETE = READ | WRITE | DELETE;
 47   
 48    // Array required by the abstract superclass via getValidPermissions()
 49    private static final int[] validPermissions = {NOTHING, ADMINISTRATION, READ, WRITE, CREATE, DELETE, READ_WRITE_CREATE_DELETE, READ_WRITE_CREATE, READ_WRITE, READ_WRITE_DELETE};
 50   
 51    //~ Constructors ===========================================================
 52   
 53    /**
 54    * Allows {@link BasicAclDao} implementations to construct this object
 55    * using <code>newInstance()</code>.
 56    *
 57    * <P>
 58    * Normal classes should <B>not</B> use this default constructor.
 59    * </p>
 60    */
 61  30 public SimpleAclEntry() {
 62  30 super();
 63    }
 64   
 65  133 public SimpleAclEntry(Object recipient,
 66    AclObjectIdentity aclObjectIdentity,
 67    AclObjectIdentity aclObjectParentIdentity, int mask) {
 68  133 super(recipient, aclObjectIdentity, aclObjectParentIdentity, mask);
 69    }
 70   
 71    //~ Methods ================================================================
 72   
 73  163 public int[] getValidPermissions() {
 74  163 return validPermissions;
 75    }
 76   
 77  6 public String printPermissionsBlock(int i) {
 78  6 StringBuffer sb = new StringBuffer();
 79   
 80  6 if (isPermitted(i, ADMINISTRATION)) {
 81  1 sb.append('A');
 82    } else {
 83  5 sb.append('-');
 84    }
 85   
 86  6 if (isPermitted(i, READ)) {
 87  2 sb.append('R');
 88    } else {
 89  4 sb.append('-');
 90    }
 91   
 92  6 if (isPermitted(i, WRITE)) {
 93  2 sb.append('W');
 94    } else {
 95  4 sb.append('-');
 96    }
 97   
 98  6 if (isPermitted(i, CREATE)) {
 99  2 sb.append('C');
 100    } else {
 101  4 sb.append('-');
 102    }
 103   
 104  6 if (isPermitted(i, DELETE)) {
 105  1 sb.append('D');
 106    } else {
 107  5 sb.append('-');
 108    }
 109   
 110  6 return sb.toString();
 111    }
 112    }