Top Description Fields Constructors Methods
org.mortbay.jetty.security

public Class B64Code

extends Object
Class Inheritance
Imports
java.io.UnsupportedEncodingException, org.mortbay.util.StringUtil

Fast B64 Encoder/Decoder as described in RFC 1421.

Does not insert or interpret whitespace as described in RFC 1521. If you require this you must pre/post process your data.

Note that in a web context the usual case is to not want linebreaks or other white space in the encoded output.

Authors
Brett Sealey (bretts), Greg Wilkins (gregw)

Field Summary

Modifier and TypeField and Description
pack-priv static byte[]
pack-priv static final char[]
pack-priv static final char

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

String decoded byte array.
decode
(String
String to decode
s
)

Base 64 decode as described in RFC 1421.

public static String

Returns:

String decoded byte array.
decode
(String
String to decode
s
,
String
String representing the character encoding used to map the decoded bytes into a String.
charEncoding
)

Base 64 decode as described in RFC 1421.

public static byte[]

Returns:

byte array containing the decoded form of the input.
decode
(char[]
char array to decode.
b
)

Fast Base 64 decode as described in RFC 1421.

public static String

Returns:

String containing the encoded form of the input.
encode
(String
String to encode.
s
)

Base 64 encode as described in RFC 1421.

public static String

Returns:

String containing the encoded form of the input.
encode
(String
String to encode.
s
,
String
String representing the name of the character encoding of the provided input String.
charEncoding
)

Base 64 encode as described in RFC 1421.

public static char[]

Returns:

char array containing the encoded form of the input.
encode
(byte[]
byte array to encode.
b
)

Fast Base 64 encode as described in RFC 1421.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

code2nibbleback to summary
pack-priv static byte[] code2nibble
nibble2codeback to summary
pack-priv static final char[] nibble2code
padback to summary
pack-priv static final char pad

Constructor Detail

B64Codeback to summary
public B64Code()

Method Detail

decodeback to summary
public static String decode(String s)

Base 64 decode as described in RFC 1421.

Does not attempt to cope with extra whitespace as described in RFC 1521.

Parameters
s:String

String to decode

Returns:String

String decoded byte array.

decodeback to summary
public static String decode(String s, String charEncoding) throws UnsupportedEncodingException

Base 64 decode as described in RFC 1421.

Does not attempt to cope with extra whitespace as described in RFC 1521.

Parameters
s:String

String to decode

charEncoding:String

String representing the character encoding used to map the decoded bytes into a String.

Returns:String

String decoded byte array.

decodeback to summary
public static byte[] decode(char[] b)

Fast Base 64 decode as described in RFC 1421.

Does not attempt to cope with extra whitespace as described in RFC 1521.

Avoids creating extra copies of the input/output.

Note this code has been flattened for performance.

Parameters
b:char[]

char array to decode.

Returns:byte[]

byte array containing the decoded form of the input.

Exceptions
IllegalArgumentException:
if the input is not a valid B64 encoding.
encodeback to summary
public static String encode(String s)

Base 64 encode as described in RFC 1421.

Does not insert whitespace as described in RFC 1521.

Parameters
s:String

String to encode.

Returns:String

String containing the encoded form of the input.

encodeback to summary
public static String encode(String s, String charEncoding) throws UnsupportedEncodingException

Base 64 encode as described in RFC 1421.

Does not insert whitespace as described in RFC 1521.

Parameters
s:String

String to encode.

charEncoding:String

String representing the name of the character encoding of the provided input String.

Returns:String

String containing the encoded form of the input.

encodeback to summary
public static char[] encode(byte[] b)

Fast Base 64 encode as described in RFC 1421.

Does not insert whitespace as described in RFC 1521.

Avoids creating extra copies of the input/output.

Parameters
b:byte[]

byte array to encode.

Returns:char[]

char array containing the encoded form of the input.