1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.crypto.internal.encoder; |
21 |
|
|
22 |
|
import java.io.ByteArrayOutputStream; |
23 |
|
import java.io.FilterInputStream; |
24 |
|
import java.io.FilterOutputStream; |
25 |
|
import java.io.IOException; |
26 |
|
import java.io.InputStream; |
27 |
|
import java.io.OutputStream; |
28 |
|
|
29 |
|
import org.xwiki.crypto.BinaryStringEncoder; |
30 |
|
import org.xwiki.crypto.internal.LineWrapperOutputStream; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (27) |
Complexity: 8 |
Complexity Density: 0.42 |
|
38 |
|
public abstract class AbstractBinaryStringEncoder implements BinaryStringEncoder |
39 |
|
{ |
40 |
|
|
41 |
|
private static final String CHARSET = "UTF-8"; |
42 |
|
|
43 |
|
abstract InternalBinaryStringEncoder getEncoder(); |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
45 |
3 |
@Override... |
46 |
|
public String encode(byte[] input) throws IOException |
47 |
|
{ |
48 |
3 |
return encode(input, 0, input.length); |
49 |
|
} |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
51 |
3 |
@Override... |
52 |
|
public String encode(byte[] input, int wrapAt) throws IOException |
53 |
|
{ |
54 |
3 |
return encode(input, 0, input.length, wrapAt); |
55 |
|
} |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
57 |
6 |
@Override... |
58 |
|
public String encode(byte[] input, int off, int len) throws IOException |
59 |
|
{ |
60 |
6 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
61 |
6 |
getEncoder().encode(input, off, len, baos); |
62 |
6 |
baos.close(); |
63 |
6 |
return baos.toString(CHARSET); |
64 |
|
} |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
66 |
6 |
@Override... |
67 |
|
public String encode(byte[] input, int off, int len, int wrapAt) throws IOException |
68 |
|
{ |
69 |
6 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
70 |
6 |
LineWrapperOutputStream lwos = new LineWrapperOutputStream(baos, wrapAt); |
71 |
6 |
getEncoder().encode(input, off, len, lwos); |
72 |
6 |
lwos.close(); |
73 |
6 |
return baos.toString(CHARSET); |
74 |
|
} |
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
76 |
100 |
@Override... |
77 |
|
public byte[] decode(String input) throws IOException |
78 |
|
{ |
79 |
100 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
80 |
100 |
byte[] inBytes = input.getBytes(); |
81 |
100 |
getEncoder().decode(inBytes, 0, inBytes.length, baos); |
82 |
100 |
baos.close(); |
83 |
100 |
return baos.toByteArray(); |
84 |
|
} |
85 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
86 |
12 |
@Override... |
87 |
|
public FilterInputStream getDecoderInputStream(InputStream is) |
88 |
|
{ |
89 |
12 |
return new BcBinaryStringEncoderInputStream(is, getEncoder()); |
90 |
|
} |
91 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
92 |
3 |
@Override... |
93 |
|
public FilterOutputStream getEncoderOutputStream(OutputStream os) |
94 |
|
{ |
95 |
3 |
return new BcBinaryStringEncoderOutputStream(os, getEncoder()); |
96 |
|
} |
97 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
3 |
@Override... |
99 |
|
public FilterOutputStream getEncoderOutputStream(OutputStream os, int wrapAt) |
100 |
|
{ |
101 |
3 |
return new BcBinaryStringEncoderOutputStream(new LineWrapperOutputStream(os, wrapAt), getEncoder()); |
102 |
|
} |
103 |
|
} |