Top Description Inners Fields Constructors Methods
io.undertow.util

public Class FlexBase64

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStream, .OutputStream, java.lang.reflect.Constructor, java.nio.ByteBuffer, java.nio.charset.StandardCharsets, java.security.AccessController, .PrivilegedExceptionAction

An efficient and flexible Base64 implementation. This class can deal with both MIME Base64 and Base64url.
Author
Jason T. Greene

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
FlexBase64.Decoder

Controls the decoding process.

public static class
FlexBase64.DecoderInputStream

An input stream which decodes bytes as they are read from a stream with Base64 encoded data.

public static class
FlexBase64.DecoderOutputStream

An output stream which decodes base64 data written to it, and writes the decoded output to the wrapped inner stream.

public static class
FlexBase64.Encoder

Controls the encoding process.

public static class
FlexBase64.EncoderInputStream

An input stream which encodes bytes as they are read from a stream.

public static class
FlexBase64.EncoderOutputStream

An output stream which base64 encodes all passed data and writes it to the wrapped target output stream.

Field Summary

Modifier and TypeField and Description
private static final byte[]
private static final byte[]
private static final Constructor<String>
private static final byte[]
private static final byte[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static FlexBase64.Decoder

Returns:

a new createDecoder instance
createDecoder
()

Creates a state driven base64 decoder.

public static FlexBase64.DecoderInputStream

Returns:

a decoded input stream instance.
createDecoderInputStream
(InputStream
an input source to read from
source
,
int
the chunk size to buffer before when reading from the target
bufferSize
)

Creates an InputStream wrapper which decodes a base64 input source into the decoded content as it is read, until the source hits EOF.

public static FlexBase64.DecoderInputStream

Returns:

a decoded input stream instance.
createDecoderInputStream
(InputStream
an input source to read from
source
)

Creates an InputStream wrapper which decodes a base64 input source into the decoded content as it is read, until the source hits EOF.

public static FlexBase64.DecoderOutputStream

Returns:

a decoded output stream instance.
createDecoderOutputStream
(OutputStream
the output stream to write decoded output to
output
,
int
the buffer size to buffer writes to
bufferSize
)

Creates an OutputStream wrapper which decodes base64 content before writing to the passed OutputStream target.

public static FlexBase64.DecoderOutputStream

Returns:

a decoded output stream instance.
createDecoderOutputStream
(OutputStream
the output stream to write decoded output to
output
)

Creates an OutputStream wrapper which decodes base64 content before writing to the passed OutputStream target.

public static FlexBase64.Encoder

Returns:

an createEncoder instance
createEncoder
(boolean
whether or not to wrap at 76 characters with CRLF
wrap
)

Creates a state driven base64 encoder.

public static FlexBase64.EncoderInputStream

Returns:

an encoded input stream instance.
createEncoderInputStream
(InputStream
an input source to read from
source
,
int
the chunk size to buffer from the source
bufferSize
,
boolean
whether or not the stream should wrap base64 output at 76 characters
wrap
)

Creates an InputStream wrapper which encodes a source into base64 as it is read, until the source hits EOF.

public static FlexBase64.EncoderInputStream

Returns:

an encoded input stream instance.
createEncoderInputStream
(InputStream
an input source to read from
source
)

Creates an InputStream wrapper which encodes a source into base64 as it is read, until the source hits EOF.

public static FlexBase64.EncoderOutputStream

Returns:

an encoded output stream instance.
createEncoderOutputStream
(OutputStream
an output target to write to
target
,
int
the chunk size to buffer before writing to the target
bufferSize
,
boolean
whether or not the stream should wrap base64 output at 76 characters
wrap
)

Creates an OutputStream wrapper which base64 encodes and writes to the passed OutputStream target.

public static FlexBase64.EncoderOutputStream

Returns:

an encoded output stream instance.
createEncoderOutputStream
(OutputStream
the output stream to write encoded output to
output
)

Creates an OutputStream wrapper which base64 encodes and writes to the passed OutputStream target.

public static FlexBase64.Decoder

Returns:

a new createDecoder instance
createURLDecoder
()

Creates a state driven base64url decoder.

public static FlexBase64.Encoder

Returns:

an createEncoder instance
createURLEncoder
(boolean
whether or not to wrap at 76 characters with CRLF
wrap
)

Creates a state driven base64url encoder.

public static ByteBuffer

Returns:

a byte buffer containing the decoded output
decode
(String
the Base64 string to decode
source
)

Decodes a Base64 encoded string into a new byte buffer.

public static ByteBuffer

Returns:

a byte buffer containing the decoded output
decode
(ByteBuffer
the Base64 content to decode
source
)

Decodes a Base64 encoded byte buffer into a new byte buffer.

public static ByteBuffer

Returns:

a byte buffer containing the decoded output
decode
(byte[]
the Base64 content to decode
source
,
int
position to start decoding from in source
off
,
int
position to stop decoding in source (exclusive)
limit
)

Decodes a Base64 encoded byte array into a new byte buffer.

public static ByteBuffer

Returns:

a byte buffer containing the decoded output
decodeURL
(String
the Base64 string to decode
source
)

Decodes a Base64url encoded string into a new byte buffer.

public static ByteBuffer

Returns:

a byte buffer containing the decoded output
decodeURL
(ByteBuffer
the Base64 content to decode
source
)

Decodes a Base64url encoded byte buffer into a new byte buffer.

public static ByteBuffer

Returns:

a byte buffer containing the decoded output
decodeURL
(byte[]
the Base64url content to decode
source
,
int
position to start decoding from in source
off
,
int
position to stop decoding in source (exclusive)
limit
)

Decodes a Base64url encoded byte array into a new byte buffer.

public static byte[]

Returns:

a new byte array containing the encoded ASCII values
encodeBytes
(byte[]
the byte array to encode from
source
,
int
the position to start encoding at
pos
,
int
the position to halt encoding at (exclusive)
limit
,
boolean
whether or not to wrap at 76 characters with CRLFs
wrap
)

Encodes a fixed and complete byte buffer into a Base64 byte array.

public static byte[]

Returns:

a new byte array containing the encoded ASCII values
encodeBytesURL
(byte[]
the byte array to encode from
source
,
int
the position to start encoding at
pos
,
int
the position to halt encoding at (exclusive)
limit
,
boolean
whether or not to wrap at 76 characters with CRLFs
wrap
)

Encodes a fixed and complete byte buffer into a Base64url byte array.

public static String

Returns:

a new String representing the Base64 output
encodeString
(byte[]
the byte array to encode from
source
,
boolean
whether or not to wrap the output at 76 chars with CRLFs
wrap
)

Encodes a fixed and complete byte array into a Base64 String.

public static String

Returns:

a new String representing the Base64 output
encodeString
(byte[]
the byte array to encode from
source
,
int
the position to start encoding from
pos
,
int
the position to halt encoding at (exclusive)
limit
,
boolean
whether or not to wrap the output at 76 chars with CRLFs
wrap
)

Encodes a fixed and complete byte array into a Base64 String.

public static String

Returns:

a new String representing the Base64 output
encodeString
(ByteBuffer
the byte buffer to encode from
source
,
boolean
whether or not to wrap the output at 76 chars with CRLFs
wrap
)

Encodes a fixed and complete byte buffer into a Base64 String.

public static String

Returns:

a new String representing the Base64url output
encodeStringURL
(byte[]
the byte array to encode from
source
,
boolean
whether or not to wrap the output at 76 chars with CRLFs
wrap
)

Encodes a fixed and complete byte array into a Base64url String.

public static String

Returns:

a new String representing the Base64url output
encodeStringURL
(byte[]
the byte array to encode from
source
,
int
the position to start encoding from
pos
,
int
the position to halt encoding at (exclusive)
limit
,
boolean
whether or not to wrap the output at 76 chars with CRLFs
wrap
)

Encodes a fixed and complete byte array into a Base64url String.

public static String

Returns:

a new String representing the Base64url output
encodeStringURL
(ByteBuffer
the byte buffer to encode from
source
,
boolean
whether or not to wrap the output at 76 chars with CRLFs
wrap
)

Encodes a fixed and complete byte buffer into a Base64url String.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait