edu.vt.middleware.ldap.ssl
Class AbstractCredentialReader<T>

java.lang.Object
  extended by edu.vt.middleware.ldap.ssl.AbstractCredentialReader<T>
Type Parameters:
T - Type of credential read by this instance.
All Implemented Interfaces:
CredentialReader<T>
Direct Known Subclasses:
KeyStoreCredentialReader, PrivateKeyCredentialReader, X509CertificateCredentialReader, X509CertificatesCredentialReader

public abstract class AbstractCredentialReader<T>
extends Object
implements CredentialReader<T>

Base class for all credential readers. It provides support for loading files from resources on the classpath or a filepath. If a path is prefixed with the string "classpath:" it is interpreted as a classpath specification. If a path is prefixed with the string "file:" it is interpreted as a file path. Any other input throws IllegalArgumentException.

Version:
$Revision$
Author:
Middleware Services

Field Summary
static String CLASSPATH_PREFIX
          Prefix used to indicate a classpath resource.
static String FILE_PREFIX
          Prefix used to indicate a file resource.
protected  org.apache.commons.logging.Log logger
          Log for this class.
 
Constructor Summary
AbstractCredentialReader()
           
 
Method Summary
protected  InputStream getBufferedInputStream(InputStream is)
          Gets a buffered input stream from the given input stream.
abstract  T read(InputStream is, String... params)
          Reads a credential object from an input stream.
 T read(String path, String... params)
          Reads a credential object from a path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASSPATH_PREFIX

public static final String CLASSPATH_PREFIX
Prefix used to indicate a classpath resource.

See Also:
Constant Field Values

FILE_PREFIX

public static final String FILE_PREFIX
Prefix used to indicate a file resource.

See Also:
Constant Field Values

logger

protected final org.apache.commons.logging.Log logger
Log for this class.

Constructor Detail

AbstractCredentialReader

public AbstractCredentialReader()
Method Detail

read

public T read(String path,
              String... params)
       throws IOException,
              GeneralSecurityException
Reads a credential object from a path.

Specified by:
read in interface CredentialReader<T>
Parameters:
path - Path from which to read credential.
params - Arbitrary string parameters, e.g. password, needed to read the credential.
Returns:
Credential read from data at path.
Throws:
IOException - On IO errors.
GeneralSecurityException - On errors with the credential data.

read

public abstract T read(InputStream is,
                       String... params)
                throws IOException,
                       GeneralSecurityException
Reads a credential object from an input stream.

Specified by:
read in interface CredentialReader<T>
Parameters:
is - Input stream from which to read credential.
params - Arbitrary string parameters, e.g. password, needed to read the credential.
Returns:
Credential read from data in stream.
Throws:
IOException - On IO errors.
GeneralSecurityException - On errors with the credential data.

getBufferedInputStream

protected InputStream getBufferedInputStream(InputStream is)
Gets a buffered input stream from the given input stream. If the given instance is already buffered, it is simply returned.

Parameters:
is - Input stream from which to create buffered instance.
Returns:
Buffered input stream. If the given instance is already buffered, it is simply returned.


Copyright © 2003-2010 Virginia Tech. All Rights Reserved.