1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.crypto.pkix.params.x509certificate.extension; |
21 |
|
|
22 |
|
import java.net.MalformedURLException; |
23 |
|
import java.net.URI; |
24 |
|
import java.net.URISyntaxException; |
25 |
|
import java.net.URL; |
26 |
|
|
27 |
|
import org.bouncycastle.asn1.DERIA5String; |
28 |
|
import org.bouncycastle.asn1.x509.GeneralName; |
29 |
|
import org.xwiki.crypto.pkix.internal.extension.BcGeneralName; |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
@version |
35 |
|
@since |
36 |
|
|
|
|
| 81.6% |
Uncovered Elements: 7 (38) |
Complexity: 12 |
Complexity Density: 0.41 |
|
37 |
|
public class X509URI implements X509StringGeneralName, BcGeneralName |
38 |
|
{ |
39 |
|
private final String str; |
40 |
|
|
41 |
|
private final URI uri; |
42 |
|
|
43 |
|
private final URL url; |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@param |
49 |
|
|
|
|
| 68.8% |
Uncovered Elements: 5 (16) |
Complexity: 4 |
Complexity Density: 0.25 |
|
50 |
3 |
public X509URI(String str)... |
51 |
|
{ |
52 |
3 |
String newStr = null; |
53 |
3 |
URI newUri = null; |
54 |
3 |
URL newUrl = null; |
55 |
|
|
56 |
3 |
try { |
57 |
3 |
newUri = new URI(str); |
58 |
3 |
newUrl = newUri.toURL(); |
59 |
3 |
newStr = newUrl.toString(); |
60 |
3 |
newUri = newUrl.toURI(); |
61 |
|
} catch (URISyntaxException e) { |
62 |
0 |
try { |
63 |
0 |
newUrl = new URL(str); |
64 |
0 |
newStr = newUrl.toString(); |
65 |
|
} catch (MalformedURLException e1) { |
66 |
0 |
newStr = str; |
67 |
|
} |
68 |
|
} catch (MalformedURLException e) { |
69 |
0 |
newStr = newUri.toASCIIString(); |
70 |
|
} |
71 |
|
|
72 |
3 |
this.str = newStr; |
73 |
3 |
this.uri = newUri; |
74 |
3 |
this.url = newUrl; |
75 |
|
} |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
@param |
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
82 |
1 |
public X509URI(URL url)... |
83 |
|
{ |
84 |
1 |
this.str = url.toString(); |
85 |
1 |
this.url = url; |
86 |
|
|
87 |
1 |
URI newUri = null; |
88 |
1 |
try { |
89 |
1 |
newUri = url.toURI(); |
90 |
|
} catch (URISyntaxException e) { |
91 |
|
|
92 |
|
} |
93 |
|
|
94 |
1 |
this.uri = newUri; |
95 |
|
} |
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
@param |
101 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
102 |
2 |
public X509URI(GeneralName name)... |
103 |
|
{ |
104 |
2 |
this(DERIA5String.getInstance(name.getName()).getString()); |
105 |
|
|
106 |
2 |
if (name.getTagNo() != GeneralName.uniformResourceIdentifier) { |
107 |
0 |
throw new IllegalArgumentException("Incompatible general name: " + name.getTagNo()); |
108 |
|
} |
109 |
|
} |
110 |
|
|
111 |
|
|
112 |
|
@return |
113 |
|
|
114 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
115 |
2 |
public URL getURL()... |
116 |
|
{ |
117 |
2 |
return this.url; |
118 |
|
} |
119 |
|
|
120 |
|
|
121 |
|
@return |
122 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
123 |
2 |
public URI getURI()... |
124 |
|
{ |
125 |
2 |
return this.uri; |
126 |
|
} |
127 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
128 |
2 |
@Override... |
129 |
|
public String getName() |
130 |
|
{ |
131 |
2 |
return this.str; |
132 |
|
} |
133 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
134 |
2 |
@Override... |
135 |
|
public GeneralName getGeneralName() |
136 |
|
{ |
137 |
2 |
return new GeneralName(GeneralName.uniformResourceIdentifier, this.str); |
138 |
|
} |
139 |
|
} |