|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.portal.common.util.Base64
Encodes and decodes to and from Base64 and URL-safe Base64 encodings. URL-safe Base64 encoding being defined here as standard Base64 encoding with the following modifications:
Based on version 2.1 of the Base64 class developed by Robert Harder (public domain). Please visit http://iharder.net/base64 periodically to check for updates or to contribute improvements.
Field Summary | |
private byte[] |
ALPHABET
The 64 valid Base64 values. |
private static byte[] |
BASE64_DECODABET
Translates a Base64 value to either its 6-bit reconstruction value or a negative number indicating some other meaning. |
private byte[] |
DECODABET
Translates a value to either its 6-bit reconstruction value or a negative number indicating some other meaning. |
private static byte |
EQUALS_SIGN
The equals sign (=) as a byte. |
private static int |
IGNORE
|
private static int |
MAX_LINE_LENGTH
Maximum line length (76) of Base64 output. |
private static byte[] |
NATIVE_ALPHABET
|
private static byte[] |
NATIVE_URL_SAFE_ALPHABET
|
private static byte |
NEW_LINE
The new line character (\n) as a byte. |
private byte |
PADDING_CHAR
The character to be used as a padding character in the encoded Strings. |
private static byte |
PADDING_CHAR_ENC
|
private static java.lang.String |
PREFERRED_ENCODING
Preferred encoding. |
private static Base64 |
STANDARD_BASE64
|
private static byte |
STAR
'*' as a byte |
private static Base64 |
URL_SAFE_BASE64
|
private static byte[] |
URL_SAFE_DECODABET
Translates a URL-modified Base64 value to either its 6-bit reconstruction value or a negative number indicating some other meaning. |
private static byte |
WHITE_SPACE_ENC
|
Constructor Summary | |
private |
Base64()
|
private |
Base64(boolean useURLSafeEncoding)
|
Method Summary | |
static byte[] |
decode(byte[] source,
int off,
int len,
boolean urlSafeEncodingWasUsed)
Very low-level access to decoding ASCII characters in the form of a byte array. |
private byte[] |
decode(int len,
int off,
byte[] source)
Very low-level access to decoding ASCII characters in the form of a byte array. |
static byte[] |
decode(java.lang.String s)
Decodes data from Base64 notation |
static byte[] |
decode(java.lang.String s,
boolean urlSafeEncodingWasUsed)
Decodes data from Base64 notation |
private int |
decode4to3(byte[] source,
int srcOffset,
byte[] destination,
int destOffset)
Decodes four bytes from array source and writes the resulting bytes (up to three of them) to destination. |
private byte[] |
encode3to4(byte[] source,
int srcOffset,
int numSigBytes,
byte[] destination,
int destOffset)
Encodes up to three bytes of the array source and writes the resulting four Base64 bytes to destination. |
static java.lang.String |
encodeBytes(byte[] source)
Encodes a byte array into Base64 notation using the standard Base64 encoding. |
static java.lang.String |
encodeBytes(byte[] source,
boolean useURLSafeEncoding)
Encodes a byte array into Base64 notation. |
static java.lang.String |
encodeBytes(byte[] source,
int off,
int len,
boolean useURLSafeEncoding)
Encodes a byte array into Base64 notation. |
private static Base64 |
getBase64(boolean useURLSafeEncoding)
|
void |
initAlphabets(boolean useURLSafeEncoding)
Determine which ALPHABET to use. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final int MAX_LINE_LENGTH
private static final byte EQUALS_SIGN
private static final byte STAR
private byte PADDING_CHAR
private static final byte NEW_LINE
private static final java.lang.String PREFERRED_ENCODING
private byte[] ALPHABET
private static final byte[] NATIVE_ALPHABET
private static final byte[] NATIVE_URL_SAFE_ALPHABET
private static final int IGNORE
private static final byte WHITE_SPACE_ENC
private static final byte PADDING_CHAR_ENC
private byte[] DECODABET
private static final byte[] BASE64_DECODABET
private static final byte[] URL_SAFE_DECODABET
private static final Base64 STANDARD_BASE64
private static final Base64 URL_SAFE_BASE64
Constructor Detail |
private Base64()
private Base64(boolean useURLSafeEncoding)
Method Detail |
public void initAlphabets(boolean useURLSafeEncoding)
private static Base64 getBase64(boolean useURLSafeEncoding)
private byte[] encode3to4(byte[] source, int srcOffset, int numSigBytes, byte[] destination, int destOffset)
source
- the array to convertsrcOffset
- the index where conversion beginsnumSigBytes
- the number of significant bytes in your arraydestination
- the array to hold the conversiondestOffset
- the index where output will be put
public static java.lang.String encodeBytes(byte[] source)
source
- The data to convertpublic static java.lang.String encodeBytes(byte[] source, boolean useURLSafeEncoding)
source
- The data to convertuseURLSafeEncoding
- true
to use '-', '_' instead of '+', '/' in the alphabet and '*' instead
of '=' for padding to generate a URL-safe encoding. Note: Technically, this makes
your encoding non-compliant.public static java.lang.String encodeBytes(byte[] source, int off, int len, boolean useURLSafeEncoding)
source
- The data to convertoff
- Offset in array where conversion should beginlen
- Length of data to convertuseURLSafeEncoding
- true
to use '-', '_' instead of '+', '/' in the alphabet and '*' instead
of '=' for padding to generate a URL-safe encoding. Note: Technically, this makes
your encoding non-compliant.private int decode4to3(byte[] source, int srcOffset, byte[] destination, int destOffset)
source
- the array to convertsrcOffset
- the index where conversion beginsdestination
- the array to hold the conversiondestOffset
- the index where output will be put
private byte[] decode(int len, int off, byte[] source)
source
- The Base64 encoded dataoff
- The offset of where to begin decodinglen
- The length of characters to decode
public static byte[] decode(byte[] source, int off, int len, boolean urlSafeEncodingWasUsed)
source
- The Base64 encoded dataoff
- The offset of where to begin decodinglen
- The length of characters to decodeurlSafeEncodingWasUsed
- true
if the URL-safe was used to encode the data to be decoded
public static byte[] decode(java.lang.String s, boolean urlSafeEncodingWasUsed)
s
- the string to decodeurlSafeEncodingWasUsed
- true
if the URL-safe was used to encode the data to be decoded
public static byte[] decode(java.lang.String s)
s
- the string to decode
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |