| DISRAPandParser | Line # 69 | 8 | 1 | 84.6% |
0.84615386
|
| No Tests | |||
| 1 | /* | |
| 2 | * Copyright (c) 2006, University of Kent | |
| 3 | * All rights reserved. | |
| 4 | * | |
| 5 | * Redistribution and use in source and binary forms, with or without | |
| 6 | * modification, are permitted provided that the following conditions are met: | |
| 7 | * | |
| 8 | * Redistributions of source code must retain the above copyright notice, this | |
| 9 | * list of conditions and the following disclaimer. | |
| 10 | * | |
| 11 | * Redistributions in binary form must reproduce the above copyright notice, | |
| 12 | * this list of conditions and the following disclaimer in the documentation | |
| 13 | * and/or other materials provided with the distribution. | |
| 14 | * | |
| 15 | * 1. Neither the name of the University of Kent nor the names of its | |
| 16 | * contributors may be used to endorse or promote products derived from this | |
| 17 | * software without specific prior written permission. | |
| 18 | * | |
| 19 | * 2. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | |
| 20 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
| 21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 22 | * PURPOSE ARE DISCLAIMED. | |
| 23 | * | |
| 24 | * 3. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
| 25 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 31 | * POSSIBILITY OF SUCH DAMAGE. | |
| 32 | * | |
| 33 | * 4. YOU AGREE THAT THE EXCLUSIONS IN PARAGRAPHS 2 AND 3 ABOVE ARE REASONABLE | |
| 34 | * IN THE CIRCUMSTANCES. IN PARTICULAR, YOU ACKNOWLEDGE (1) THAT THIS | |
| 35 | * SOFTWARE HAS BEEN MADE AVAILABLE TO YOU FREE OF CHARGE, (2) THAT THIS | |
| 36 | * SOFTWARE IS NOT "PRODUCT" QUALITY, BUT HAS BEEN PRODUCED BY A RESEARCH | |
| 37 | * GROUP WHO DESIRE TO MAKE THIS SOFTWARE FREELY AVAILABLE TO PEOPLE WHO WISH | |
| 38 | * TO USE IT, AND (3) THAT BECAUSE THIS SOFTWARE IS NOT OF "PRODUCT" QUALITY | |
| 39 | * IT IS INEVITABLE THAT THERE WILL BE BUGS AND ERRORS, AND POSSIBLY MORE | |
| 40 | * SERIOUS FAULTS, IN THIS SOFTWARE. | |
| 41 | * | |
| 42 | * 5. This license is governed, except to the extent that local laws | |
| 43 | * necessarily apply, by the laws of England and Wales. | |
| 44 | */ | |
| 45 | ||
| 46 | /* | |
| 47 | * DISPolicyFinder.java | |
| 48 | * | |
| 49 | * Created on April 4, 2006, 4:14 PM | |
| 50 | */ | |
| 51 | ||
| 52 | package issrg.dis; | |
| 53 | ||
| 54 | import issrg.pba.PolicyParser; | |
| 55 | import issrg.pba.rbac.CustomisePERMIS; | |
| 56 | import issrg.pba.rbac.LDAPDNPrincipal; | |
| 57 | import issrg.pba.rbac.RuleComparator; | |
| 58 | import issrg.pba.rbac.SignatureVerifier; | |
| 59 | import issrg.utils.repository.AttributeRepository; | |
| 60 | import org.apache.log4j.Level; | |
| 61 | ||
| 62 | ||
| 63 | ||
| 64 | /** | |
| 65 | *This class tries to retrieve the policy for the DIS and creates | |
| 66 | *some required object for the DIS: comparator, token parser and parsed policy | |
| 67 | * @author anhnt | |
| 68 | */ | |
| 69 | public class DISRAPandParser extends issrg.pba.rbac.x509.RepositoryACPolicyFinder { | |
| 70 | ||
| 71 | /** Creates a new instance of DISPolicyFinder */ | |
| 72 | private issrg.pba.rbac.RuleComparator comparator = CustomisePERMIS.getComparator(); | |
| 73 | private issrg.pba.AuthzTokenParser parser=CustomisePERMIS.getAuthTokenParser(); | |
| 74 | ||
| 75 | // static Logger log = Logger.getLogger(issrg.dis.DISRAPandParser.class); | |
| 76 | // static org.apache.log4j.Appender appender; | |
| 77 | // static org.apache.log4j.Layout layout = new org.apache.log4j.PatternLayout("%d{dd MM yyyy HH:mm:ss} %-5p %c %x - %m%n"); | |
| 78 | ||
| 79 | /** | |
| 80 | *This constructor used for creating the object with debug level | |
| 81 | *@param R is an attribute repository that stores the policy | |
| 82 | *@param OID is the policy identifier | |
| 83 | *@param SOA is the policy writer's DN | |
| 84 | *@param SV is a signature verifier that used for verifying user's certificate | |
| 85 | *@param level is the debuging level | |
| 86 | */ | |
| 87 | ||
| 88 | 1 |
public DISRAPandParser(AttributeRepository R, String OID, LDAPDNPrincipal SOA, SignatureVerifier SV, Level level) throws Exception { |
| 89 | 1 | super(R, OID, SOA, SV); |
| 90 | // if (level != null) log.setLevel(level); | |
| 91 | // appender = new org.apache.log4j.WriterAppender(layout, System.out); | |
| 92 | // BasicConfigurator.configure(appender); | |
| 93 | // log.debug("Finish calling the supper constructor, going to get the parser and allocationPolicy objects"); | |
| 94 | 1 | parser.setAuthTokenParsingRules(parsedPolicy.getAuthTokenParsingRules()); |
| 95 | 1 | parser.setSignatureVerifier(SV); |
| 96 | 1 | allocationPolicy = new issrg.pba.rbac.policies.AllocationPolicy(parsedPolicy.getAssignmentRules()); |
| 97 | // log.debug("Got the parser, allocation policy"); | |
| 98 | } | |
| 99 | ||
| 100 | /** | |
| 101 | *This constructor used for creating the object without debug level | |
| 102 | *@param R is an attribute repository that stores the policy | |
| 103 | *@param OID is the policy identifier | |
| 104 | *@param SOA is the policy writer's DN | |
| 105 | *@param SV is a signature verifier that used for verifying user's certificate | |
| 106 | */ | |
| 107 | ||
| 108 | 0 |
public DISRAPandParser(AttributeRepository R, String OID, LDAPDNPrincipal SOA, SignatureVerifier SV) throws Exception { |
| 109 | 0 | this(R, OID, SOA, SV, null); |
| 110 | } | |
| 111 | ||
| 112 | /** | |
| 113 | * This function return the comparator used in the DIS | |
| 114 | *@return comparator | |
| 115 | */ | |
| 116 | 1 |
public RuleComparator getComparator() { |
| 117 | 1 | return comparator; |
| 118 | } | |
| 119 | ||
| 120 | /** | |
| 121 | * This function return the parsed policy | |
| 122 | *@return parsedPolicy is the parsed policy | |
| 123 | */ | |
| 124 | ||
| 125 | 1 |
public PolicyParser getPolicyPaser() { |
| 126 | 1 | return parsedPolicy; |
| 127 | } | |
| 128 | ||
| 129 | /** | |
| 130 | * This function return the tokenPaser that | |
| 131 | * is used for decode the AC | |
| 132 | *@return tokenParser | |
| 133 | */ | |
| 134 | ||
| 135 | 1 |
public issrg.pba.AuthzTokenParser getAuthTokenParser() { |
| 136 | 1 | return parser; |
| 137 | } | |
| 138 | } | |
|
||||||||||