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 |
|
package issrg.pba.rbac; |
47 |
|
|
48 |
|
import issrg.utils.repository.*; |
49 |
|
import issrg.security.SecurityException; |
50 |
|
import issrg.saml.SAMLSecurity; |
51 |
|
|
52 |
|
import java.net.*; |
53 |
|
|
54 |
|
import org.apache.log4j.*; |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
@author |
60 |
|
@version |
61 |
|
|
|
|
| 12.8% |
Uncovered Elements: 34 (39) |
Complexity: 9 |
Complexity Density: 0.39 |
|
62 |
|
public class WebDAVURLHandler extends URLHandler { |
63 |
|
|
64 |
|
private static Logger logger = Logger.getLogger(WebDAVURLHandler.class.getName()); |
65 |
|
private String protocol = null; |
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
67 |
2
|
public WebDAVURLHandler(int defaultPort, String protocolIn) {... |
68 |
2
|
super(protocolIn.toLowerCase(), defaultPort); |
69 |
2
|
this.protocol = protocolIn.toLowerCase(); |
70 |
|
} |
71 |
|
|
|
|
| 0% |
Uncovered Elements: 33 (33) |
Complexity: 9 |
Complexity Density: 0.36 |
|
72 |
0
|
public issrg.utils.repository.AttributeRepository getRepository(String url) throws BadURLException {... |
73 |
0
|
if (getProtocolName(url).compareToIgnoreCase(HTTPS_PROTOCOL) == 0) { |
74 |
0
|
logger.debug("a SSL connection is required"); |
75 |
0
|
try { |
76 |
0
|
SAMLSecurity security = new SAMLSecurity(); |
77 |
0
|
security.login(3); |
78 |
0
|
URL up = new URL(url); |
79 |
0
|
String host = up.getHost(); |
80 |
0
|
int port = up.getPort(); |
81 |
0
|
if (port!=-1) defaultPort = port; |
82 |
0
|
return new WebDAVRepository(host, defaultPort, security); |
83 |
|
} catch (MalformedURLException me) { |
84 |
0
|
throw new BadURLException("Wrong URL syntax: "+url+" is encountered"); |
85 |
|
} catch (SecurityException se) { |
86 |
0
|
throw new BadURLException("security object error: "+se); |
87 |
|
} catch (Exception e) { |
88 |
0
|
throw new BadURLException("login error: "+e); |
89 |
|
} |
90 |
|
|
91 |
0
|
} else if (getProtocolName(url).compareToIgnoreCase(HTTP_PROTOCOL) == 0) { |
92 |
0
|
logger.debug("non-SSL connection is required"); |
93 |
0
|
try { |
94 |
0
|
URL up = new URL(url); |
95 |
0
|
String host = up.getHost(); |
96 |
0
|
int port = up.getPort(); |
97 |
0
|
if (port!=-1) defaultPort = port; |
98 |
0
|
return new WebDAVRepository(host, defaultPort); |
99 |
|
} catch (MalformedURLException me) { |
100 |
0
|
throw new BadURLException("Wrong URL syntax: "+url+" is encountered"); |
101 |
|
} |
102 |
|
} else { |
103 |
0
|
throw new BadURLException("Wrong URL Handler: "+url); |
104 |
|
} |
105 |
|
} |
106 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
107 |
2
|
public String getProtocol(){... |
108 |
2
|
return this.protocol; |
109 |
|
} |
110 |
|
|
111 |
|
} |