Coverage Report - org.openpermis.policy.bean.basic.BasicRoleAssignmentRuleCollection
 
Classes in this File Line Coverage Branch Coverage Complexity
BasicRoleAssignmentRuleCollection
81%
9/11
100%
2/2
1.2
 
 1  
 /*
 2  
  * Copyright (c) 2009, Swiss Federal Department of Defence Civil Protection and Sport
 3  
  *                     (http://www.vbs.admin.ch)
 4  
  * Copyright (c) 2009, Ergon Informatik AG (http://www.ergon.ch)
 5  
  * All rights reserved.
 6  
  *
 7  
  * Licensed under the Open Permis License which accompanies this distribution,
 8  
  * and is available at http://www.openpermis.org/BSDlicenceKent.txt
 9  
  */
 10  
 package org.openpermis.policy.bean.basic;
 11  
 
 12  
 import java.util.Collection;
 13  
 import java.util.HashSet;
 14  
 import java.util.List;
 15  
 import java.util.Set;
 16  
 
 17  
 import org.openpermis.Subject;
 18  
 import org.openpermis.policy.Role;
 19  
 import org.openpermis.policy.RoleAssignmentRule;
 20  
 import org.openpermis.policy.TimeStamp;
 21  
 import org.openpermis.policy.bean.RoleAssignmentRuleBean;
 22  
 import org.openpermis.policy.bean.RoleAssignmentRuleBeanCollection;
 23  
 import org.openpermis.policy.bean.SerialNumber;
 24  
 
 25  
 
 26  
 /**
 27  
  * Basic implementation of {@link RoleAssignmentRuleBeanCollection}.
 28  
  * @since 0.3.0
 29  
  */
 30  0
 public class BasicRoleAssignmentRuleCollection 
 31  
         extends BasicAbstractCollection<RoleAssignmentRuleBean> 
 32  
         implements RoleAssignmentRuleBeanCollection 
 33  
 {
 34  
         
 35  
         //---- Static
 36  
         
 37  
         private static final long serialVersionUID = -956620427014379243L;
 38  
 
 39  
         //---- State
 40  
         
 41  
         //---- Constructors
 42  
         
 43  
         /**
 44  
          * Creates a basic role assignment rule collection.
 45  
          * @param serialNumber the serial number of this part.
 46  
          * @since 0.3.0
 47  
          */
 48  
         protected BasicRoleAssignmentRuleCollection (SerialNumber serialNumber) {
 49  266
                 super(serialNumber);
 50  266
         }
 51  
         
 52  
         /**
 53  
          * Creates a basic role assignment rule collection.
 54  
          * @param serialNumber the serial number of this part.
 55  
          * @param collection a collection of {@link RoleAssignmentRuleBean}'s.
 56  
          * @since 0.3.0
 57  
          */
 58  
         protected BasicRoleAssignmentRuleCollection (
 59  
                 SerialNumber serialNumber, 
 60  
                 Collection<RoleAssignmentRuleBean> collection
 61  
         ) {
 62  249
                 super(serialNumber, collection);
 63  248
         }
 64  
         
 65  
         //---- Methods
 66  
         
 67  
         //---- RoleAssignmentRuleCollection
 68  
         
 69  
         /**
 70  
          * @since 0.3.0
 71  
          */
 72  
         public Set<Role> verifyRoleAssignments (
 73  
                 Subject subject,
 74  
                 Set<Role> assertedRoles,
 75  
                 TimeStamp timeStamp
 76  
         ) {
 77  11
                 final Set<Role> result = new HashSet<Role>();
 78  11
                 for (RoleAssignmentRule roleAssignmentRule : this) {
 79  11
                         result.addAll(
 80  
                                 roleAssignmentRule.verifyRoleAssignment(subject, assertedRoles, timeStamp)
 81  
                         );
 82  
                 }
 83  11
                 return result;
 84  
         }
 85  
 
 86  
         //---- BasicAbstractCollection
 87  
         
 88  
         /**
 89  
          * @since 0.3.0
 90  
          */
 91  
         protected boolean isCollectionType (BasicPart part) {
 92  841
                 return part instanceof RoleAssignmentRuleBeanCollection;
 93  
         }
 94  
         
 95  
         //---- BeanCollection
 96  
         
 97  
         /**
 98  
          * @since 0.3.0
 99  
          */
 100  
         public BasicRoleAssignmentRuleCollection create (List<RoleAssignmentRuleBean> list) {
 101  0
                 return new BasicRoleAssignmentRuleCollection(getSerialNumber().next(), list);
 102  
         }
 103  
 
 104  
 }