Clover Coverage Report - Atlassian Trusted Apps(Aggregated)
Coverage timestamp: Tue Jun 9 2009 19:34:44 CDT
6   61   6   1.5
0   41   1   2
4     1.5  
2    
 
 
  Transcoder       Line # 10 0 0 - -1.0
  Transcoder.Base64Transcoder       Line # 21 6 6 100% 1.0
 
  (25)
 
1    package com.atlassian.security.auth.trustedapps;
2   
3    import org.bouncycastle.util.encoders.Base64;
4   
5    import java.io.UnsupportedEncodingException;
6   
7    /**
8    * Encode/decode byte[] to Strings.
9    */
 
10    interface Transcoder
11    {
12    String encode(byte[] data);
13   
14    byte[] decode(String encoded);
15   
16    byte[] getBytes(String data);
17   
18    /**
19    * Standard implemetation.
20    */
 
21    static class Base64Transcoder implements Transcoder
22    {
 
23  39 toggle public String encode(byte[] data)
24    {
25  39 try
26    {
27  39 return new String(Base64.encode(data), TrustedApplicationUtils.Constant.CHARSET_NAME);
28    }
29    // /CLOVER:OFF
30    catch (UnsupportedEncodingException e)
31    {
32    throw new RuntimeException(e);
33    }
34    // /CLOVER:ON
35    }
36   
 
37  60 toggle public byte[] decode(String encoded)
38    {
39  60 return decode(getBytes(encoded));
40    }
41   
 
42  60 toggle byte[] decode(byte[] encoded)
43    {
44  60 return Base64.decode(encoded);
45    }
46   
 
47  86 toggle public byte[] getBytes(String data)
48    {
49  86 try
50    {
51  86 return data.getBytes(TrustedApplicationUtils.Constant.CHARSET_NAME);
52    }
53    // /CLOVER:OFF
54    catch (UnsupportedEncodingException e)
55    {
56    throw new AssertionError(e);
57    }
58    // /CLOVER:ON
59    }
60    }
61    }