Package edu.vt.middleware.ldap.ssl
Class AbstractCredentialReader<T>
- java.lang.Object
-
- 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 java.lang.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
Fields Modifier and Type Field Description static java.lang.String
CLASSPATH_PREFIX
Prefix used to indicate a classpath resource.static java.lang.String
FILE_PREFIX
Prefix used to indicate a file resource.protected org.apache.commons.logging.Log
logger
Log for this class.
-
Constructor Summary
Constructors Constructor Description AbstractCredentialReader()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.io.InputStream
getBufferedInputStream(java.io.InputStream is)
Gets a buffered input stream from the given input stream.abstract T
read(java.io.InputStream is, java.lang.String... params)
Reads a credential object from an input stream.T
read(java.lang.String path, java.lang.String... params)
Reads a credential object from a path.
-
-
-
Field Detail
-
CLASSPATH_PREFIX
public static final java.lang.String CLASSPATH_PREFIX
Prefix used to indicate a classpath resource.- See Also:
- Constant Field Values
-
FILE_PREFIX
public static final java.lang.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.
-
-
Method Detail
-
read
public T read(java.lang.String path, java.lang.String... params) throws java.io.IOException, java.security.GeneralSecurityException
Reads a credential object from a path.- Specified by:
read
in interfaceCredentialReader<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:
java.io.IOException
- On IO errors.java.security.GeneralSecurityException
- On errors with the credential data.
-
read
public abstract T read(java.io.InputStream is, java.lang.String... params) throws java.io.IOException, java.security.GeneralSecurityException
Reads a credential object from an input stream.- Specified by:
read
in interfaceCredentialReader<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:
java.io.IOException
- On IO errors.java.security.GeneralSecurityException
- On errors with the credential data.
-
getBufferedInputStream
protected java.io.InputStream getBufferedInputStream(java.io.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.
-
-