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 |
|
@author |
56 |
|
|
57 |
|
|
58 |
|
package issrg.ac.extensions; |
59 |
|
|
60 |
|
import iaik.asn1.*; |
61 |
|
import iaik.asn1.structures.*; |
62 |
|
import issrg.pba.PbaException; |
63 |
|
import issrg.utils.WebDAV_DIT; |
64 |
|
|
65 |
|
import java.math.BigInteger; |
66 |
|
import java.util.*; |
67 |
|
|
|
|
| 2.7% |
Uncovered Elements: 72 (74) |
Complexity: 13 |
Complexity Density: 0.51 |
|
68 |
|
public class WebdavRevocation extends issrg.ac.Extension { |
69 |
|
|
70 |
|
public static final String WEBDAV_REVOCATION_METHOD_OID = "1.2.826.0.1.3344810.10.3"; |
71 |
|
|
72 |
|
private String rev_loc; |
73 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
74 |
0
|
public WebdavRevocation(ASN1Object ao)throws CodingException{... |
75 |
0
|
super(ao); |
76 |
|
} |
77 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
78 |
0
|
public WebdavRevocation(String location,String subjectDN, BigInteger serial) {... |
79 |
0
|
super(WEBDAV_REVOCATION_METHOD_OID,false); |
80 |
0
|
rev_loc= getProperLocation(location,subjectDN, serial); |
81 |
|
} |
82 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
83 |
0
|
public String getExtensionOID() {... |
84 |
0
|
return WEBDAV_REVOCATION_METHOD_OID; |
85 |
|
} |
86 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
87 |
0
|
public String getLocation(){... |
88 |
0
|
return rev_loc; |
89 |
|
} |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
91 |
0
|
public void setLocation(String location){... |
92 |
0
|
rev_loc=location; |
93 |
|
} |
94 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
95 |
0
|
public ASN1Object encodeValue() throws CodingException{... |
96 |
|
|
97 |
0
|
SEQUENCE extnV = new SEQUENCE(); |
98 |
|
|
99 |
0
|
if (rev_loc!=null){ |
100 |
0
|
GeneralName name = new GeneralName(GeneralName.uniformResourceIdentifier, rev_loc); |
101 |
|
|
102 |
0
|
SEQUENCE revocation = new SEQUENCE(); |
103 |
0
|
revocation.addComponent(new ObjectID(WEBDAV_REVOCATION_METHOD_OID), 0); |
104 |
0
|
revocation.addComponent(name.toASN1Object(), 1); |
105 |
0
|
extnV.addComponent(revocation); |
106 |
|
} |
107 |
|
|
108 |
|
|
109 |
0
|
return extnV; |
110 |
|
} |
111 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
112 |
0
|
public void decode(ASN1Object ao)throws CodingException{... |
113 |
0
|
super.decode(ao); |
114 |
|
} |
115 |
|
|
|
|
| 0% |
Uncovered Elements: 31 (31) |
Complexity: 9 |
Complexity Density: 0.53 |
|
116 |
0
|
public void decodeValue(ASN1Object ao )throws CodingException{... |
117 |
|
|
118 |
0
|
int j = ao.countComponents(); |
119 |
0
|
for (int i=0; i<j; i++) { |
120 |
0
|
ASN1Object accessDescription = ao.getComponentAt(i); |
121 |
0
|
try{ |
122 |
0
|
if ((accessDescription instanceof SEQUENCE)) { |
123 |
0
|
ASN1Object oid = (ASN1Object) accessDescription.getComponentAt(0); |
124 |
0
|
if ((oid instanceof ObjectID)) { |
125 |
|
|
126 |
0
|
String id = (String) ((ObjectID) oid).getValue(); |
127 |
0
|
if (id.equals(WEBDAV_REVOCATION_METHOD_OID)) { |
128 |
0
|
ASN1Object generalName = (ASN1Object) accessDescription.getComponentAt(1); |
129 |
0
|
if ((generalName instanceof CON_SPEC)) { |
130 |
0
|
GeneralName gn = new GeneralName(generalName); |
131 |
0
|
if (gn.getType()!=GeneralName.uniformResourceIdentifier){ |
132 |
0
|
continue; |
133 |
|
} |
134 |
0
|
setLocation((String)gn.getName()); |
135 |
|
} |
136 |
|
|
137 |
|
|
138 |
|
} |
139 |
|
} |
140 |
|
} |
141 |
|
}catch(CodingException ce){ |
142 |
0
|
if(isCritical()!=false){ |
143 |
0
|
throw new CodingException("Not possible to decode the ASN1Object values"); |
144 |
|
} |
145 |
|
} |
146 |
|
} |
147 |
|
|
148 |
|
} |
149 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
150 |
19
|
public static void registerMe() {... |
151 |
19
|
issrg.ac.Extensions.registerExtension(WEBDAV_REVOCATION_METHOD_OID, WebdavRevocation.class); |
152 |
|
} |
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
153 |
0
|
public String extensionValueToString(String indent){... |
154 |
0
|
String result=""; |
155 |
0
|
result =result.concat(indent+"Extension ID: "+extnID+"\n"+indent); |
156 |
0
|
result =result.concat(indent+"Location: "+getLocation()+"\n"+indent); |
157 |
0
|
return result; |
158 |
|
} |
159 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0.5 |
|
160 |
0
|
private String getProperLocation(String loc, String holderDN, BigInteger serial){... |
161 |
0
|
String holderURL; |
162 |
0
|
try{ |
163 |
0
|
holderURL= issrg.utils.WebdavUtil.convertDN2URI(holderDN); |
164 |
|
}catch(PbaException pba){ |
165 |
0
|
return ""; |
166 |
|
} |
167 |
0
|
if(loc.endsWith("/") && holderURL.startsWith("/")){ |
168 |
0
|
holderURL = holderURL.substring(1); |
169 |
|
} |
170 |
0
|
String location = loc+holderURL+"/cn=CRLs/"+"serialNumber="+serial+"WebDAV_DIT.crl"; |
171 |
0
|
return location; |
172 |
|
} |
173 |
|
|
174 |
|
} |