|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--webfunds.util.Armoury
This class provides methods for encoding and decoding data in MIME base64 format. Also included are many convenience methods for encoding and decoding various types of object.
All of the methods either take a byte array, a String, or an Object, and return a byte array or String (depending upon the method) containing the base 64 encoded data. The return value represents a sequence of characters, and depending upon the method, can be either a byte array or String, since these characters are from a subset of both the Unicode and ASCII character repertoires.
See Base64Coder for details on how Base64 works.
| Constructor Summary | |
Armoury()
|
|
| Method Summary | |
static void |
canonicalTest(byte[] buf)
|
static java.lang.String |
createSignedData(byte[] data,
byte[] binarySignature)
Create the signed data |
static byte[] |
decode(java.lang.String msg)
Decodes a byte array containing base64-encoded ASCII. |
static byte[] |
decodeByteArray(java.lang.String type,
java.lang.String buf)
Decode some Base 64 encoded data, first of all searching for the appropriate "BEGIN" line, and reading up until the "END" line. |
static java.security.cert.Certificate |
decodeCert(java.lang.String buf)
Decode a Certificate object from ascii-armoured base64 encoding |
static int |
decodeChecksum(java.lang.String s)
|
static byte[] |
decodeData(byte[] data)
This method returns the data part of a signed message removing the -(space) and changing line endings to local format. |
static java.security.PrivateKey |
decodePrivateKey(java.lang.String buf)
Decode an PrivateKey object from ascii-armoured base64 encoding |
static byte[] |
decodeSig(java.lang.String buf)
Decode a Signature from ascii-armoured base64 encoding |
static java.lang.String |
encode(java.lang.String type,
byte[] data)
Encode data (as a byte array) into ascii-armoured Base 64 encoded data, with "BEGIN" and "END" lines, and default platform newline and 51 chars per line. |
static java.lang.String |
encode(java.lang.String type,
byte[] data,
int maxline)
Encode data (as a byte array) into ascii-armoured Base 64 encoded data, with "BEGIN" and "END" lines. |
static java.lang.String |
encode(java.lang.String type,
byte[] data,
int maxline,
java.lang.String headers,
java.lang.String newline)
Encode data (as a byte array) into ascii-armoured Base 64 encoded data, with "BEGIN" and "END" lines. |
static java.lang.String |
encodeCert(java.security.cert.Certificate cert)
Encode a Certificate object, using ascii-armoured base64 encoding |
static java.lang.String |
encodeChecksum(byte[] buf)
deprecated? |
static java.lang.String |
encodePrivateKey(java.security.PrivateKey key)
Encode a PrivateKey object using ascii-armoured base64 encoding |
static java.lang.String |
encodePublicKey(java.security.PublicKey key)
Encode a PublicKey object using ascii-armoured base64 encoding |
static java.lang.String |
encodeSig(byte[] sig)
Encode a Signature (stored in a byte array) using ascii-armoured base64 encoding |
static java.security.cert.Certificate |
getCertificate(byte[] data)
|
static byte[] |
getChecksum(byte[] buf)
|
static java.lang.String |
getErrors()
Obviously not thread-relevant! |
static boolean |
isPresent(java.lang.String type,
java.lang.String buf)
Determine if this header can be found |
static void |
main(java.lang.String[] args)
|
static byte[] |
prepareDataToSign(byte[] data)
This method prepares data to be signed (i.e. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public Armoury()
| Method Detail |
public static java.lang.String getErrors()
public static byte[] decode(java.lang.String msg)
throws java.io.IOException
data - the data to be encoded.public static byte[] getChecksum(byte[] buf)
public static java.lang.String encodeChecksum(byte[] buf)
public static int decodeChecksum(java.lang.String s)
public static boolean isPresent(java.lang.String type,
java.lang.String buf)
throws java.io.IOException
header - the string following the "BEGIN" on the ascii armour.buf - a String containing the Base 64 encoded databuf contains invalid
characters, or is incorrectly padded.
public static byte[] decodeByteArray(java.lang.String type,
java.lang.String buf)
throws java.io.IOException
header - the string following the "BEGIN" and "END" on the
ascii armouring.buf - a String containing the Base 64 encoded databuf contains invalid
characters, or is incorrectly padded.
public static java.lang.String encode(java.lang.String type,
byte[] data)
data - a byte array containing the data to be encoded
public static java.lang.String encode(java.lang.String type,
byte[] data,
int maxline)
header - the string following the "BEGIN" and "END" on the
ascii armour.data - a byte array containing the data to be encoded
public static java.lang.String encode(java.lang.String type,
byte[] data,
int maxline,
java.lang.String headers,
java.lang.String newline)
header - the string following the "BEGIN" and "END" on the
ascii armour.data - a byte array containing the data to be encodedpublic static java.lang.String encodeCert(java.security.cert.Certificate cert)
cert - the certificate object to be encoded
public static java.security.cert.Certificate getCertificate(byte[] data)
throws java.io.IOException
public static java.security.cert.Certificate decodeCert(java.lang.String buf)
throws SOXKeyException
buf - a String containing the ascii-armoured certificatepublic static java.lang.String encodePublicKey(java.security.PublicKey key)
key - the PublicKey object to be encodedPublicKeypublic static java.lang.String encodePrivateKey(java.security.PrivateKey key)
key - the PrivateKey object to be encodedPrivateKey
public static java.security.PrivateKey decodePrivateKey(java.lang.String buf)
throws java.security.InvalidKeyException
buf - a String containing the base64 encoded PrivateKeyPrivateKeypublic static java.lang.String encodeSig(byte[] sig)
keyPair - the KeyPair object to be encoded
public static byte[] decodeSig(java.lang.String buf)
throws java.io.IOException
buf - a String containing the base64 encoded signature
public static java.lang.String createSignedData(byte[] data,
byte[] binarySignature)
throws java.io.IOException,
java.io.FileNotFoundException,
java.security.KeyException
data - the original data (not the preparedToSign data)binary - Signature the signature of the signedData
public static byte[] decodeData(byte[] data)
throws java.io.IOException
public static byte[] prepareDataToSign(byte[] data)
throws java.io.IOException
data - the original data
public static void canonicalTest(byte[] buf)
throws java.lang.Exception
public static void main(java.lang.String[] args)
throws java.lang.Exception
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||