1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
package issrg.ac; |
77 |
|
|
78 |
|
import iaik.asn1.*; |
79 |
|
import iaik.asn1.structures.*; |
80 |
|
import java.math.BigInteger; |
81 |
|
import java.util.Vector; |
82 |
|
import java.util.Enumeration; |
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
|
|
| 61.1% |
Uncovered Elements: 79 (203) |
Complexity: 30 |
Complexity Density: 0.47 |
|
88 |
|
public class AttributeCertificateInfo implements ASN1Type, Cloneable{ |
89 |
|
|
90 |
|
protected AttCertVersion version = new AttCertVersion(); |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
95 |
0
|
public AttCertVersion getVersion(){... |
96 |
0
|
return version; |
97 |
|
} |
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
102 |
0
|
public void setVersion(AttCertVersion version){... |
103 |
0
|
this.version=version; |
104 |
|
} |
105 |
|
|
106 |
|
protected Holder holder = new Holder(); |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
111 |
7194
|
public Holder getHolder(){... |
112 |
7194
|
return holder; |
113 |
|
} |
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
118 |
0
|
public void setHolder(Holder holder){... |
119 |
0
|
this.holder=holder; |
120 |
|
} |
121 |
|
|
122 |
|
protected AttCertIssuer issuer = new AttCertIssuer(); |
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
127 |
3588
|
public AttCertIssuer getIssuer(){... |
128 |
3588
|
return issuer; |
129 |
|
} |
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
134 |
0
|
public void setIssuer(AttCertIssuer issuer){... |
135 |
0
|
this.issuer=issuer; |
136 |
|
} |
137 |
|
|
138 |
|
protected AlgorithmID signature = new AlgorithmID(); |
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
143 |
0
|
public AlgorithmID getSignatureAlgorithmID(){... |
144 |
0
|
return signature; |
145 |
|
} |
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
150 |
0
|
public void setSignatureAlgorithmID(AlgorithmID signature){... |
151 |
0
|
this.signature=signature; |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
|
protected BigInteger serialNumber = new BigInteger("0"); |
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
160 |
1
|
public BigInteger getSerialNumber(){... |
161 |
1
|
return serialNumber; |
162 |
|
} |
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
167 |
0
|
public void setSerialNumber(BigInteger serialNumber){... |
168 |
0
|
this.serialNumber=serialNumber; |
169 |
|
} |
170 |
|
|
171 |
|
|
172 |
|
protected AttCertValidityPeriod attrCertValidityPeriod = new AttCertValidityPeriod(); |
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
177 |
3598
|
public AttCertValidityPeriod getValidityPeriod(){... |
178 |
3598
|
return attrCertValidityPeriod; |
179 |
|
} |
180 |
|
|
181 |
|
|
182 |
|
|
183 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
184 |
0
|
public void setValidityPeriod(AttCertValidityPeriod validityPeriod){... |
185 |
0
|
this.attrCertValidityPeriod=validityPeriod; |
186 |
|
} |
187 |
|
|
188 |
|
protected Vector attributes = new Vector(); |
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
195 |
1813
|
public Vector getAttributes(){... |
196 |
1813
|
return attributes; |
197 |
|
} |
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
203 |
0
|
public void setAttributes(Vector attributes){... |
204 |
0
|
this.attributes=attributes; |
205 |
|
} |
206 |
|
|
207 |
|
protected BIT_STRING issuerUniqueID = null; |
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
213 |
0
|
public BIT_STRING getIssuerUniqueID(){... |
214 |
0
|
return issuerUniqueID; |
215 |
|
} |
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
221 |
0
|
public void setIssuerUniqueID(BIT_STRING issuerUniqueID){... |
222 |
0
|
this.issuerUniqueID=issuerUniqueID; |
223 |
|
} |
224 |
|
|
225 |
|
protected Extensions extensions = null; |
226 |
|
|
227 |
|
|
228 |
|
|
229 |
|
|
230 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
231 |
1779
|
public Extensions getExtensions(){... |
232 |
1779
|
return extensions; |
233 |
|
} |
234 |
|
|
235 |
|
|
236 |
|
|
237 |
|
|
238 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
239 |
0
|
public void setExtensions(Extensions extensions){... |
240 |
0
|
this.extensions=extensions; |
241 |
|
} |
242 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
243 |
2999
|
protected AttributeCertificateInfo() {... |
244 |
|
} |
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
@param |
250 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
251 |
2979
|
public AttributeCertificateInfo(ASN1Object ao) throws CodingException{... |
252 |
2979
|
decode(ao); |
253 |
|
} |
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
@param |
261 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 3 |
Complexity Density: 0.23 |
|
262 |
0
|
public AttributeCertificateInfo(AttributeCertificateInfo aci) throws CodingException{... |
263 |
0
|
version = new AttCertVersion(aci.version); |
264 |
0
|
holder = new Holder(aci.holder); |
265 |
0
|
issuer = new AttCertIssuer(aci.issuer); |
266 |
0
|
signature = new AlgorithmID(aci.signature.getAlgorithm(), aci.signature.getParameter()); |
267 |
0
|
serialNumber = new BigInteger(aci.serialNumber.toByteArray()); |
268 |
0
|
attrCertValidityPeriod = new AttCertValidityPeriod(aci.attrCertValidityPeriod); |
269 |
0
|
attributes = new Vector(aci.attributes); |
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
|
274 |
0
|
issuerUniqueID = null; |
275 |
0
|
if (aci.issuerUniqueID!=null){ |
276 |
0
|
issuerUniqueID = new BIT_STRING(aci.issuerUniqueID.getBinaryString()); |
277 |
|
} |
278 |
|
|
279 |
0
|
extensions = null; |
280 |
0
|
if (aci.extensions!=null){ |
281 |
0
|
extensions = new Extensions(aci.extensions); |
282 |
|
} |
283 |
|
} |
284 |
|
|
285 |
|
|
286 |
|
|
287 |
|
|
288 |
|
@param |
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
@param |
293 |
|
@param |
294 |
|
@param |
295 |
|
@param |
296 |
|
@param |
297 |
|
|
298 |
|
@param |
299 |
|
|
300 |
|
@param |
301 |
|
|
302 |
|
@param |
303 |
|
|
304 |
|
|
|
|
| 84.6% |
Uncovered Elements: 2 (13) |
Complexity: 2 |
Complexity Density: 0.18 |
|
305 |
20
|
public AttributeCertificateInfo(AttCertVersion version,... |
306 |
|
Holder holder, |
307 |
|
AttCertIssuer issuer, |
308 |
|
AlgorithmID signature, |
309 |
|
BigInteger serialNumber, |
310 |
|
AttCertValidityPeriod attrCertValidityPeriod, |
311 |
|
Vector attributes, |
312 |
|
BIT_STRING issuerUniqueID, |
313 |
|
Extensions extensions){ |
314 |
20
|
if (version == null){ |
315 |
0
|
version = new AttCertVersion(AttCertVersion.DEFAULT); |
316 |
|
} |
317 |
20
|
this.version = version; |
318 |
20
|
this.holder = holder; |
319 |
20
|
this.issuer = issuer; |
320 |
20
|
this.signature = signature; |
321 |
20
|
this.serialNumber = serialNumber; |
322 |
20
|
this.attrCertValidityPeriod = attrCertValidityPeriod; |
323 |
20
|
this.attributes = attributes; |
324 |
20
|
this.issuerUniqueID = issuerUniqueID; |
325 |
20
|
this.extensions = extensions; |
326 |
|
} |
327 |
|
|
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
@return |
332 |
|
|
333 |
|
|
|
|
| 69.2% |
Uncovered Elements: 12 (39) |
Complexity: 9 |
Complexity Density: 0.36 |
|
334 |
42
|
public ASN1Object toASN1Object() throws CodingException{... |
335 |
42
|
try{ |
336 |
42
|
ASN1Object seq = new SEQUENCE(); |
337 |
|
|
338 |
42
|
if (attributes==null){ |
339 |
0
|
throw new CodingException("Attribute list is empty"); |
340 |
|
}else{ |
341 |
|
|
342 |
84
|
for (int i=0; i<attributes.size(); i++){ |
343 |
42
|
String a = ((Attribute)attributes.elementAt(i)).type; |
344 |
42
|
for (int j=i+1; j<attributes.size(); j++){ |
345 |
0
|
if (((Attribute)attributes.elementAt(j)).type.equals(a)){ |
346 |
0
|
throw new CodingException("Attributes of the same type encountered: ["+i+"]=["+j+"]="+a); |
347 |
|
} |
348 |
|
} |
349 |
42
|
seq.addComponent(((issrg.ac.Attribute)attributes.elementAt(i)).toASN1Object()); |
350 |
|
} |
351 |
|
} |
352 |
|
|
353 |
42
|
ASN1Object result = ASN.create(new ASN(ASN.SEQUENCE.getTag(), "AttributeCertificateInfo", ASN.UNIVERSAL)); |
354 |
|
|
355 |
42
|
if (version.version!=version.DEFAULT){ |
356 |
42
|
result.addComponent(version.toASN1Object()); |
357 |
|
} |
358 |
42
|
result.addComponent(holder.toASN1Object()); |
359 |
42
|
result.addComponent(issuer.toASN1Object()); |
360 |
42
|
result.addComponent(signature.toASN1Object()); |
361 |
42
|
result.addComponent(new INTEGER(serialNumber)); |
362 |
42
|
result.addComponent(attrCertValidityPeriod.toASN1Object()); |
363 |
42
|
result.addComponent(seq); |
364 |
|
|
365 |
42
|
if (issuerUniqueID!=null){ |
366 |
0
|
result.addComponent(issuerUniqueID); |
367 |
|
} |
368 |
|
|
369 |
42
|
if (extensions!=null){ |
370 |
42
|
result.addComponent(extensions.toASN1Object()); |
371 |
|
} |
372 |
|
|
373 |
42
|
return result; |
374 |
|
}catch (InstantiationException ex){ |
375 |
|
|
376 |
0
|
throw new CodingException("Cannot encode due to tag instantiation exception"); |
377 |
|
} |
378 |
|
} |
379 |
|
|
380 |
|
|
381 |
|
|
382 |
|
|
383 |
|
|
384 |
|
@param |
385 |
|
|
386 |
|
|
387 |
|
|
|
|
| 81.2% |
Uncovered Elements: 12 (64) |
Complexity: 16 |
Complexity Density: 0.4 |
|
388 |
2979
|
public void decode(ASN1Object ao) throws CodingException{... |
389 |
2979
|
ASN type = ao.getAsnType(); |
390 |
2979
|
if (type.getTag()!=ASN.SEQUENCE.getTag() || type.getTagClass()!=ASN.UNIVERSAL){ |
391 |
0
|
throw new CodingException("AttributeCertificateInfo SEQUENCE tag was expected"); |
392 |
|
} |
393 |
|
|
394 |
2979
|
int i=0; |
395 |
2979
|
ASN1Object tag = ao.getComponentAt(i++); |
396 |
2979
|
type = tag.getAsnType(); |
397 |
|
|
398 |
2979
|
if (type.getTag()!=ASN.INTEGER.getTag() || type.getTagClass()!=ASN.UNIVERSAL){ |
399 |
|
|
400 |
739
|
version = new AttCertVersion((ASN1Object)null); |
401 |
|
}else{ |
402 |
2240
|
version = new AttCertVersion(tag); |
403 |
|
|
404 |
2240
|
tag = ao.getComponentAt(i++); |
405 |
|
} |
406 |
|
|
407 |
2979
|
holder = new Holder(tag); |
408 |
2979
|
issuer = new AttCertIssuer(ao.getComponentAt(i++)); |
409 |
1859
|
signature = new AlgorithmID(ao.getComponentAt(i++)); |
410 |
1859
|
serialNumber = (BigInteger)((INTEGER)ao.getComponentAt(i++)).getValue(); |
411 |
|
|
412 |
1859
|
attrCertValidityPeriod = new AttCertValidityPeriod(ao.getComponentAt(i++)); |
413 |
|
|
414 |
1859
|
attributes = new Vector(); |
415 |
1859
|
ASN1Object seq = ao.getComponentAt(i++); |
416 |
3723
|
for(int j=seq.countComponents(); j-->0; ){ |
417 |
1864
|
attributes.insertElementAt(new issrg.ac.Attribute(seq.getComponentAt(j)), 0); |
418 |
|
} |
419 |
|
|
420 |
1859
|
if (attributes.size()==0){ |
421 |
0
|
throw new CodingException("Attribute set is empty"); |
422 |
|
}else{ |
423 |
|
|
424 |
1864
|
for (int j=0; j<attributes.size()-1; j++){ |
425 |
5
|
String a = ((Attribute)attributes.elementAt(j)).type; |
426 |
10
|
for (int k=j+1; k<attributes.size(); k++){ |
427 |
5
|
if (((Attribute)attributes.elementAt(k)).type.equals(a)){ |
428 |
0
|
throw new CodingException("Attributes of the same type encountered: ["+j+"]=["+k+"]="+a); |
429 |
|
} |
430 |
|
} |
431 |
|
} |
432 |
|
} |
433 |
1859
|
issuerUniqueID = null; |
434 |
1859
|
extensions = null; |
435 |
|
|
436 |
1859
|
if (ao.countComponents()>i){ |
437 |
1859
|
tag = ao.getComponentAt(i++); |
438 |
1859
|
type = tag.getAsnType(); |
439 |
|
|
440 |
1859
|
if (type.getTag()==ASN.BIT_STRING.getTag() && type.getTagClass()==ASN.UNIVERSAL){ |
441 |
739
|
issuerUniqueID = (BIT_STRING)tag; |
442 |
|
|
443 |
739
|
if (ao.countComponents()>i){ |
444 |
739
|
tag = ao.getComponentAt(i++); |
445 |
|
}else{ |
446 |
0
|
tag = null; |
447 |
|
} |
448 |
|
} |
449 |
|
|
450 |
1859
|
if (tag!=null){ |
451 |
1859
|
extensions = new Extensions(tag); |
452 |
|
} |
453 |
|
|
454 |
1859
|
if (ao.countComponents()>i){ |
455 |
0
|
throw new CodingException("Extra entries found in AttributeCertificateInfo tag: "+Integer.toString(ao.countComponents())); |
456 |
|
} |
457 |
|
} |
458 |
|
} |
459 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
460 |
0
|
public String toString(){... |
461 |
0
|
return toString(""); |
462 |
|
} |
463 |
|
|
|
|
| 76.5% |
Uncovered Elements: 4 (17) |
Complexity: 3 |
Complexity Density: 0.43 |
|
464 |
4
|
public String toString(String ident){... |
465 |
4
|
Enumeration e = attributes.elements(); |
466 |
4
|
String result = |
467 |
|
"SEQUENCE { -- AttributeCertificateInfo --\n "+ident+ |
468 |
|
"version = "+version.toString(ident+" ")+",\n "+ident+ |
469 |
|
"holder = "+holder.toString(ident+" ")+",\n "+ident+ |
470 |
|
"issuer = "+issuer.toString(ident+" ")+",\n "+ident+ |
471 |
|
"signature = "+signature.toString()+",\n "+ident+ |
472 |
|
"serialNumber = "+serialNumber.toString()+",\n "+ident+ |
473 |
|
"attCertValidityPeriod = "+attrCertValidityPeriod.toString(ident+" ")+",\n "+ident+ |
474 |
|
"attributes = SEQUENCE { -- Sequence of Attributes -- "; |
475 |
|
|
476 |
4
|
if (e.hasMoreElements()){ |
477 |
4
|
result = result+"\n "+ident; |
478 |
8
|
for(; e.hasMoreElements();){ |
479 |
4
|
result = result + " "+((Attribute)e.nextElement()).toString(ident+" ")+(e.hasMoreElements()?",":"")+"\n "+ident; |
480 |
|
} |
481 |
|
} |
482 |
|
|
483 |
4
|
return result+"},\n "+ident+ |
484 |
4
|
"issuerUniqueID = "+((issuerUniqueID!=null)?issuerUniqueID.toString():"[OPTIONAL; omitted]")+",\n "+ident+ |
485 |
4
|
"extensions = "+((extensions!=null)?extensions.toString(ident+" "):"[OPTIONAL; omitted]")+"\n"+ident+"}"; |
486 |
|
} |
487 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
488 |
0
|
public Object clone(){... |
489 |
0
|
try{ |
490 |
0
|
return new AttributeCertificateInfo(this); |
491 |
|
}catch (CodingException ex){ |
492 |
0
|
ex.printStackTrace(); |
493 |
0
|
return null; |
494 |
|
} |
495 |
|
} |
496 |
|
|
497 |
|
|
498 |
|
|
499 |
|
|
500 |
|
|
501 |
|
|
502 |
|
@throws |
503 |
|
|
504 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
505 |
20
|
public byte[] getEncoded() throws CodingException {... |
506 |
20
|
return iaik.asn1.DerCoder.encode(toASN1Object()); |
507 |
|
} |
508 |
|
} |
509 |
|
|