org.aselect.system.utils
Class Base64

java.lang.Object
  extended by org.aselect.system.utils.Base64

public class Base64
extends java.lang.Object

RFC 2045 compliant Base64 Codec.

Description:
This class implements a Base64 codec engine according to RFC 2045. This class should not be called directly.

Concurrency issues:
None.

Author:
Alfa & Ariss

Constructor Summary
Base64()
           
 
Method Summary
static byte[] decode(java.lang.String xEncodedString)
          Decodes a Base64 encoded String.
static java.lang.String encode(byte[] xData)
          Encodes an array of bytes into Base64 format.
protected static char[] encodeBlock(byte[] xData, int xOffset)
          Encodes a block of 3 bytes.
protected static char getChar(int x6Bits)
          Returns the carachter in the 6 lower bits of the input int.
protected static int getValue(char xChar)
          Decodes the value of a Base64 encoded character.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base64

public Base64()
Method Detail

encode

public static java.lang.String encode(byte[] xData)
Encodes an array of bytes into Base64 format.

Description:
This method encodes a byte array taking 3 bytes with each run until the whole input is encoded.

Concurrency issues:
None.

Preconditions:
None.

Postconditions:
None.

Parameters:
xData - Input byte array.
Returns:
String containing the corresponding Base64 encoding of xInput.

encodeBlock

protected static char[] encodeBlock(byte[] xData,
                                    int xOffset)
Encodes a block of 3 bytes.

Description:
None.

Concurrency issues:
None.

Preconditions:
None.

Postconditions:
None.

Parameters:
xData - input block
xOffset - current offset
Returns:
Encoded String.

getChar

protected static char getChar(int x6Bits)
Returns the carachter in the 6 lower bits of the input int.

Description:
Returns the character represented by the lower 6 bits or one of the trailing character as specified in RFC 2045.

Concurrency issues:
None.

Preconditions:
None.

Postconditions:
None.

Parameters:
x6Bits - Input character.
Returns:
Encoded char according to RFC 2045.

decode

public static byte[] decode(java.lang.String xEncodedString)
Decodes a Base64 encoded String.

Description:
This method decodes an RFC 2045 Base64 encoded String.

Concurrency issues:
None.

Preconditions:
None.

Postconditions:
None.

Parameters:
xEncodedString - Base64 encoded String.
Returns:
byte array contining the decoded bytes.

getValue

protected static int getValue(char xChar)
Decodes the value of a Base64 encoded character.

Description:
This method returns the value of a Base64 encoded character.

Concurrency issues:
None.

Preconditions:
None.

Postconditions:
None.

Parameters:
xChar - Base64 encoded character.
Returns:
Decoded value or -1 if non-Base64 input charachter.


Copyright © 2008 SURFnet BV. All Rights Reserved.