|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.sdsc.inca.Component edu.sdsc.inca.Client
public class Client
This class implements the functionality common to all Inca client classes. Along with defining an API that understands the Server protocol, it defines a main method that allows access to a Server via a telnet-style interface.
Field Summary | |
---|---|
static java.lang.String |
CLIENT_OPTS
|
protected static org.apache.log4j.Logger |
logger
|
protected ProtocolReader |
reader
|
protected java.net.Socket |
socket
|
protected ProtocolWriter |
writer
|
Fields inherited from class edu.sdsc.inca.Component |
---|
authenticate, cert, certPath, COMPONENT_OPTS, hostname, key, keyPath, logFile, password, port, trusted, trustedPath |
Constructor Summary | |
---|---|
Client()
|
Method Summary | |
---|---|
void |
close()
Close the client socket to the server. |
java.lang.String |
commandGetLog()
Retrieve the text in the server's log file, if any. |
void |
commandLogConfig(java.lang.String data)
Send a log config message to the server. |
java.lang.String |
commandPing(java.lang.String data)
Send a ping to the server and return the response data. |
void |
connect()
Establish a connection to the server. |
protected java.lang.String |
dialog(java.lang.String command,
java.lang.String data)
Sends a statement to the server and returns the data from a successful response. |
boolean |
isConnected()
Query whether the client is presently connected. |
static void |
main(java.lang.String[] args)
A simple main method for exercising the Client. |
Statement |
read()
Read the next statement from the server. |
void |
setConfiguration(java.util.Properties config)
A convenience function for setting multiple configuration properties at once. |
void |
setServer(java.lang.String server,
int defaultPort)
Sets the host and port of the server to contact. |
static void |
telnetDialog(Client c,
java.lang.String prompt)
Allows the user to use a client via a telnet-style interface. |
void |
write(Statement statement)
Write a statement to the server. |
Methods inherited from class edu.sdsc.inca.Component |
---|
addTrustedCert, configComponent, createSocket, getAuthenticate, getCertificate, getCertificatePath, getHostname, getKey, getKeyPath, getLogFile, getPassword, getPort, getTrustedCertificates, getTrustedPath, getUri, openResourceStream, readCredentials, readVersion, setAuthenticate, setCertificatePath, setHostname, setKeyPath, setLogFile, setPassword, setPort, setTrustedPath |
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 CLIENT_OPTS
protected static org.apache.log4j.Logger logger
protected java.net.Socket socket
protected ProtocolReader reader
protected ProtocolWriter writer
Constructor Detail |
---|
public Client()
Method Detail |
---|
public void close()
public java.lang.String commandGetLog() throws java.io.IOException, ProtocolException
java.io.IOException
- on read/write error
ProtocolException
- on an invalid messagepublic void commandLogConfig(java.lang.String data) throws java.io.IOException, ProtocolException
data
- a log4j setting of the form property=value
java.io.IOException
- on read/write error
ProtocolException
- on an invalid messagepublic java.lang.String commandPing(java.lang.String data) throws java.io.IOException, ProtocolException
data
- the ping message data
java.io.IOException
- on read/write error
ProtocolException
- on an invalid messagepublic void connect() throws ConfigurationException, java.io.IOException
ConfigurationException
- if the configuration settings are invalid
java.io.IOException
- if the attempt to contact the server failspublic boolean isConnected()
public Statement read() throws java.io.IOException, ProtocolException
java.io.IOException
- on read error
ProtocolException
- on an invalid messagepublic void setConfiguration(java.util.Properties config) throws ConfigurationException
setConfiguration
in class Component
config
- contains client configuration values
ConfigurationException
- on a faulty configuration property valuepublic void setServer(java.lang.String server, int defaultPort)
server
- contact spec of the form [protocol://]host[:port]defaultPort
- port to contact if server contains nonepublic void write(Statement statement) throws java.io.IOException
statement
- the statement to write
java.io.IOException
- on write failureprotected java.lang.String dialog(java.lang.String command, java.lang.String data) throws java.io.IOException, ProtocolException
command
- the command to senddata
- the data to accompany the command
java.io.IOException
- on read failure
ProtocolException
- if a failure message is receivedpublic static void telnetDialog(Client c, java.lang.String prompt)
c
- the client to useprompt
- the user promptpublic static void main(java.lang.String[] args)
usage:java inca.Client
-a|--auth boolean Authenticated (secure) connection? -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 -S|--server str Server specification; host:port -t|--trusted path Path to authentication trusted certificate dir -V|--version null Display program version
args
- command line arguments, as above.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |