1 17 18 19 20 package org.apache.lenya.ac.impl; 21 22 import org.apache.lenya.ac.AccessControlException; 23 import org.apache.lenya.ac.Accreditable; 24 import org.apache.lenya.ac.AccreditableManager; 25 import org.apache.lenya.ac.Group; 26 import org.apache.lenya.ac.IPRange; 27 import org.apache.lenya.ac.User; 28 29 32 public class RemovedAccreditablePolicyBuilder extends PolicyBuilder { 33 34 38 public RemovedAccreditablePolicyBuilder(AccreditableManager accreditableManager) { 39 super(accreditableManager); 40 } 41 42 private Accreditable removedAccreditable; 43 44 49 public void setRemovedAccreditable(Accreditable accreditable) { 50 this.removedAccreditable = accreditable; 51 } 52 53 56 protected Accreditable getAccreditable(String elementName, String id) 57 throws AccessControlException { 58 59 Accreditable accreditable; 60 61 if (removedAccreditable instanceof User 62 && elementName.equals(USER_ELEMENT) 63 && ((User) removedAccreditable).getId().equals(id)) { 64 accreditable = removedAccreditable; 65 } else if ( 66 removedAccreditable instanceof Group 67 && elementName.equals(GROUP_ELEMENT) 68 && ((Group) removedAccreditable).getId().equals(id)) { 69 accreditable = removedAccreditable; 70 } else if ( 71 removedAccreditable instanceof IPRange 72 && elementName.equals(IP_RANGE_ELEMENT) 73 && ((IPRange) removedAccreditable).getId().equals(id)) { 74 accreditable = removedAccreditable; 75 } else { 76 77 accreditable = super.getAccreditable(elementName, id); 78 } 79 return accreditable; 80 } 81 82 } 83 | Popular Tags |