public final class CASClient extends BaseCASClient
CASClient client = new CASClient(); client.setHost("myhost"); client.setPort(10738)And setup the action parameters and invoke the action:
CASActionOptions options = new CASActionOptions(); options.setActionSetName("builtins"); options.setActionName("serverstatus");Then invoke the action and process the results:
CASActionResults<CASValue> results = client.invoke(options); // Print all events generated by the action BaseSample.printEvents(results); // Print all results generated by the action BaseSample.printResultValues(results);This class should not be assumed to be thread safe.
BaseCASClient.AUTH_METHOD
Constructor and Description |
---|
CASClient()
Instantiate a new CASClient.
|
CASClient(CASClient client)
Copy constructor.
|
CASClient(CASClient client,
boolean includeSessionID)
Copy constructor.
|
CASClient(java.lang.String host,
int port)
Instantiates a new CASClient with the given connection information.
|
CASClient(java.lang.String host,
int port,
java.lang.String userName,
java.lang.String password)
Instantiates a new CASClient with the given connection information.
|
Modifier and Type | Method and Description |
---|---|
protected com.sas.cas.proto.CASClientProto.Request |
buildRequest(CASActionOptions options) |
void |
close()
Closes the current connection, if any, to the server.
|
void |
close(boolean endSession)
Closes the current connection, if any, to the server.
|
CASClientInterface |
copy(boolean includeSessionID)
Creates a copy of the current object with the same settings.
|
protected boolean |
equals(java.lang.String s1,
java.lang.String s2)
Returns true if both strings are equal, or both strings are null.
|
protected CASActionResults<com.sas.cas.proto.CASClientProto.Value> |
getActions(CASActionOptions options)
Uses reflection to get the action parameters.
|
CASAuthenticatedUserEventListener |
getAuthenticatedUserEventListener()
Returns the current authenticated user event listener.
|
CASAuthenticatedUserInfo |
getAuthenticatedUserInfo()
Gets information about the authenticated user.
|
java.lang.String[] |
getBackupHosts()
Gets the list of backup hosts in the format host:port.
|
java.lang.String |
getHost() |
protected long |
getLastActivityTime()
Gets the time of the last activity.
|
java.lang.String |
getLocale() |
static java.lang.String |
getMessage(java.lang.Throwable ex)
Gets an exception message.
|
int |
getNumberOfNodes() |
int |
getPort() |
java.lang.String |
getRecordingInputFileName() |
java.lang.String |
getRecordingOutputFileName() |
CASServerInfo |
getServerInfo()
Gets information about the current server.
|
java.lang.String |
getSessionID()
Gets the session ID associated with this client.
|
CASSocketAttemptEventListener |
getSocketAttemptEventListener() |
CASSocketEventListener |
getSocketEventListener()
Returns the current socket event listener.
|
int |
getSocketRetries() |
CASSSLSocketEventListener |
getSSLSocketEventListener()
Returns the current SSL socket event listener.
|
java.lang.String |
getUserName()
Gets the user name which may have been set prior to authentication.
|
java.lang.Object |
getUserProperty(java.lang.String key)
Returns the user property associated with the given key.
|
java.util.Iterator<java.lang.String> |
getUserPropertyKeys()
Returns an iterator of user property keys.
|
CASActionResults<CASValue> |
invoke(CASActionOptions options,
com.sas.cas.proto.CASClientProto.Request request)
Invokes an action on the server
|
protected CASActionResults<com.sas.cas.proto.CASClientProto.Value> |
invoke(CASActionOptions options,
com.sas.cas.proto.CASClientProto.Request request,
com.sas.cas.CASClient.ResultValueHandler handler,
boolean reconnect) |
protected CASActionResults<CASValue> |
invokeInternal(CASActionOptions options) |
static boolean |
isActionRestart(com.sas.cas.proto.CASClientProto.Response response) |
boolean |
isClosed()
Returns true if the current connection is closed, or a connection has not been established.
|
boolean |
isCommunicationEncrypted() |
CASClient |
setAuthenticatedUserEventListener(CASAuthenticatedUserEventListener authenticatedUserEventListener)
Sets the authenticated user event listener that will be called when a user has
been authenticated with the server.
|
CASClient |
setBackupHosts(java.lang.String hosts)
Sets the backup CAS host name(s).
|
CASClient |
setBackupHosts(java.lang.String[] hosts)
Sets the backup CAS host name(s).
|
CASClient |
setHost(java.lang.String host)
Sets the target CAS host.
|
CASClient |
setLocale(java.lang.String locale)
Sets the client locale.
|
CASClient |
setNumberOfNodes(int numberOfNodes)
Sets the number of nodes to use on the target server.
|
CASClient |
setPassword(java.lang.String password)
Sets the user password used with authentication to the CAS instance.
|
CASClient |
setPort(int port)
Sets the target CAS port.
|
CASClient |
setProperties(CASClient client)
Sets the properties from an existing client.
|
CASClient |
setProperties(CASClient client,
boolean includeSessionID)
Sets the properties from an existing client.
|
CASClient |
setRecordingInputFileName(java.lang.String recordingInputFileName)
Sets the name of the input recording file name.
|
CASClient |
setRecordingOutputFileName(java.lang.String recordingOutputFileName)
Sets the name of the output recording file name.
|
CASClient |
setSessionID(java.lang.String sessionID)
Sets the session ID used with authentication to the CAS instance.
|
CASClient |
setSocketAttemptEventListener(CASSocketAttemptEventListener socketAttemptEventListener)
Sets the socket attempt event lisetener that will be called when new socket connections
are being attempted.
|
CASClient |
setSocketEventListener(CASSocketEventListener socketListener)
Sets the socket event listener that will be called when new socket connections have
been established and sockets are being closed.
|
CASClient |
setSocketRetries(int socketRetries)
Sets the number of times a connection to a server will be retried before failing.
|
CASClient |
setSSLSocketEventListener(CASSSLSocketEventListener sslSocketEventListener)
Sets the SSL socket event listener that will be called when a new SSL socket connection
is created.
|
CASClient |
setUserName(java.lang.String userName)
Sets the user name used with authentication to the CAS instance.
|
CASClient |
setUserProperty(java.lang.String key,
java.lang.Object value)
Sets a user property.
|
addActionEventListener, addEventListener, addExceptionHandler, addLogEventListener, batchAction, cancelAction, checkAuthMethod, checkDispositions, copy, copy, fireAndSetDispositionEvents, fireAndSetDispositionEvents, fireAndSetLogEvents, fireAndSetLogEvents, fireAndSetPerformanceEvents, fireAndSetPerformanceEvents, fireGlobalLogEvent, getActionEventListeners, getActions, getActionSets, getAutoCloseTimeout, getClientContext, getDispositionEventListener, getEventListeners, getExceptionHandler, getExceptionHandlerKeys, getLogEventListener, getLogEventListeners, getObjectFactories, getPerformanceEventListener, getSecurityToken, getSecurityTokenProvider, getTableAttributes, invoke, invoke, loadActionSet, removeActionEventListener, removeEventListener, removeExceptionHandler, removeLogEventListener, setAsActiveClientContext, setAutoCloseTimeout, setClientContext, setDispositionEventListener, setLogEventListener, setPerformanceEventListener, setSecurityToken, setSecurityTokenProvider, shutdown, stopAction, toDispositionEvent, toLogEvent, toPerformanceEvent
public CASClient()
public CASClient(java.lang.String host, int port)
host
- The CAS hostport
- The CAS portpublic CASClient(java.lang.String host, int port, java.lang.String userName, java.lang.String password)
host
- The CAS hostport
- The CAS portuserName
- The user namepassword
- The user passwordpublic CASClient(CASClient client)
client
- The source CASClientpublic CASClient(CASClient client, boolean includeSessionID)
client
- The source CASClientpublic CASClient setProperties(CASClient client)
client
- The clientpublic CASClient setProperties(CASClient client, boolean includeSessionID)
includeSessionID
- True to include the session IDclient
- The clientpublic java.lang.String getHost()
public CASClient setHost(java.lang.String host)
host
- The host name or addresspublic CASClient setBackupHosts(java.lang.String hosts)
hosts
- The host name(s)public CASClient setBackupHosts(java.lang.String[] hosts)
hosts
- The array of host name(s)public java.lang.String[] getBackupHosts()
public boolean isCommunicationEncrypted()
public int getPort()
public CASClient setPort(int port)
port
- The portpublic int getNumberOfNodes()
public CASClient setNumberOfNodes(int numberOfNodes)
numberOfNodes
- The number of nodes, or 0 for allpublic java.lang.String getUserName()
CASClientInterface
public CASClient setUserName(java.lang.String userName)
userName
- The user namepublic CASClient setPassword(java.lang.String password)
password
- The passwordpublic java.lang.String getSessionID()
CASClientInterface
public CASClient setSessionID(java.lang.String sessionID)
sessionID
- The session IDpublic java.lang.String getLocale()
public CASClient setLocale(java.lang.String locale)
locale
- The locale, or null to use the server default.public java.lang.String getRecordingOutputFileName()
public CASClient setRecordingOutputFileName(java.lang.String recordingOutputFileName)
recordingOutputFileName
- The output file namepublic java.lang.String getRecordingInputFileName()
public CASClient setRecordingInputFileName(java.lang.String recordingInputFileName) throws java.io.IOException
recordingInputFileName
- The input file namejava.io.IOException
public CASAuthenticatedUserInfo getAuthenticatedUserInfo()
CASClientInterface
public CASServerInfo getServerInfo()
CASClientInterface
public CASClientInterface copy(boolean includeSessionID)
CASClientInterface
includeSessionID
- True to include the session IDpublic int getSocketRetries()
public CASClient setSocketRetries(int socketRetries)
socketRetries
- The number of retriesprotected boolean equals(java.lang.String s1, java.lang.String s2)
s1
- The first strings2
- The second stringpublic CASSocketEventListener getSocketEventListener()
public CASClient setSocketEventListener(CASSocketEventListener socketListener)
socketListener
- The socket listenerpublic CASSSLSocketEventListener getSSLSocketEventListener()
public CASClient setSSLSocketEventListener(CASSSLSocketEventListener sslSocketEventListener)
sslSocketEventListener
- The SSL socket listenerpublic CASSocketAttemptEventListener getSocketAttemptEventListener()
public CASClient setSocketAttemptEventListener(CASSocketAttemptEventListener socketAttemptEventListener)
socketAttemptEventListener
- The listenerpublic CASAuthenticatedUserEventListener getAuthenticatedUserEventListener()
public CASClient setAuthenticatedUserEventListener(CASAuthenticatedUserEventListener authenticatedUserEventListener)
authenticatedUserEventListener
- The listenerpublic CASClient setUserProperty(java.lang.String key, java.lang.Object value)
key
- The property keyvalue
- The property value, or null to remove the keypublic java.lang.Object getUserProperty(java.lang.String key)
key
- The property keypublic java.util.Iterator<java.lang.String> getUserPropertyKeys()
public static java.lang.String getMessage(java.lang.Throwable ex)
ex
- The exceptionprotected CASActionResults<com.sas.cas.proto.CASClientProto.Value> getActions(CASActionOptions options) throws CASException, java.io.IOException
BaseCASClient
getActions
in class BaseCASClient
options
- The optionsCASException
java.io.IOException
protected CASActionResults<CASValue> invokeInternal(CASActionOptions options) throws CASException, java.io.IOException
invokeInternal
in class BaseCASClient
CASException
java.io.IOException
public CASActionResults<CASValue> invoke(CASActionOptions options, com.sas.cas.proto.CASClientProto.Request request) throws CASException, java.io.IOException
options
- The action optionsrequest
- The protobuf requestCASException
java.io.IOException
public boolean isClosed()
CASClientInterface
public void close(boolean endSession) throws CASException, java.io.IOException
CASClientInterface
close
in interface CASClientInterface
close
in class BaseCASClient
endSession
- true to end the server sessionCASException
java.io.IOException
public void close() throws CASException, java.io.IOException
CASClientInterface
close
in interface CASClientInterface
close
in interface java.lang.AutoCloseable
close
in class BaseCASClient
CASException
java.io.IOException
protected com.sas.cas.proto.CASClientProto.Request buildRequest(CASActionOptions options)
public static boolean isActionRestart(com.sas.cas.proto.CASClientProto.Response response)
protected CASActionResults<com.sas.cas.proto.CASClientProto.Value> invoke(CASActionOptions options, com.sas.cas.proto.CASClientProto.Request request, com.sas.cas.CASClient.ResultValueHandler handler, boolean reconnect) throws CASException, java.io.IOException
CASException
java.io.IOException
protected long getLastActivityTime()
BaseCASClient
getLastActivityTime
in class BaseCASClient