Clover Coverage Report - Atlassian Trusted Apps(Aggregated)
Coverage timestamp: Tue Jun 9 2009 19:34:44 CDT
15   53   5   7.5
0   44   0.33   2
2     2.5  
1    
 
 
  URLApplicationRetriever       Line # 14 15 5 94.1% 0.9411765
 
  (4)
 
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    * Take a URL and produce an {@link Application}.
13    */
 
14    public class URLApplicationRetriever implements ApplicationRetriever
15    {
16    private final String baseUrl;
17    private final EncryptionProvider encryptionProvider;
18   
 
19  4 toggle 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   
 
28  4 toggle 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    }