|
7 | 7 | abstract class SignUtils { |
8 | 8 |
|
9 | 9 | /** |
10 | | - * Decodes a given String from it's Base64 string representation into a UTF-8 String. |
| 10 | + * Encodes the given bytes into a UTF-8 String representation. |
11 | 11 | * |
12 | | - * @param source the source of the decode process. |
13 | | - * @return a UTF-8 String representing the Base64 decoded source. |
| 12 | + * @param source the source of the . |
| 13 | + * @return a UTF-8 String representing the source bytes. |
14 | 14 | * @throws NullPointerException if the UTF-8 Charset isn't initialized. |
15 | 15 | */ |
16 | | - static String base64Decode(String source) throws NullPointerException { |
17 | | - return StringUtils.newStringUtf8(Base64.decodeBase64(source)); |
| 16 | + static String toUTF8String(byte[] source) throws NullPointerException { |
| 17 | + return StringUtils.newStringUtf8(source); |
18 | 18 | } |
19 | 19 |
|
20 | 20 | /** |
21 | | - * Encodes a given String into it's Base64 string representation. |
| 21 | + * Decodes a given String from it's Base64 String representation into an array of bytes. |
22 | 22 | * |
23 | | - * @param source the source of the decode process. |
24 | | - * @return a UTF-8 String encoded into it's Base64 representation. |
25 | | - * @throws NullPointerException if the UTF-8 Charset isn't initialized. |
26 | | - * @throws IllegalArgumentException if the source string is too long. |
| 23 | + * @param source the source bytes to decode. |
| 24 | + * @return an array of bytes representing the Base64 decoded source. |
27 | 25 | */ |
28 | | - static String base64Encode(String source) throws NullPointerException, IllegalArgumentException { |
29 | | - return StringUtils.newStringUtf8(Base64.encodeBase64(source.getBytes(), false, true)); |
| 26 | + static byte[] base64Decode(String source) { |
| 27 | + return Base64.decodeBase64(source); |
30 | 28 | } |
31 | 29 |
|
| 30 | + /** |
| 31 | + * Encodes a given String into it's Base64 String representation. |
| 32 | + * |
| 33 | + * @param source the source bytes to encode. |
| 34 | + * @return a String containing Base64 characters. |
| 35 | + */ |
| 36 | + static String base64Encode(byte[] source) { |
| 37 | + return Base64.encodeBase64URLSafeString(source); |
| 38 | + } |
| 39 | + |
| 40 | + |
32 | 41 | /** |
33 | 42 | * Splits the given token on the "." chars into a String array with 3 parts. |
34 | 43 | * |
|
0 commit comments