PermisRole | Line # 94 | 14 | 2 | 60.7% |
0.60714287
|
(1) | |||
Result | |||
0.53571427
|
issrg.test.ds.TestDS.testIssuing issrg.test.ds.TestDS.testIssuing | 1 PASS | |
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 | * Copyright (c) 2000-2005, University of Salford | |
48 | * All rights reserved. | |
49 | * | |
50 | * Redistribution and use in source and binary forms, with or without | |
51 | * modification, are permitted provided that the following conditions are met: | |
52 | * | |
53 | * Redistributions of source code must retain the above copyright notice, this | |
54 | * list of conditions and the following disclaimer. | |
55 | * | |
56 | * Redistributions in binary form must reproduce the above copyright notice, | |
57 | * this list of conditions and the following disclaimer in the documentation | |
58 | * and/or other materials provided with the distribution. | |
59 | * | |
60 | * Neither the name of the University of Salford nor the names of its | |
61 | * contributors may be used to endorse or promote products derived from this | |
62 | * software without specific prior written permission. | |
63 | * | |
64 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
65 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
66 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
67 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
68 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
69 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
70 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
71 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
72 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
73 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
74 | * POSSIBILITY OF SUCH DAMAGE. | |
75 | */ | |
76 | ||
77 | package issrg.ac.attributes; | |
78 | ||
79 | import iaik.asn1.*; | |
80 | import iaik.asn1.structures.*; | |
81 | import issrg.ac.DistinctAttribute; | |
82 | ||
83 | /** | |
84 | * This is a class for ASN.1 representation of the Permis Role value (singular). | |
85 | * Note that the Attribute implementation will deal with multiple values and | |
86 | * instantiate an appropriate value object for each of those. | |
87 | * | |
88 | * <p>This Attribute cannot | |
89 | * be registered just with one OID, because it represents the whole class of | |
90 | * attributes that are | |
91 | * just printable strings. | |
92 | */ | |
93 | ||
94 | public class PermisRole extends DistinctAttribute { | |
95 | /** | |
96 | * This is the string Name of the role of the given type | |
97 | */ | |
98 | protected String roleValue = ""; | |
99 | ||
100 | /** | |
101 | * Returns the Role Value. | |
102 | */ | |
103 | 1912 | public String getRoleValue(){ |
104 | 1912 | return roleValue; |
105 | } | |
106 | ||
107 | /** | |
108 | * Sets the Role Value. | |
109 | * | |
110 | * @param role - the role value | |
111 | */ | |
112 | 0 | public void setRoleValue(String role){ |
113 | 0 | roleValue=role; |
114 | } | |
115 | ||
116 | 0 | protected PermisRole() { |
117 | } | |
118 | ||
119 | /** | |
120 | * This constructor builds a single PermisRole, given an ASN1Object of its | |
121 | * single value. | |
122 | * | |
123 | * @param ao - the ASN1Object representing a single value | |
124 | */ | |
125 | 1141 | public PermisRole(ASN1Object ao) throws CodingException{ |
126 | 1141 | decode(ao); |
127 | } | |
128 | ||
129 | /** | |
130 | * This constructor builds a PermisRole given a parsed AttributeValue. | |
131 | * | |
132 | * @param av - the AttributeValue that represents PermisRole | |
133 | */ | |
134 | 1888 | public PermisRole(issrg.ac.AttributeValue av) throws CodingException{ |
135 | 1888 | decode(av.getRawAttribute()); |
136 | } | |
137 | ||
138 | /** | |
139 | * This constructor copies a given PermisRole. | |
140 | * | |
141 | * @param pr - the PermisRole to copy | |
142 | */ | |
143 | 0 | public PermisRole(PermisRole pr){ |
144 | 0 | roleValue = pr.roleValue; |
145 | } | |
146 | ||
147 | /** | |
148 | * This constructor creates a PermisRole given its String value. | |
149 | * | |
150 | * @param roleValue - the role value | |
151 | */ | |
152 | 24 | public PermisRole(String roleValue){ |
153 | 24 | this.roleValue=roleValue; |
154 | } | |
155 | ||
156 | /** | |
157 | * This method returns the ASN1Object representing PermisRole attribute value. | |
158 | * | |
159 | * @return PrintableString with the role value | |
160 | */ | |
161 | 48 | public ASN1Object toASN1Object() throws CodingException{ |
162 | 48 | return new PrintableString(roleValue); |
163 | } | |
164 | ||
165 | ||
166 | /** | |
167 | * This method decodes a given ASN1Object and upon successful decoding sets | |
168 | * the role value as contained in the ASN1Object. | |
169 | * | |
170 | * @param ao - ASN1Object to decode; must be a PrintableString | |
171 | */ | |
172 | 3029 | public void decode(ASN1Object ao) throws CodingException{ |
173 | 3029 | super.decode(ao); // this will invoke the inherited decode method, which will set the fields required for this attribute to be handled as a usual AttributeValue |
174 | 3029 | if (!ao.isA(ASN.PrintableString)){ |
175 | 0 | throw new CodingException("RoleValue PrintableString was expected"); |
176 | } | |
177 | 3029 | roleValue = (String)ao.getValue(); |
178 | } | |
179 | ||
180 | 0 | public String toString(String indent){ |
181 | 0 | return "roleValue = "+roleValue; |
182 | } | |
183 | ||
184 | ||
185 | 0 | public Object clone(){ |
186 | 0 | return new PermisRole(this); |
187 | } | |
188 | ||
189 | /** | |
190 | * This method registers PermisRole as a value of attributes with a specific | |
191 | * OID. After PermisRole has been registered, Attribute can recognise | |
192 | * the attributes with this OID and use PermisRole to parse the individual | |
193 | * values of that attribute. | |
194 | * | |
195 | * @param oid - the dotted form of the OID of the attribute that represents | |
196 | * a PermisRole | |
197 | */ | |
198 | 1 | public static void registerMe(String oid){ |
199 | 1 | issrg.ac.Attribute.registerAttribute(oid, PermisRole.class); |
200 | } | |
201 | } | |
202 |
|