|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.sdsc.inca.Component
public class Component
This class encapsulates the common behavior of the Client and Server classes.
Field Summary | |
---|---|
protected boolean |
authenticate
|
protected java.security.cert.Certificate |
cert
|
protected java.lang.String |
certPath
|
static java.lang.String |
COMPONENT_OPTS
|
protected java.lang.String |
hostname
|
protected java.security.KeyPair |
key
|
protected java.lang.String |
keyPath
|
protected java.lang.String |
logFile
|
protected static org.apache.log4j.Logger |
logger
|
protected java.lang.String |
password
|
protected int |
port
|
protected java.util.Vector |
trusted
|
protected java.lang.String |
trustedPath
|
Constructor Summary | |
---|---|
Component()
|
Method Summary | |
---|---|
void |
addTrustedCert(java.security.cert.Certificate trusted)
Add a single trusted certificate. |
static void |
configComponent(Component c,
java.lang.String[] args,
java.lang.String opts,
java.lang.String prefix,
java.lang.String exec,
java.lang.String versionFilename)
A convenience function for configuring a Component (or descendent class) from the system properties, the arguments passed to main, and the properties file. |
protected java.lang.Object |
createSocket(boolean serverSocket,
java.lang.String host,
int port)
Creates and returns a socket with any appropriate authentication. |
boolean |
getAuthenticate()
Is the connection authenticated? |
java.security.cert.Certificate |
getCertificate()
Returns the component certificate. |
java.lang.String |
getCertificatePath()
Returns the path to the component certificate. |
static java.lang.String |
getDn(java.net.Socket s,
boolean peer)
Returns the DN from one end of a secure connection. |
java.lang.String |
getHostname()
Returns the name of the host where the server is running. |
java.security.KeyPair |
getKey()
Returns the component key. |
java.lang.String |
getKeyPath()
Returns the path to the component private key. |
java.lang.String |
getLogFile()
Returns the path to the file where the component writes log messages. |
java.lang.String |
getPassword()
Gets the component encryption password. |
int |
getPort()
Returns the port where the Server is listening. |
java.security.cert.Certificate[] |
getTrustedCertificates()
Returns the set of certificates trusted by the component. |
java.lang.String |
getTrustedPath()
Get the path to the component trusted certificate directory. |
java.lang.String |
getUri()
Return the uri for the server. |
static java.io.InputStream |
openResourceStream(java.lang.String resourcePath)
Returns an input stream for a resource found either in the classpath or on the file system. |
void |
readCredentials()
Read in the credentials using the paths to the credentials and passphrase. |
static java.lang.String |
readVersion(java.lang.String versionFilename)
Read the version for the component from a file in the classpath. |
void |
setAuthenticate(boolean authenticate)
Determines whether or not the connection is authenticated. |
void |
setCertificatePath(java.lang.String path)
Sets the path to the file that contains the component certificate. |
void |
setConfiguration(java.util.Properties config)
A convenience function for setting multiple Component configuration properties at once. |
void |
setHostname(java.lang.String hostname)
Sets the name of the host where the server is running. |
void |
setKeyPath(java.lang.String path)
Sets the path to the file that contains the component private key. |
void |
setLogFile(java.lang.String path)
Sets the path to the file where the component writes log messages. |
void |
setPassword(java.lang.String password)
Sets the component encryption password. |
void |
setPort(int port)
Set the port to bind to. |
void |
setTrustedPath(java.lang.String path)
Set the trusted certificates to the contents of the directory given. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String COMPONENT_OPTS
protected static final org.apache.log4j.Logger logger
protected boolean authenticate
protected java.lang.String certPath
protected java.lang.String hostname
protected java.lang.String keyPath
protected java.lang.String logFile
protected java.lang.String password
protected int port
protected java.lang.String trustedPath
protected java.security.cert.Certificate cert
protected java.security.KeyPair key
protected java.util.Vector trusted
Constructor Detail |
---|
public Component()
Method Detail |
---|
public void addTrustedCert(java.security.cert.Certificate trusted)
trusted
- the certificate to addpublic boolean getAuthenticate()
public java.security.cert.Certificate getCertificate()
public java.lang.String getCertificatePath()
public static java.lang.String getDn(java.net.Socket s, boolean peer)
s
- the connectionpeer
- indicates whether the local or peer DN is desired
public java.lang.String getHostname()
public java.security.KeyPair getKey()
public java.lang.String getKeyPath()
public java.lang.String getLogFile()
public java.lang.String getPassword()
public int getPort()
public java.security.cert.Certificate[] getTrustedCertificates()
public java.lang.String getTrustedPath()
public java.lang.String getUri()
public void setAuthenticate(boolean authenticate)
authenticate
- authenticate the connection?public void setCertificatePath(java.lang.String path)
path
- path to the certificate filepublic void setConfiguration(java.util.Properties config) throws ConfigurationException
config
- contains configuration values
ConfigurationException
- on a faulty configuration property valuepublic void setHostname(java.lang.String hostname)
hostname
- A string containing the hostname of the serverpublic void setKeyPath(java.lang.String path)
path
- path to the private key filepublic void setLogFile(java.lang.String path) throws ConfigurationException
path
- the path to the log file
ConfigurationException
- if the path is not writablepublic void setPassword(java.lang.String password)
password
- the encryption passwordpublic void setPort(int port)
port
- port numberpublic void setTrustedPath(java.lang.String path)
path
- the trusted certificate directory pathprotected java.lang.Object createSocket(boolean serverSocket, java.lang.String host, int port) throws ConfigurationException, java.io.IOException
serverSocket
- determines whether the return value is a Socket or
a ServerSockethost
- the server host for client sockets; ignored for serversport
- the port to open (Server) or connect to (Clients)
ConfigurationException
- if a config attribute has a bad value
java.io.IOException
- on socket creation failurepublic void readCredentials() throws ConfigurationException, java.io.IOException
ConfigurationException
- if problem finding credential properties
java.io.IOException
- if problem reading credentialspublic static java.lang.String readVersion(java.lang.String versionFilename)
versionFilename
- The filename of the version file in the classpath
public static java.io.InputStream openResourceStream(java.lang.String resourcePath)
resourcePath
- the path (relative or absolute) to the resource
public static void configComponent(Component c, java.lang.String[] args, java.lang.String opts, java.lang.String prefix, java.lang.String exec, java.lang.String versionFilename) throws ConfigurationException, java.io.IOException
c
- the component to configureargs
- command-line argumentsopts
- valid command-line optionsprefix
- property prefix from system props and property fileexec
- main class nameversionFilename
- classpath filename containing the version
ConfigurationException
- on faulty config properties
java.io.IOException
- on an unreadable file property
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |