Yet Another WebIOPi+
 All Classes Namespaces Files Functions Variables Macros Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Package Functions | Static Package Functions | Static Package Attributes | Private Attributes | Static Private Attributes | List of all members
org.apache.commons.codec.binary.Base64 Class Reference
Inheritance diagram for org.apache.commons.codec.binary.Base64:
org.apache.commons.codec.binary.BaseNCodec org.apache.commons.codec.BinaryEncoder org.apache.commons.codec.BinaryDecoder org.apache.commons.codec.Encoder org.apache.commons.codec.Decoder

Public Member Functions

 Base64 ()
 
 Base64 (final boolean urlSafe)
 
 Base64 (final int lineLength)
 
 Base64 (final int lineLength, final byte[] lineSeparator)
 
 Base64 (final int lineLength, final byte[] lineSeparator, final boolean urlSafe)
 
boolean isUrlSafe ()
 
- Public Member Functions inherited from org.apache.commons.codec.binary.BaseNCodec
Object encode (final Object obj) throws EncoderException
 
String encodeToString (final byte[] pArray)
 
String encodeAsString (final byte[] pArray)
 
Object decode (final Object obj) throws DecoderException
 
byte[] decode (final String pArray)
 
byte[] decode (final byte[] pArray)
 
byte[] encode (final byte[] pArray)
 
boolean isInAlphabet (final byte[] arrayOctet, final boolean allowWSPad)
 
boolean isInAlphabet (final String basen)
 
long getEncodedLength (final byte[] pArray)
 
- Public Member Functions inherited from org.apache.commons.codec.BinaryEncoder
byte[] encode (byte[] source) throws EncoderException
 
- Public Member Functions inherited from org.apache.commons.codec.Encoder
Object encode (Object source) throws EncoderException
 
- Public Member Functions inherited from org.apache.commons.codec.BinaryDecoder
byte[] decode (byte[] source) throws DecoderException
 
- Public Member Functions inherited from org.apache.commons.codec.Decoder
Object decode (Object source) throws DecoderException
 

Static Public Member Functions

static boolean isArrayByteBase64 (final byte[] arrayOctet)
 
static boolean isBase64 (final byte octet)
 
static boolean isBase64 (final String base64)
 
static boolean isBase64 (final byte[] arrayOctet)
 
static byte[] encodeBase64 (final byte[] binaryData)
 
static String encodeBase64String (final byte[] binaryData)
 
static byte[] encodeBase64URLSafe (final byte[] binaryData)
 
static String encodeBase64URLSafeString (final byte[] binaryData)
 
static byte[] encodeBase64Chunked (final byte[] binaryData)
 
static byte[] encodeBase64 (final byte[] binaryData, final boolean isChunked)
 
static byte[] encodeBase64 (final byte[] binaryData, final boolean isChunked, final boolean urlSafe)
 
static byte[] encodeBase64 (final byte[] binaryData, final boolean isChunked, final boolean urlSafe, final int maxResultSize)
 
static byte[] decodeBase64 (final String base64String)
 
static byte[] decodeBase64 (final byte[] base64Data)
 
static BigInteger decodeInteger (final byte[] pArray)
 
static byte[] encodeInteger (final BigInteger bigInt)
 

Protected Member Functions

boolean isInAlphabet (final byte octet)
 
- Protected Member Functions inherited from org.apache.commons.codec.binary.BaseNCodec
 BaseNCodec (final int unencodedBlockSize, final int encodedBlockSize, final int lineLength, final int chunkSeparatorLength)
 
int getDefaultBufferSize ()
 
byte[] ensureBufferSize (final int size, final Context context)
 
abstract boolean isInAlphabet (byte value)
 
boolean containsAlphabetOrPad (final byte[] arrayOctet)
 

Package Functions

void encode (final byte[] in, int inPos, final int inAvail, final Context context)
 
void decode (final byte[] in, int inPos, final int inAvail, final Context context)
 
- Package Functions inherited from org.apache.commons.codec.binary.BaseNCodec
boolean hasData (final Context context)
 
int available (final Context context)
 
int readResults (final byte[] b, final int bPos, final int bAvail, final Context context)
 
abstract void encode (byte[] pArray, int i, int length, Context context)
 
abstract void decode (byte[] pArray, int i, int length, Context context)
 

Static Package Functions

static byte[] toIntegerBytes (final BigInteger bigInt)
 

Static Package Attributes

static final byte[] CHUNK_SEPARATOR = {'\r', '\n'}
 
- Static Package Attributes inherited from org.apache.commons.codec.binary.BaseNCodec
static final int EOF = -1
 

Private Attributes

final byte[] encodeTable
 
final byte[] decodeTable = DECODE_TABLE
 
final byte[] lineSeparator
 
final int decodeSize
 
final int encodeSize
 

Static Private Attributes

static final int BITS_PER_ENCODED_BYTE = 6
 
static final int BYTES_PER_UNENCODED_BLOCK = 3
 
static final int BYTES_PER_ENCODED_BLOCK = 4
 
static final byte[] STANDARD_ENCODE_TABLE
 
static final byte[] URL_SAFE_ENCODE_TABLE
 
static final byte[] DECODE_TABLE
 
static final int MASK_6BITS = 0x3f
 

Additional Inherited Members

- Static Public Attributes inherited from org.apache.commons.codec.binary.BaseNCodec
static final int MIME_CHUNK_SIZE = 76
 
static final int PEM_CHUNK_SIZE = 64
 
- Static Protected Member Functions inherited from org.apache.commons.codec.binary.BaseNCodec
static boolean isWhiteSpace (final byte byteToCheck)
 
- Protected Attributes inherited from org.apache.commons.codec.binary.BaseNCodec
final byte PAD = PAD_DEFAULT
 
final int lineLength
 
- Static Protected Attributes inherited from org.apache.commons.codec.binary.BaseNCodec
static final int MASK_8BITS = 0xff
 
static final byte PAD_DEFAULT = '='
 

Detailed Description

Provides Base64 encoding and decoding as defined by RFC 2045.

This class implements section <cite>6.8. Base64 Content-Transfer-Encoding</cite> from RFC 2045 <cite>Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies</cite> by Freed and Borenstein.

The class can be parameterized in the following manner with various constructors:

Since this class operates directly on byte streams, and not character streams, it is hard-coded to only encode/decode character encodings which are compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252, UTF-8, etc).

This class is thread-safe.

See also
RFC 2045
Since
1.0
Version
$Id$

Definition at line 51 of file Base64.java.

Constructor & Destructor Documentation

org.apache.commons.codec.binary.Base64.Base64 ( )

Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode.

When encoding the line length is 0 (no chunking), and the encoding table is STANDARD_ENCODE_TABLE.

When decoding all variants are supported.

Definition at line 169 of file Base64.java.

Referenced by org.apache.commons.codec.binary.Base64.decodeBase64(), and org.apache.commons.codec.binary.Base64.encodeBase64().

org.apache.commons.codec.binary.Base64.Base64 ( final boolean  urlSafe)

Creates a Base64 codec used for decoding (all modes) and encoding in the given URL-safe mode.

When encoding the line length is 76, the line separator is CRLF, and the encoding table is STANDARD_ENCODE_TABLE.

When decoding all variants are supported.

Parameters
urlSafeif
true
, URL-safe encoding is used. In most cases this should be set to
false
.
Since
1.4

Definition at line 188 of file Base64.java.

References org.apache.commons.codec.binary.Base64.CHUNK_SEPARATOR, and org.apache.commons.codec.binary.BaseNCodec.MIME_CHUNK_SIZE.

org.apache.commons.codec.binary.Base64.Base64 ( final int  lineLength)

Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode.

When encoding the line length is given in the constructor, the line separator is CRLF, and the encoding table is STANDARD_ENCODE_TABLE.

Line lengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data.

When decoding all variants are supported.

Parameters
lineLengthEach line of encoded data will be at most of the given length (rounded down to nearest multiple of 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when decoding.
Since
1.4

Definition at line 211 of file Base64.java.

References org.apache.commons.codec.binary.Base64.CHUNK_SEPARATOR, and org.apache.commons.codec.binary.BaseNCodec.lineLength.

org.apache.commons.codec.binary.Base64.Base64 ( final int  lineLength,
final byte[]  lineSeparator 
)

Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode.

When encoding the line length and line separator are given in the constructor, and the encoding table is STANDARD_ENCODE_TABLE.

Line lengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data.

When decoding all variants are supported.

Parameters
lineLengthEach line of encoded data will be at most of the given length (rounded down to nearest multiple of 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when decoding.
lineSeparatorEach line of encoded data will end with this sequence of bytes.
Exceptions
IllegalArgumentExceptionThrown when the provided lineSeparator included some base64 characters.
Since
1.4

Definition at line 238 of file Base64.java.

References org.apache.commons.codec.binary.BaseNCodec.lineLength, and org.apache.commons.codec.binary.Base64.lineSeparator.

org.apache.commons.codec.binary.Base64.Base64 ( final int  lineLength,
final byte[]  lineSeparator,
final boolean  urlSafe 
)

Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode.

When encoding the line length and line separator are given in the constructor, and the encoding table is STANDARD_ENCODE_TABLE.

Line lengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data.

When decoding all variants are supported.

Parameters
lineLengthEach line of encoded data will be at most of the given length (rounded down to nearest multiple of 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when decoding.
lineSeparatorEach line of encoded data will end with this sequence of bytes.
urlSafeInstead of emitting '+' and '/' we emit '-' and '_' respectively. urlSafe is only applied to encode operations. Decoding seamlessly handles both modes. Note: no padding is added when using the URL-safe alphabet.
Exceptions
IllegalArgumentExceptionThe provided lineSeparator included some base64 characters. That's not going to work!
Since
1.4

Definition at line 269 of file Base64.java.

References org.apache.commons.codec.binary.Base64.BYTES_PER_ENCODED_BLOCK, org.apache.commons.codec.binary.BaseNCodec.containsAlphabetOrPad(), org.apache.commons.codec.binary.StringUtils.newStringUtf8(), and org.apache.commons.codec.binary.Base64.STANDARD_ENCODE_TABLE.

Member Function Documentation

void org.apache.commons.codec.binary.Base64.decode ( final byte[]  in,
int  inPos,
final int  inAvail,
final Context  context 
)
package

Decodes all of the provided data, starting at inPos, for inAvail bytes. Should be called at least twice: once with the data to decode, and once with inAvail set to "-1" to alert decoder that EOF has been reached. The "-1" call is not necessary when decoding, but it doesn't hurt, either.

Ignores all non-base64 characters. This is how chunked (e.g. 76 character) data is handled, since CR and LF are silently ignored, but has implications for other bytes, too. This method subscribes to the garbage-in, garbage-out philosophy: it will not check the provided data for validity.

Thanks to "commons" project in ws.apache.org for the bitwise operations, and general approach. http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/

Parameters
inbyte[] array of ascii data to base64 decode.
inPosPosition to start reading data from.
inAvailAmount of bytes available from input for encoding.
contextthe context to be used

Definition at line 425 of file Base64.java.

References org.apache.commons.codec.binary.Base64.BITS_PER_ENCODED_BYTE, org.apache.commons.codec.binary.BaseNCodec.ensureBufferSize(), org.apache.commons.codec.binary.BaseNCodec.Context.eof, org.apache.commons.codec.binary.BaseNCodec.Context.ibitWorkArea, org.apache.commons.codec.binary.BaseNCodec.MASK_8BITS, org.apache.commons.codec.binary.BaseNCodec.Context.modulus, org.apache.commons.codec.binary.BaseNCodec.PAD, org.apache.commons.codec.binary.BaseNCodec.Context.pos, and webiopi.utils.version.result.

static byte [] org.apache.commons.codec.binary.Base64.decodeBase64 ( final String  base64String)
static

Decodes a Base64 String into octets

Parameters
base64StringString containing Base64 data
Returns
Array containing decoded data.
Since
1.4

Definition at line 685 of file Base64.java.

References org.apache.commons.codec.binary.Base64.Base64().

Referenced by org.apache.commons.codec.binary.Base64.decodeInteger().

static byte [] org.apache.commons.codec.binary.Base64.decodeBase64 ( final byte[]  base64Data)
static

Decodes Base64 data into octets

Parameters
base64DataByte array containing Base64 data
Returns
Array containing decoded data.

Definition at line 696 of file Base64.java.

References org.apache.commons.codec.binary.Base64.Base64().

static BigInteger org.apache.commons.codec.binary.Base64.decodeInteger ( final byte[]  pArray)
static

Decodes a byte64-encoded integer according to crypto standards such as W3C's XML-Signature

Parameters
pArraya byte array containing base64 character data
Returns
A BigInteger
Since
1.4

Definition at line 711 of file Base64.java.

References org.apache.commons.codec.binary.Base64.decodeBase64().

void org.apache.commons.codec.binary.Base64.encode ( final byte[]  in,
int  inPos,
final int  inAvail,
final Context  context 
)
package

Encodes all of the provided data, starting at inPos, for inAvail bytes. Must be called at least twice: once with the data to encode, and once with inAvail set to "-1" to alert encoder that EOF has been reached, to flush last remaining bytes (if not multiple of 3).

Note: no padding is added when encoding using the URL-safe alphabet.

Thanks to "commons" project in ws.apache.org for the bitwise operations, and general approach. http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/

Parameters
inbyte[] array of binary data to base64 encode.
inPosPosition to start reading data from.
inAvailAmount of bytes available from input for encoding.
contextthe context to be used

Definition at line 328 of file Base64.java.

References org.apache.commons.codec.binary.Base64.BYTES_PER_ENCODED_BLOCK, org.apache.commons.codec.binary.BaseNCodec.Context.currentLinePos, org.apache.commons.codec.binary.BaseNCodec.ensureBufferSize(), org.apache.commons.codec.binary.BaseNCodec.Context.eof, org.apache.commons.codec.binary.BaseNCodec.Context.ibitWorkArea, org.apache.commons.codec.binary.BaseNCodec.lineLength, org.apache.commons.codec.binary.Base64.MASK_6BITS, org.apache.commons.codec.binary.BaseNCodec.Context.modulus, org.apache.commons.codec.binary.BaseNCodec.PAD, and org.apache.commons.codec.binary.BaseNCodec.Context.pos.

Referenced by org.apache.commons.codec.binary.Base64.encodeBase64().

static byte [] org.apache.commons.codec.binary.Base64.encodeBase64 ( final byte[]  binaryData)
static

Encodes binary data using the base64 algorithm but does not chunk the output.

Parameters
binaryDatabinary data to encode
Returns
byte[] containing Base64 characters in their UTF-8 representation.

Definition at line 550 of file Base64.java.

Referenced by org.apache.commons.codec.binary.Base64.encodeBase64(), org.apache.commons.codec.binary.Base64.encodeBase64Chunked(), org.apache.commons.codec.binary.Base64.encodeBase64String(), org.apache.commons.codec.binary.Base64.encodeBase64URLSafe(), org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString(), and org.apache.commons.codec.binary.Base64.encodeInteger().

static byte [] org.apache.commons.codec.binary.Base64.encodeBase64 ( final byte[]  binaryData,
final boolean  isChunked 
)
static

Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.

Parameters
binaryDataArray containing binary data to encode.
isChunkedif
true
this encoder will chunk the base64 output into 76 character blocks
Returns
Base64-encoded data.
Exceptions
IllegalArgumentExceptionThrown when the input array needs an output array bigger than Integer#MAX_VALUE

Definition at line 617 of file Base64.java.

References org.apache.commons.codec.binary.Base64.encodeBase64().

static byte [] org.apache.commons.codec.binary.Base64.encodeBase64 ( final byte[]  binaryData,
final boolean  isChunked,
final boolean  urlSafe 
)
static

Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.

Parameters
binaryDataArray containing binary data to encode.
isChunkedif
true
this encoder will chunk the base64 output into 76 character blocks
urlSafeif
true
this encoder will emit - and _ instead of the usual + and / characters. Note: no padding is added when encoding using the URL-safe alphabet.
Returns
Base64-encoded data.
Exceptions
IllegalArgumentExceptionThrown when the input array needs an output array bigger than Integer#MAX_VALUE
Since
1.4

Definition at line 636 of file Base64.java.

References org.apache.commons.codec.binary.Base64.encodeBase64().

static byte [] org.apache.commons.codec.binary.Base64.encodeBase64 ( final byte[]  binaryData,
final boolean  isChunked,
final boolean  urlSafe,
final int  maxResultSize 
)
static

Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.

Parameters
binaryDataArray containing binary data to encode.
isChunkedif
true
this encoder will chunk the base64 output into 76 character blocks
urlSafeif
true
this encoder will emit - and _ instead of the usual + and / characters. Note: no padding is added when encoding using the URL-safe alphabet.
maxResultSizeThe maximum result size to accept.
Returns
Base64-encoded data.
Exceptions
IllegalArgumentExceptionThrown when the input array needs an output array bigger than maxResultSize
Since
1.4

Definition at line 657 of file Base64.java.

References org.apache.commons.codec.binary.Base64.Base64(), org.apache.commons.codec.binary.Base64.encode(), and org.apache.commons.codec.binary.BaseNCodec.getEncodedLength().

static byte [] org.apache.commons.codec.binary.Base64.encodeBase64Chunked ( final byte[]  binaryData)
static

Encodes binary data using the base64 algorithm and chunks the encoded output into 76 character blocks

Parameters
binaryDatabinary data to encode
Returns
Base64 characters chunked in 76 character blocks

Definition at line 602 of file Base64.java.

References org.apache.commons.codec.binary.Base64.encodeBase64().

static String org.apache.commons.codec.binary.Base64.encodeBase64String ( final byte[]  binaryData)
static

Encodes binary data using the base64 algorithm but does not chunk the output.

NOTE: We changed the behaviour of this method from multi-line chunking (commons-codec-1.4) to single-line non-chunking (commons-codec-1.5).

Parameters
binaryDatabinary data to encode
Returns
String containing Base64 characters.
Since
1.4 (NOTE: 1.4 chunked the output, whereas 1.5 does not).

Definition at line 565 of file Base64.java.

References org.apache.commons.codec.binary.Base64.encodeBase64(), and org.apache.commons.codec.binary.StringUtils.newStringUtf8().

Referenced by com.trouch.webiopi.client.PiClient.encodeCredentials().

static byte [] org.apache.commons.codec.binary.Base64.encodeBase64URLSafe ( final byte[]  binaryData)
static

Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The url-safe variation emits - and _ instead of + and / characters. Note: no padding is added.

Parameters
binaryDatabinary data to encode
Returns
byte[] containing Base64 characters in their UTF-8 representation.
Since
1.4

Definition at line 578 of file Base64.java.

References org.apache.commons.codec.binary.Base64.encodeBase64().

static String org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString ( final byte[]  binaryData)
static

Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The url-safe variation emits - and _ instead of + and / characters. Note: no padding is added.

Parameters
binaryDatabinary data to encode
Returns
String containing Base64 characters
Since
1.4

Definition at line 591 of file Base64.java.

References org.apache.commons.codec.binary.Base64.encodeBase64(), and org.apache.commons.codec.binary.StringUtils.newStringUtf8().

static byte [] org.apache.commons.codec.binary.Base64.encodeInteger ( final BigInteger  bigInt)
static

Encodes to a byte64-encoded integer according to crypto standards such as W3C's XML-Signature

Parameters
bigInta BigInteger
Returns
A byte array containing base64 character data
Exceptions
NullPointerExceptionif null is passed in
Since
1.4

Definition at line 725 of file Base64.java.

References org.apache.commons.codec.binary.Base64.encodeBase64(), and org.apache.commons.codec.binary.Base64.toIntegerBytes().

static boolean org.apache.commons.codec.binary.Base64.isArrayByteBase64 ( final byte[]  arrayOctet)
static

Tests a given byte array to see if it contains only valid characters within the Base64 alphabet. Currently the method treats whitespace as valid.

Parameters
arrayOctetbyte array to test
Returns
true
if all bytes are valid characters in the Base64 alphabet or if the byte array is empty;
false
, otherwise
Deprecated:
1.5 Use isBase64(byte[]), will be removed in 2.0.

Definition at line 494 of file Base64.java.

References org.apache.commons.codec.binary.Base64.isBase64().

static boolean org.apache.commons.codec.binary.Base64.isBase64 ( final byte  octet)
static

Returns whether or not the octet is in the base 64 alphabet.

Parameters
octetThe value to test
Returns
true
if the value is defined in the the base 64 alphabet,
false
otherwise.
Since
1.4

Definition at line 506 of file Base64.java.

References org.apache.commons.codec.binary.BaseNCodec.PAD_DEFAULT.

Referenced by org.apache.commons.codec.binary.Base64.isArrayByteBase64(), and org.apache.commons.codec.binary.Base64.isBase64().

static boolean org.apache.commons.codec.binary.Base64.isBase64 ( final String  base64)
static

Tests a given String to see if it contains only valid characters within the Base64 alphabet. Currently the method treats whitespace as valid.

Parameters
base64String to test
Returns
true
if all characters in the String are valid characters in the Base64 alphabet or if the String is empty;
false
, otherwise
Since
1.5

Definition at line 520 of file Base64.java.

References org.apache.commons.codec.binary.StringUtils.getBytesUtf8(), and org.apache.commons.codec.binary.Base64.isBase64().

static boolean org.apache.commons.codec.binary.Base64.isBase64 ( final byte[]  arrayOctet)
static

Tests a given byte array to see if it contains only valid characters within the Base64 alphabet. Currently the method treats whitespace as valid.

Parameters
arrayOctetbyte array to test
Returns
true
if all bytes are valid characters in the Base64 alphabet or if the byte array is empty;
false
, otherwise
Since
1.5

Definition at line 534 of file Base64.java.

References org.apache.commons.codec.binary.Base64.isBase64(), and org.apache.commons.codec.binary.BaseNCodec.isWhiteSpace().

boolean org.apache.commons.codec.binary.Base64.isInAlphabet ( final byte  octet)
protected

Returns whether or not the octet is in the Base64 alphabet.

Parameters
octetThe value to test
Returns
true
if the value is defined in the the Base64 alphabet
false
otherwise.

Definition at line 771 of file Base64.java.

boolean org.apache.commons.codec.binary.Base64.isUrlSafe ( )

Returns our current encode mode. True if we're URL-SAFE, false otherwise.

Returns
true if we're in URL-SAFE mode, false otherwise.
Since
1.4

Definition at line 302 of file Base64.java.

References org.apache.commons.codec.binary.Base64.URL_SAFE_ENCODE_TABLE.

static byte [] org.apache.commons.codec.binary.Base64.toIntegerBytes ( final BigInteger  bigInt)
staticpackage

Returns a byte-array representation of a BigInteger without sign bit.

Parameters
bigIntBigInteger to be converted
Returns
a byte array representation of the BigInteger parameter

Definition at line 739 of file Base64.java.

Referenced by org.apache.commons.codec.binary.Base64.encodeInteger().

Member Data Documentation

final int org.apache.commons.codec.binary.Base64.BITS_PER_ENCODED_BYTE = 6
staticprivate

BASE32 characters are 6 bits in length. They are formed by taking a block of 3 octets to form a 24-bit string, which is converted into 4 BASE64 characters.

Definition at line 58 of file Base64.java.

Referenced by org.apache.commons.codec.binary.Base64.decode().

final int org.apache.commons.codec.binary.Base64.BYTES_PER_ENCODED_BLOCK = 4
staticprivate
final int org.apache.commons.codec.binary.Base64.BYTES_PER_UNENCODED_BLOCK = 3
staticprivate

Definition at line 59 of file Base64.java.

final byte [] org.apache.commons.codec.binary.Base64.CHUNK_SEPARATOR = {'\r', '\n'}
staticpackage

Chunk separator per RFC 2045 section 2.1.

N.B. The next major release may break compatibility and make this field private.

See also
RFC 2045 section 2.1

Definition at line 71 of file Base64.java.

Referenced by org.apache.commons.codec.binary.Base64.Base64().

final byte [] org.apache.commons.codec.binary.Base64.DECODE_TABLE
staticprivate
Initial value:
= {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, 62, -1, 63, 52, 53, 54,
55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
24, 25, -1, -1, -1, -1, 63, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
}

This array is a lookup table that translates Unicode characters drawn from the "Base64 Alphabet" (as specified in Table 1 of RFC 2045) into their 6-bit positive integer equivalents. Characters that are not in the Base64 alphabet but fall within the bounds of the array are translated to -1.

Note: '+' and '-' both decode to 62. '/' and '_' both decode to 63. This means decoder seamlessly handles both URL_SAFE and STANDARD base64. (The encoder, on the other hand, needs to know ahead of time what to emit).

Thanks to "commons" project in ws.apache.org for this code. http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/

Definition at line 112 of file Base64.java.

final int org.apache.commons.codec.binary.Base64.decodeSize
private

Convenience variable to help us determine when our buffer is going to run out of room and needs resizing. decodeSize = 3 + lineSeparator.length;

Definition at line 151 of file Base64.java.

final byte [] org.apache.commons.codec.binary.Base64.decodeTable = DECODE_TABLE
private

Definition at line 140 of file Base64.java.

final int org.apache.commons.codec.binary.Base64.encodeSize
private

Convenience variable to help us determine when our buffer is going to run out of room and needs resizing. encodeSize = 4 + lineSeparator.length;

Definition at line 157 of file Base64.java.

final byte [] org.apache.commons.codec.binary.Base64.encodeTable
private

Encode table to use: either STANDARD or URL_SAFE. Note: the DECODE_TABLE above remains static because it is able to decode both STANDARD and URL_SAFE streams, but the encodeTable must be a member variable so we can switch between the two modes.

Definition at line 137 of file Base64.java.

final byte [] org.apache.commons.codec.binary.Base64.lineSeparator
private

Line separator for encoding. Not used when decoding. Only used if lineLength > 0.

Definition at line 145 of file Base64.java.

Referenced by org.apache.commons.codec.binary.Base64.Base64().

final int org.apache.commons.codec.binary.Base64.MASK_6BITS = 0x3f
staticprivate

Base64 uses 6-bit fields.Mask used to extract 6 bits, used when encoding

Definition at line 126 of file Base64.java.

Referenced by org.apache.commons.codec.binary.Base64.encode().

final byte [] org.apache.commons.codec.binary.Base64.STANDARD_ENCODE_TABLE
staticprivate
Initial value:
= {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
}

This array is a lookup table that translates 6-bit positive integer index values into their "Base64 Alphabet" equivalents as specified in Table 1 of RFC 2045.

Thanks to "commons" project in ws.apache.org for this code. http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/

Definition at line 80 of file Base64.java.

Referenced by org.apache.commons.codec.binary.Base64.Base64().

final byte [] org.apache.commons.codec.binary.Base64.URL_SAFE_ENCODE_TABLE
staticprivate
Initial value:
= {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_'
}

This is a copy of the STANDARD_ENCODE_TABLE above, but with + and / changed to - and _ to make the encoded Base64 results more URL-SAFE. This table is only used when the Base64's mode is set to URL-SAFE.

Definition at line 93 of file Base64.java.

Referenced by org.apache.commons.codec.binary.Base64.isUrlSafe().


The documentation for this class was generated from the following file: