org.kth.pdc.grid.utility
Class FileCertReader

java.lang.Object
  extended by org.kth.pdc.grid.utility.FileCertReader

public class FileCertReader
extends Object

Reads all certificates from given files, accepts binary form of DER encoded certs and the Base64 form of the DER encoded certs (PEM). The base64 certs can contain garbage in front of the actual certificate that has to begin with "-----BEGIN". Should accept multiple certs in one file, not tested!


Constructor Summary
FileCertReader()
          Creates a new instance of CertReader
FileCertReader(Provider provider)
          Creates a new instance of CertReader with the specified provider
 
Method Summary
 Object objectReader(BufferedInputStream binStream, int type)
          Reads a certificate or a CRL from the stream, doing some error correction.
 Vector readAnchors(String files)
          Reads the certificates from the files defined in the argument and makes TrustAnchors from them.
 Vector readCerts(String files)
          Reads the certificates from the files defined in the argument.
 Vector readCRLs(String files)
          Reads the certificate revocation lists (CRLs) from the files defined in the argument.
 Vector readFile(File certFile, int type)
          Reads the objects of given type from the File
 Object readObject(BufferedInputStream binStream, int type)
          Does the actual reading of the object.
 KeyStore readProxy(BufferedInputStream stream, String storePasswd)
           
static void skipEmptyLines(BufferedInputStream stream)
          Skips empty lines in the stream.
static void skipToCertBeginning(BufferedInputStream stream)
          Skips everything in front of "-----BEGIN" in the stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileCertReader

public FileCertReader()
               throws CertificateException
Creates a new instance of CertReader

Throws:
CertificateException

FileCertReader

public FileCertReader(Provider provider)
               throws CertificateException
Creates a new instance of CertReader with the specified provider

Parameters:
provider - the provider to be used in creating the certificates etc.
Throws:
CertificateException
Method Detail

readCerts

public Vector readCerts(String files)
                 throws Exception
Reads the certificates from the files defined in the argument. See DirectoryList for file definition format.

Parameters:
files - The file definition.
Returns:
Returns the Vector of certificates read.
Throws:
Exception - Thrown if certificate reading from the files fails.
See Also:
org.glite.security.util.DirectoryList

readAnchors

public Vector readAnchors(String files)
                   throws Exception
Reads the certificates from the files defined in the argument and makes TrustAnchors from them. See DirectoryList for file definition format.

Parameters:
files - The file definition.
Returns:
Returns a Vector of TrustAnchors read from the files.
Throws:
Exception - Thrown if the certificate reading fails.
See Also:
org.glite.security.util.DirectoryList

readCRLs

public Vector readCRLs(String files)
                throws Exception
Reads the certificate revocation lists (CRLs) from the files defined in the argument. See DirectoryList for file definition format.

Parameters:
files - The file definition.
Returns:
Returns a vector of CRLs read from the files.
Throws:
Exception - Thrown if the CRL reading failed.
See Also:
org.glite.security.util.DirectoryList

readFile

public Vector readFile(File certFile,
                       int type)
                throws Exception
Reads the objects of given type from the File

Parameters:
certFile - The file to read.
type - The type of objects to read form the file.
Returns:
Returns the Vector of objects read form the file.
Throws:
Exception - Thrown if the reading of objects of given type fails.

objectReader

public Object objectReader(BufferedInputStream binStream,
                           int type)
                    throws Exception
Reads a certificate or a CRL from the stream, doing some error correction.

Parameters:
binStream - The stream to read the object from.
type - The type of object to read from the stream.
Returns:
Returns the object read.
Throws:
Exception - Thrown if an error occurs while reading the object.

readObject

public Object readObject(BufferedInputStream binStream,
                         int type)
                  throws Exception
Does the actual reading of the object.

Parameters:
binStream - The stream to read the object from.
type - The type of the object.
Returns:
Returns the object read.
Throws:
Exception - Thrown if there is a problem reading the object.

skipToCertBeginning

public static void skipToCertBeginning(BufferedInputStream stream)
                                throws IOException
Skips everything in front of "-----BEGIN" in the stream.

Parameters:
stream - The stream to read and skip.
Throws:
IOException - Thrown if there is a problem skipping.

skipEmptyLines

public static void skipEmptyLines(BufferedInputStream stream)
                           throws IOException
Skips empty lines in the stream.

Parameters:
stream - The stream possibly containing empty lines.
Throws:
IOException - Thrown if a problem occurs.

readProxy

public KeyStore readProxy(BufferedInputStream stream,
                          String storePasswd)
                   throws IOException
Throws:
IOException


Copyright © 2001-2008 University of Southampton IT Innovation Centre. All Rights Reserved.