Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.sun.xacml.attr
Class Base64  view Base64 download Base64.java

java.lang.Object
  extended bycom.sun.xacml.attr.Base64

class Base64
extends java.lang.Object

Class that knows how to encode and decode Base64 values. Base64 Content-Transfer-Encoding rules are defined in Section 6.8 of IETF RFC 2045 Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies, available at ftp://ftp.isi.edu/in-notes/rfc2045.txt.

All methods of this class are static and thread-safe.

Since:
1.0

Field Summary
private static char ALTLF
           
private static int[] Base64DecodeArray
           
private static java.lang.String BASE64EncodingString
           
private static char CR
           
private static char ETX
           
private static char FF
           
private static char HTAB
           
private static char LF
           
private static int MAX_BASE64_CHAR
           
private static int MAX_GROUPS_PER_LINE
          The maximum number of groups that should be encoded onto a single line (so we don't exceed 76 characters per line).
private static int NO_CHARS_DECODED
           
private static int ONE_CHAR_DECODED
           
private static char PAD
           
private static int PAD_FOUR_READ
           
private static int PAD_INDEX
           
private static int PAD_THREE_READ
           
private static char SPACE
           
private static int THREE_CHARS_DECODED
           
private static int TWO_CHARS_DECODED
           
private static char VTAB
           
 
Constructor Summary
(package private) Base64()
           
 
Method Summary
static byte[] decode(java.lang.String encoded, boolean ignoreBadChars)
          Decodes a Base64-encoded String.
static java.lang.String encode(byte[] binaryValue)
          Encodes the input byte array into a Base64-encoded String.
private static void initDecodeArray()
          Initializes Base64DecodeArray, if this hasn't already been done.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPACE

private static final char SPACE
See Also:
Constant Field Values

ETX

private static final char ETX
See Also:
Constant Field Values

VTAB

private static final char VTAB
See Also:
Constant Field Values

FF

private static final char FF
See Also:
Constant Field Values

HTAB

private static final char HTAB
See Also:
Constant Field Values

LF

private static final char LF
See Also:
Constant Field Values

ALTLF

private static final char ALTLF
See Also:
Constant Field Values

CR

private static final char CR
See Also:
Constant Field Values

PAD

private static char PAD

BASE64EncodingString

private static final java.lang.String BASE64EncodingString
See Also:
Constant Field Values

PAD_INDEX

private static final int PAD_INDEX
See Also:
Constant Field Values

MAX_BASE64_CHAR

private static final int MAX_BASE64_CHAR
See Also:
Constant Field Values

Base64DecodeArray

private static int[] Base64DecodeArray

NO_CHARS_DECODED

private static final int NO_CHARS_DECODED
See Also:
Constant Field Values

ONE_CHAR_DECODED

private static final int ONE_CHAR_DECODED
See Also:
Constant Field Values

TWO_CHARS_DECODED

private static final int TWO_CHARS_DECODED
See Also:
Constant Field Values

THREE_CHARS_DECODED

private static final int THREE_CHARS_DECODED
See Also:
Constant Field Values

PAD_THREE_READ

private static final int PAD_THREE_READ
See Also:
Constant Field Values

PAD_FOUR_READ

private static final int PAD_FOUR_READ
See Also:
Constant Field Values

MAX_GROUPS_PER_LINE

private static final int MAX_GROUPS_PER_LINE
The maximum number of groups that should be encoded onto a single line (so we don't exceed 76 characters per line).

See Also:
Constant Field Values
Constructor Detail

Base64

Base64()
Method Detail

encode

public static java.lang.String encode(byte[] binaryValue)
Encodes the input byte array into a Base64-encoded String. The output String has a CR LF (0x0d 0x0a) after every 76 bytes, but not at the end.

WARNING: If the input byte array is modified while encoding is in progress, the output is undefined.


initDecodeArray

private static void initDecodeArray()
Initializes Base64DecodeArray, if this hasn't already been done.


decode

public static byte[] decode(java.lang.String encoded,
                            boolean ignoreBadChars)
                     throws java.io.IOException
Decodes a Base64-encoded String. The result is returned in a byte array that should match the original binary value (before encoding). Whitespace characters in the input String are ignored.

If the ignoreBadChars parameter is true, characters that are not allowed in a BASE64-encoded string are ignored. Otherwise, they cause an IOException to be raised.