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