|
|
@ -24,16 +24,16 @@ package org.springframework.boot.test;
|
|
|
|
final class Base64 {
|
|
|
|
final class Base64 {
|
|
|
|
|
|
|
|
|
|
|
|
/** No options specified. Value is zero. */
|
|
|
|
/** No options specified. Value is zero. */
|
|
|
|
public final static int NO_OPTIONS = 0;
|
|
|
|
public static final int NO_OPTIONS = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/** Specify encoding in first bit. Value is one. */
|
|
|
|
/** Specify encoding in first bit. Value is one. */
|
|
|
|
public final static int ENCODE = 1;
|
|
|
|
public static final int ENCODE = 1;
|
|
|
|
|
|
|
|
|
|
|
|
/** Specify decoding in first bit. Value is zero. */
|
|
|
|
/** Specify decoding in first bit. Value is zero. */
|
|
|
|
public final static int DECODE = 0;
|
|
|
|
public static final int DECODE = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/** Do break lines when encoding. Value is 8. */
|
|
|
|
/** Do break lines when encoding. Value is 8. */
|
|
|
|
public final static int DO_BREAK_LINES = 8;
|
|
|
|
public static final int DO_BREAK_LINES = 8;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Encode using Base64-like encoding that is URL- and Filename-safe as described in
|
|
|
|
* Encode using Base64-like encoding that is URL- and Filename-safe as described in
|
|
|
@ -44,32 +44,32 @@ final class Base64 {
|
|
|
|
* Base64 without also specifying that is was encoded using the URL- and Filename-safe
|
|
|
|
* Base64 without also specifying that is was encoded using the URL- and Filename-safe
|
|
|
|
* dialect.
|
|
|
|
* dialect.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public final static int URL_SAFE = 16;
|
|
|
|
public static final int URL_SAFE = 16;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Encode using the special "ordered" dialect of Base64 described here: <a
|
|
|
|
* Encode using the special "ordered" dialect of Base64 described here: <a
|
|
|
|
* href="http://www.faqs.org/qa/rfcc-1940.html"
|
|
|
|
* href="http://www.faqs.org/qa/rfcc-1940.html"
|
|
|
|
* >http://www.faqs.org/qa/rfcc-1940.html</a>.
|
|
|
|
* >http://www.faqs.org/qa/rfcc-1940.html</a>.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public final static int ORDERED = 32;
|
|
|
|
public static final int ORDERED = 32;
|
|
|
|
|
|
|
|
|
|
|
|
/** Maximum line length (76) of Base64 output. */
|
|
|
|
/** Maximum line length (76) of Base64 output. */
|
|
|
|
private final static int MAX_LINE_LENGTH = 76;
|
|
|
|
private static final int MAX_LINE_LENGTH = 76;
|
|
|
|
|
|
|
|
|
|
|
|
/** The equals sign (=) as a byte. */
|
|
|
|
/** The equals sign (=) as a byte. */
|
|
|
|
private final static byte EQUALS_SIGN = (byte) '=';
|
|
|
|
private static final byte EQUALS_SIGN = (byte) '=';
|
|
|
|
|
|
|
|
|
|
|
|
/** The new line character (\n) as a byte. */
|
|
|
|
/** The new line character (\n) as a byte. */
|
|
|
|
private final static byte NEW_LINE = (byte) '\n';
|
|
|
|
private static final byte NEW_LINE = (byte) '\n';
|
|
|
|
|
|
|
|
|
|
|
|
private final static byte WHITE_SPACE_ENC = -5; // Indicates white space in encoding
|
|
|
|
private static final byte WHITE_SPACE_ENC = -5; // Indicates white space in encoding
|
|
|
|
private final static byte EQUALS_SIGN_ENC = -1; // Indicates equals sign in encoding
|
|
|
|
private static final byte EQUALS_SIGN_ENC = -1; // Indicates equals sign in encoding
|
|
|
|
|
|
|
|
|
|
|
|
/* ******** S T A N D A R D B A S E 6 4 A L P H A B E T ******** */
|
|
|
|
/* ******** S T A N D A R D B A S E 6 4 A L P H A B E T ******** */
|
|
|
|
|
|
|
|
|
|
|
|
/** The 64 valid Base64 values. */
|
|
|
|
/** The 64 valid Base64 values. */
|
|
|
|
/* Host platform me be something funny like EBCDIC, so we hardcode these values. */
|
|
|
|
/* Host platform me be something funny like EBCDIC, so we hardcode these values. */
|
|
|
|
private final static byte[] _STANDARD_ALPHABET = { (byte) 'A', (byte) 'B',
|
|
|
|
private static final byte[] _STANDARD_ALPHABET = { (byte) 'A', (byte) 'B',
|
|
|
|
(byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F', (byte) 'G', (byte) 'H',
|
|
|
|
(byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F', (byte) 'G', (byte) 'H',
|
|
|
|
(byte) 'I', (byte) 'J', (byte) 'K', (byte) 'L', (byte) 'M', (byte) 'N',
|
|
|
|
(byte) 'I', (byte) 'J', (byte) 'K', (byte) 'L', (byte) 'M', (byte) 'N',
|
|
|
|
(byte) 'O', (byte) 'P', (byte) 'Q', (byte) 'R', (byte) 'S', (byte) 'T',
|
|
|
|
(byte) 'O', (byte) 'P', (byte) 'Q', (byte) 'R', (byte) 'S', (byte) 'T',
|
|
|
@ -86,7 +86,7 @@ final class Base64 {
|
|
|
|
* Translates a Base64 value to either its 6-bit reconstruction value or a negative
|
|
|
|
* Translates a Base64 value to either its 6-bit reconstruction value or a negative
|
|
|
|
* number indicating some other meaning.
|
|
|
|
* number indicating some other meaning.
|
|
|
|
**/
|
|
|
|
**/
|
|
|
|
private final static byte[] _STANDARD_DECODABET = { -9, -9, -9, -9, -9, -9, -9, -9,
|
|
|
|
private static final byte[] _STANDARD_DECODABET = { -9, -9, -9, -9, -9, -9, -9, -9,
|
|
|
|
-9, // Decimal 0 - 8
|
|
|
|
-9, // Decimal 0 - 8
|
|
|
|
-5, -5, // Whitespace: Tab and Linefeed
|
|
|
|
-5, -5, // Whitespace: Tab and Linefeed
|
|
|
|
-9, -9, // Decimal 11 - 12
|
|
|
|
-9, -9, // Decimal 11 - 12
|
|
|
@ -129,7 +129,7 @@ final class Base64 {
|
|
|
|
* Notice that the last two bytes become "hyphen" and "underscore" instead of "plus"
|
|
|
|
* Notice that the last two bytes become "hyphen" and "underscore" instead of "plus"
|
|
|
|
* and "slash."
|
|
|
|
* and "slash."
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private final static byte[] _URL_SAFE_ALPHABET = { (byte) 'A', (byte) 'B',
|
|
|
|
private static final byte[] _URL_SAFE_ALPHABET = { (byte) 'A', (byte) 'B',
|
|
|
|
(byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F', (byte) 'G', (byte) 'H',
|
|
|
|
(byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F', (byte) 'G', (byte) 'H',
|
|
|
|
(byte) 'I', (byte) 'J', (byte) 'K', (byte) 'L', (byte) 'M', (byte) 'N',
|
|
|
|
(byte) 'I', (byte) 'J', (byte) 'K', (byte) 'L', (byte) 'M', (byte) 'N',
|
|
|
|
(byte) 'O', (byte) 'P', (byte) 'Q', (byte) 'R', (byte) 'S', (byte) 'T',
|
|
|
|
(byte) 'O', (byte) 'P', (byte) 'Q', (byte) 'R', (byte) 'S', (byte) 'T',
|
|
|
@ -145,7 +145,7 @@ final class Base64 {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Used in decoding URL- and Filename-safe dialects of Base64.
|
|
|
|
* Used in decoding URL- and Filename-safe dialects of Base64.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private final static byte[] _URL_SAFE_DECODABET = { -9, -9, -9, -9, -9, -9, -9, -9,
|
|
|
|
private static final byte[] _URL_SAFE_DECODABET = { -9, -9, -9, -9, -9, -9, -9, -9,
|
|
|
|
-9, // Decimal 0 - 8
|
|
|
|
-9, // Decimal 0 - 8
|
|
|
|
-5, -5, // Whitespace: Tab and Linefeed
|
|
|
|
-5, -5, // Whitespace: Tab and Linefeed
|
|
|
|
-9, -9, // Decimal 11 - 12
|
|
|
|
-9, -9, // Decimal 11 - 12
|
|
|
@ -191,7 +191,7 @@ final class Base64 {
|
|
|
|
* href="http://www.faqs.org/qa/rfcc-1940.html">http://www.faqs.org/
|
|
|
|
* href="http://www.faqs.org/qa/rfcc-1940.html">http://www.faqs.org/
|
|
|
|
* qa/rfcc-1940.html</a>.
|
|
|
|
* qa/rfcc-1940.html</a>.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private final static byte[] _ORDERED_ALPHABET = { (byte) '-', (byte) '0', (byte) '1',
|
|
|
|
private static final byte[] _ORDERED_ALPHABET = { (byte) '-', (byte) '0', (byte) '1',
|
|
|
|
(byte) '2', (byte) '3', (byte) '4', (byte) '5', (byte) '6', (byte) '7',
|
|
|
|
(byte) '2', (byte) '3', (byte) '4', (byte) '5', (byte) '6', (byte) '7',
|
|
|
|
(byte) '8', (byte) '9', (byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D',
|
|
|
|
(byte) '8', (byte) '9', (byte) 'A', (byte) 'B', (byte) 'C', (byte) 'D',
|
|
|
|
(byte) 'E', (byte) 'F', (byte) 'G', (byte) 'H', (byte) 'I', (byte) 'J',
|
|
|
|
(byte) 'E', (byte) 'F', (byte) 'G', (byte) 'H', (byte) 'I', (byte) 'J',
|
|
|
@ -207,7 +207,7 @@ final class Base64 {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Used in decoding the "ordered" dialect of Base64.
|
|
|
|
* Used in decoding the "ordered" dialect of Base64.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private final static byte[] _ORDERED_DECODABET = { -9, -9, -9, -9, -9, -9, -9, -9,
|
|
|
|
private static final byte[] _ORDERED_DECODABET = { -9, -9, -9, -9, -9, -9, -9, -9,
|
|
|
|
-9, // Decimal 0 - 8
|
|
|
|
-9, // Decimal 0 - 8
|
|
|
|
-5, -5, // Whitespace: Tab and Linefeed
|
|
|
|
-5, -5, // Whitespace: Tab and Linefeed
|
|
|
|
-9, -9, // Decimal 11 - 12
|
|
|
|
-9, -9, // Decimal 11 - 12
|
|
|
|