DigiStamp.com

dgs.tlkt
Class ToolkitUtility

java.lang.Object
  extended bydgs.tlkt.ToolkitUtility

public class ToolkitUtility
extends java.lang.Object

This class contains several "help functions" related to time stamp processing. All the methods are Statics.


Field Summary
static java.lang.String DSG_SIG_POLICY1
           
static java.lang.String ID_CTI_ETS_PROOFOFAPPROVAL
          The object identifier as a string for ID_CTI_ETS_PROOFOFAPPROVAL
static java.lang.String ID_CTI_ETS_PROOFOFCREATION
          The object identifier as a string for ID_CTI_ETS_PROOFOFCREATION
static java.lang.String ID_CTI_ETS_PROOFOFORIGIN
          The object identifier as a string for ID_CTI_ETS_PROOFOFORIGIN
static java.lang.String ID_CTI_ETS_PROOFOFRECEIPT
          The object identifier as a string for ID_CTI_ETS_PROOFOFRECEIPT
static java.lang.String SHA_1
          The object identifier as a string for SHA_1
 
Method Summary
static byte[] base64Bytes(java.lang.String inString)
          Create a base 64 string from input byte array
static java.lang.String base64String(byte[] inBytes)
          Create a base 64 string from input byte array
static byte[] byteArrayAppend(byte[] b1, byte[] b2)
          Returns new byte array from concatenation of input
static boolean byteArraysEqual(byte[] b1, byte[] b2)
          Are the two byte arrays equal?
static java.lang.String byteArrayToString(byte[] in)
          Byte array is returned as string - integers separated by comma
static byte[] byteArrayTrim(byte[] in, int length)
          Trim the byte array to the specified length
static byte[] byteCopy(byte[] in, int from, int to)
          Copy of the byte array from the specified position to the given position
static java.lang.String byteToHex02sString(byte[] digestBits)
          Returns the byte array as a hex string separated by spaces
static java.lang.String byteToHex04String(byte[] digestBits)
          Returns the byte array as hex string ("0X" notation)
static java.lang.String byteToString(byte[] digestBits)
          Returns the byte array as a hex string
static java.lang.String dateToGMTString(java.util.Date date)
          Returns the data as a GMT string: "yyyy MM dd HH:mm:ss zz"
static byte[] digestSHA1(byte[] yourData)
          Only to be used on small byte arrays for testing purposes.
static byte[] digestSHA1(java.io.InputStream in)
          Only to be used on small byte arrays for testing purposes.
static java.lang.String dNtoString(byte[] anEncodedName)
          Given an ASN encoded x500 name, return a readable string of the name.
static java.lang.String dNtoString(java.security.Principal aPrincipal)
          Given a java.security.Principal, return a readable string of the name.
static java.lang.String dNtoString(sun.security.x509.X500Name name)
          Given a sun.security.x509.X500Name, return a readable name
static java.lang.String encodeDNtoString(byte[] encodedDN)
          Insert the method's description here.
static java.lang.String getOidText(java.lang.String oid)
          Translate OID values used in the toolkit to more human readable.
static byte[] hexStringToByteArray(java.lang.String aString)
          Given a hex string (format 2 with no spaces), convert to the byte array.
static java.lang.String printTSInfo(CMSTsToken cms)
          Display information contained in the time stamp.
static byte[] readFile(java.io.File aFile)
          Convenience method to read a file to a byte array.
static byte[] readFile(java.lang.String fileName)
          Convenience method to read a file to a byte array.
static void writeToFile(java.io.File aFile, byte[] bytesOut)
          Convenience method to write a byte array to disk.
static void writeToFile(java.lang.String fileName, byte[] bytesOut)
          Convenience method to write a byte array to disk.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DSG_SIG_POLICY1

public static transient java.lang.String DSG_SIG_POLICY1

ID_CTI_ETS_PROOFOFAPPROVAL

public static transient java.lang.String ID_CTI_ETS_PROOFOFAPPROVAL
The object identifier as a string for ID_CTI_ETS_PROOFOFAPPROVAL


ID_CTI_ETS_PROOFOFCREATION

public static transient java.lang.String ID_CTI_ETS_PROOFOFCREATION
The object identifier as a string for ID_CTI_ETS_PROOFOFCREATION


ID_CTI_ETS_PROOFOFORIGIN

public static transient java.lang.String ID_CTI_ETS_PROOFOFORIGIN
The object identifier as a string for ID_CTI_ETS_PROOFOFORIGIN


ID_CTI_ETS_PROOFOFRECEIPT

public static transient java.lang.String ID_CTI_ETS_PROOFOFRECEIPT
The object identifier as a string for ID_CTI_ETS_PROOFOFRECEIPT


SHA_1

public static transient java.lang.String SHA_1
The object identifier as a string for SHA_1

Method Detail

base64Bytes

public static byte[] base64Bytes(java.lang.String inString)
Create a base 64 string from input byte array

Parameters:
inString - byte[]
Returns:
java.lang.String

base64String

public static java.lang.String base64String(byte[] inBytes)
Create a base 64 string from input byte array

Parameters:
inBytes - byte[]
Returns:
java.lang.String

byteArrayAppend

public static byte[] byteArrayAppend(byte[] b1,
                                     byte[] b2)
Returns new byte array from concatenation of input

Parameters:
b1 - byte[]
b2 - byte[]
Returns:
byte[]

byteArraysEqual

public static boolean byteArraysEqual(byte[] b1,
                                      byte[] b2)
Are the two byte arrays equal?

Parameters:
b1 - byte[]
b2 - byte[]
Returns:
boolean

byteArrayToString

public static java.lang.String byteArrayToString(byte[] in)
Byte array is returned as string - integers separated by comma

Parameters:
in - byte[]
Returns:
java.lang.String

byteArrayTrim

public static byte[] byteArrayTrim(byte[] in,
                                   int length)
Trim the byte array to the specified length

Parameters:
in - byte[]
Returns:
byte[]

byteCopy

public static byte[] byteCopy(byte[] in,
                              int from,
                              int to)
Copy of the byte array from the specified position to the given position

Parameters:
in - byte[]
from - int
to - int exclusive
Returns:
byte[]

byteToHex02sString

public static java.lang.String byteToHex02sString(byte[] digestBits)
Returns the byte array as a hex string separated by spaces

Parameters:
digestBits - byte[]
Returns:
java.lang.String

byteToHex04String

public static java.lang.String byteToHex04String(byte[] digestBits)
Returns the byte array as hex string ("0X" notation)

Parameters:
digestBits - byte[] this same method is in serverProxy package
Returns:
java.lang.String

byteToString

public static java.lang.String byteToString(byte[] digestBits)
Returns the byte array as a hex string

Parameters:
digestBits - byte[] this same method is in serverProxy package
Returns:
java.lang.String

dateToGMTString

public static java.lang.String dateToGMTString(java.util.Date date)
Returns the data as a GMT string: "yyyy MM dd HH:mm:ss zz"

Parameters:
date - Date
Returns:
java.lang.String

digestSHA1

public static byte[] digestSHA1(byte[] yourData)
Only to be used on small byte arrays for testing purposes. Returns the SHA-1 hash of the input byte array. Uses:
java.security.MessageDigest.getInstance("SHA-1","SUN")
if that fails, java.security.MessageDigest.getInstance("SHA-1")

Parameters:
yourData - byte[]
Returns:
byte[] Returns the SHA-1 hash of the input byte array. Uses:
java.security.MessageDigest.getInstance("SHA-1","SUN")
if that fails, java.security.MessageDigest.getInstance("SHA-1")

digestSHA1

public static byte[] digestSHA1(java.io.InputStream in)
                         throws java.io.IOException
Only to be used on small byte arrays for testing purposes. Returns the SHA-1 hash of the input InputStream. Uses:
java.security.MessageDigest.getInstance("SHA-1","SUN")
if that fails, java.security.MessageDigest.getInstance("SHA-1")

Parameters:
in - InputStream
Returns:
byte[] Returns the SHA-1 hash of the input byte array. Uses:
java.security.MessageDigest.getInstance("SHA-1","SUN")
if that fails, java.security.MessageDigest.getInstance("SHA-1")
Throws:
java.io.IOException

dNtoString

public static java.lang.String dNtoString(byte[] anEncodedName)
Given an ASN encoded x500 name, return a readable string of the name.

Parameters:
anEncodedName - byte[]

dNtoString

public static java.lang.String dNtoString(java.security.Principal aPrincipal)
Given a java.security.Principal, return a readable string of the name.

Parameters:
aPrincipal - Principal

dNtoString

public static java.lang.String dNtoString(sun.security.x509.X500Name name)
Given a sun.security.x509.X500Name, return a readable name

Parameters:
name - X500Name

encodeDNtoString

public static java.lang.String encodeDNtoString(byte[] encodedDN)
Insert the method's description here. Creation date: (10/19/01 2:38:40 PM)

Parameters:
encodedDN - byte[]

getOidText

public static java.lang.String getOidText(java.lang.String oid)
Translate OID values used in the toolkit to more human readable. If translation not available then it returns the input value. Never returns null.

Parameters:
oid - java.lang.String
Returns:
java.lang.String

hexStringToByteArray

public static byte[] hexStringToByteArray(java.lang.String aString)
                                   throws java.lang.NumberFormatException
Given a hex string (format 2 with no spaces), convert to the byte array. This method was created by a SmartGuide.

Parameters:
aString - java.lang.String
Returns:
byte[]
Throws:
java.lang.NumberFormatException

printTSInfo

public static java.lang.String printTSInfo(CMSTsToken cms)
Display information contained in the time stamp.


readFile

public static byte[] readFile(java.io.File aFile)
Convenience method to read a file to a byte array. Not to be used with large files. IOExceptions written to logger.

Parameters:
aFile - File

readFile

public static byte[] readFile(java.lang.String fileName)
Convenience method to read a file to a byte array. Not to be used with large files. IOExceptions written to logger.

Parameters:
fileName - java.lang.String

writeToFile

public static void writeToFile(java.io.File aFile,
                               byte[] bytesOut)
Convenience method to write a byte array to disk. IOExceptions written to logger.

Parameters:
aFile - File
bytesOut - byte[]

writeToFile

public static void writeToFile(java.lang.String fileName,
                               byte[] bytesOut)
Convenience method to write a byte array to disk. IOExceptions written to logger.

Parameters:
fileName - java.lang.String
bytesOut - byte[]

Copyright 2000-2010 DigiStamp, Inc.