| 1 |
|
package com.atlassian.security.auth.trustedapps; |
| 2 |
|
|
| 3 |
|
import java.io.FileNotFoundException; |
| 4 |
|
import java.io.IOException; |
| 5 |
|
import java.io.InputStream; |
| 6 |
|
import java.io.InputStreamReader; |
| 7 |
|
import java.net.MalformedURLException; |
| 8 |
|
import java.net.URL; |
| 9 |
|
import java.net.URLConnection; |
| 10 |
|
|
| 11 |
|
|
| 12 |
|
@link |
| 13 |
|
|
|
|
|
| 94.1% |
Uncovered Elements: 1 (17) |
Complexity: 5 |
Complexity Density: 0.33 |
|
| 14 |
|
public class URLApplicationRetriever implements ApplicationRetriever |
| 15 |
|
{ |
| 16 |
|
private final String baseUrl; |
| 17 |
|
private final EncryptionProvider encryptionProvider; |
| 18 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 19 |
4
|
public URLApplicationRetriever(String baseUrl, EncryptionProvider encryptionProvider)... |
| 20 |
|
{ |
| 21 |
4
|
Null.not("baseUrl", baseUrl); |
| 22 |
4
|
Null.not("encryptionProvider", encryptionProvider); |
| 23 |
|
|
| 24 |
4
|
this.baseUrl = baseUrl; |
| 25 |
4
|
this.encryptionProvider = encryptionProvider; |
| 26 |
|
} |
| 27 |
|
|
|
|
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 4 |
Complexity Density: 0.36 |
|
| 28 |
4
|
public Application getApplication() throws RetrievalException... |
| 29 |
|
{ |
| 30 |
4
|
final String certUrl = baseUrl + TrustedApplicationUtils.Constant.CERTIFICATE_URL_PATH; |
| 31 |
4
|
try |
| 32 |
|
{ |
| 33 |
4
|
final URLConnection con = new URL(certUrl).openConnection(); |
| 34 |
3
|
con.connect(); |
| 35 |
2
|
final InputStream in = con.getInputStream(); |
| 36 |
2
|
final InputStreamReader reader = new InputStreamReader(in); |
| 37 |
2
|
final ReaderApplicationRetriever retriever = new ReaderApplicationRetriever(reader, encryptionProvider); |
| 38 |
2
|
return retriever.getApplication(); |
| 39 |
|
} |
| 40 |
|
catch (FileNotFoundException e) |
| 41 |
|
{ |
| 42 |
1
|
throw new ApplicationNotFoundException(e); |
| 43 |
|
} |
| 44 |
|
catch (MalformedURLException e) |
| 45 |
|
{ |
| 46 |
1
|
throw new RemoteSystemNotFoundException(e); |
| 47 |
|
} |
| 48 |
|
catch (IOException e) |
| 49 |
|
{ |
| 50 |
0
|
throw new RemoteSystemNotFoundException(e); |
| 51 |
|
} |
| 52 |
|
} |
| 53 |
|
} |