edu.sdsc.inca
Class AgentClient

java.lang.Object
  extended byedu.sdsc.inca.Component
      extended byedu.sdsc.inca.Client
          extended byedu.sdsc.inca.AgentClient

public class AgentClient
extends Client

This class allows access to the services provided by an Inca Agent. Along with defining an API that understands the Agent protocol, it defines a main method that allows access to an Agent via a telnet-style interface and provides a means for configuring an Inca installation from the command line.


Field Summary
static java.lang.String AGENT_CLIENT_OPTS
           
protected  java.lang.String deployPath
           
protected static org.apache.log4j.Logger logger
           
 
Fields inherited from class edu.sdsc.inca.Client
CLIENT_OPTS, host, port, reader, socket, writer
 
Fields inherited from class edu.sdsc.inca.Component
authenticate, cert, certPath, COMPONENT_OPTS, key, keyPath, logFile, password, trusted, trustedPath
 
Constructor Summary
AgentClient()
           
 
Method Summary
 java.util.Properties[] getCatalog(java.lang.String url)
          Returns properties for all reporters contained within one repository or all repositories known to the Agent.
 java.lang.String getCatalogAsXml(java.lang.String uri)
          Like getCatlog, but returns wraps the catalog information into XML instead of an array of Properties.
 java.lang.String getConfig()
          Returns IncaDocument XML for the Inca deployment configuration.
 java.lang.String getDeployPath()
          Returns the path to the IncaDocument XML deployment file.
static void main(java.lang.String[] args)
          A simple main method for exercising the AgentClient.
 void setConfig(java.lang.String config)
          Replaces or updates the Inca deployment configuration.
 void setConfiguration(java.util.Properties config)
          A convenience function for setting multiple configuration properties at once.
 void setDeployPath(java.lang.String path)
          Sets the path to the IncaDocument XML deployment file.
 
Methods inherited from class edu.sdsc.inca.Client
close, commandGetLog, commandLogConfig, commandPing, connect, dialog, getHost, getPort, getUri, isConnected, read, setHost, setPort, setServer, telnetDialog, write
 
Methods inherited from class edu.sdsc.inca.Component
addTrustedCert, configComponent, createSocket, getAuthenticate, getCertificate, getCertificatePath, getKey, getKeyPath, getLogFile, getPassword, getTrustedCertificates, getTrustedPath, openResourceStream, readCredentials, readVersion, setAuthenticate, setCertificatePath, setKeyPath, setLogFile, setPassword, setTrustedPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AGENT_CLIENT_OPTS

public static final java.lang.String AGENT_CLIENT_OPTS

logger

protected static final org.apache.log4j.Logger logger

deployPath

protected java.lang.String deployPath
Constructor Detail

AgentClient

public AgentClient()
Method Detail

getCatalog

public java.util.Properties[] getCatalog(java.lang.String url)
                                  throws java.io.IOException,
                                         ProtocolException
Returns properties for all reporters contained within one repository or all repositories known to the Agent.

Parameters:
url - the url of the repository to query; if null, a merged catalog from all repositories known to the Agent is returned
Returns:
an array of Properties, each of which represents the attributes of a single repository package
Throws:
java.io.IOException - on read/write error
ProtocolException - on an invalid message

getCatalogAsXml

public java.lang.String getCatalogAsXml(java.lang.String uri)
                                 throws java.io.IOException,
                                        ProtocolException
Like getCatlog, but returns wraps the catalog information into XML instead of an array of Properties. The outer tag of the XML is <catalog>, which returns 0 or more <reporter> subtags. Each of these contains zero or more <property> subtags, which list the property name and value in subtags.

Returns:
XML, described above, that gives the contents of the repository
Throws:
java.io.IOException - on read/write error
ProtocolException - on an invalid message

getConfig

public java.lang.String getConfig()
                           throws java.io.IOException,
                                  ProtocolException
Returns IncaDocument XML for the Inca deployment configuration.

Returns:
IncaDocument XML for the deployment configuration
Throws:
java.io.IOException - on read/write error
ProtocolException - on an invalid message

getDeployPath

public java.lang.String getDeployPath()
Returns the path to the IncaDocument XML deployment file.

Returns:
the path to the deployment file

setConfig

public void setConfig(java.lang.String config)
               throws java.io.IOException,
                      ProtocolException
Replaces or updates the Inca deployment configuration.

Parameters:
config - IncaDocument XML specifying changes in the configuration
Throws:
java.io.IOException - on read/write error
ProtocolException - on an invalid message

setConfiguration

public void setConfiguration(java.util.Properties config)
                      throws ConfigurationException
A convenience function for setting multiple configuration properties at once. In addition to the keys recognized by the superclass, recognizes: "agent", the specification of the Agent; "file", a path to an IncaDocument XML file.

Overrides:
setConfiguration in class Client
Parameters:
config - contains AgentClient configuration values
Throws:
ConfigurationException - on a faulty configuration property value

setDeployPath

public void setDeployPath(java.lang.String path)
Sets the path to the IncaDocument XML deployment file.

Parameters:
path - the path to the deployment file

main

public static void main(java.lang.String[] args)
A simple main method for exercising the AgentClient.
 usage: java inca.AgentClient
-a|--auth boolean Authenticated (secure) connection? -A|--agent str Agent specification; host:port -c|--cert path Path to the authentication certificate -f|--file path Inca installation configuration file path -h|--help null Print help/usage -i|--init path Path to properties file -k|--key path Path to the authentication key -P|--password str Specify how to obtain encryption password -t|--trusted path Path to authentication trusted certificate dir -V|--version null Display program version

Each of these properties, other than --init, can also be specified in the initialization file or in system properties defined via the -D switch. In each of these cases, the configuration name must be prefixed with "inca.agent.", e.g., use "inca.agent.cert" to specify the cert value. Command line arguments override any properties specified in this fashion. If --file is specified, the main method reads the specified file and sends it to the Agent in a setConfig message; otherwise, main allows the user to communicate with the Agent via a telnet-style interface. Supported values for the --password argument are: "no" or "false" (no encryption); "yes", "true", or "stdin:prompt" (read password from stdin after optionally prompting); "pass:text" (specify the password directly--should only be used for testing and, possibly, in the init file).

Parameters:
args - command line arguments, as above.