public class Connection extends java.util.TimerTask implements MachineObserver
Constructor and Description |
---|
Connection(Messenger messenger,
int handle)
Creates the connection.
|
Modifier and Type | Method and Description |
---|---|
void |
closeSession()
Closes the session.
|
void |
connect(java.net.InetAddress address,
int pingPeriod)
Starts the connection to the specified
InetAddress |
void |
disconnect()
Ends the connection.
|
java.util.List<CipherSuite> |
getAvailableCipherSuites(int tag)
Gets from the managed system supported
CipherSuite s. |
GetChannelAuthenticationCapabilitiesResponseData |
getChannelAuthenticationCapabilities(int tag,
CipherSuite cipherSuite,
PrivilegeLevel requestedPrivilegeLevel)
Queries the managed system for the details of the authentification
process.
|
int |
getHandle() |
java.net.InetAddress |
getRemoteMachineAddress() |
int |
getTimeout() |
boolean |
isActive()
Checks if the connection is active
|
boolean |
isSessionValid()
Checks if session is currently open.
|
void |
notify(StateMachineAction action)
Notifies observer of action performed by the State Machine.
|
void |
notifyListeners(int handle,
int tag,
ResponseData responseData,
java.lang.Exception exception) |
void |
registerListener(ConnectionListener listener)
Registers the listener so it will receive notifications from this
connection
|
int |
retry(int tag,
int maxAllowedRetries)
Deprecated.
|
void |
run()
TimerTask runner - periodically sends no-op messages to keep the
session up |
int |
sendIpmiCommand(IpmiCommandCoder commandCoder)
Attempts to send IPMI request to the managed system.
|
void |
setTimeout(int timeout) |
void |
startSession(int tag,
CipherSuite cipherSuite,
PrivilegeLevel privilegeLevel,
java.lang.String username,
java.lang.String password,
byte[] bmcKey)
Initiates the session with the managed system.
|
void |
unregisterListener(ConnectionListener listener)
Unregisters the
ConnectionListener |
public Connection(Messenger messenger, int handle) throws java.io.FileNotFoundException, java.io.IOException
messenger
- - Messenger
associated with the proper
Constants.IPMI_PORT
handle
- - id of the connectionjava.io.IOException
- - when properties file was not foundjava.io.FileNotFoundException
- - when properties file was not foundpublic int getHandle()
public int getTimeout()
public void setTimeout(int timeout)
public void registerListener(ConnectionListener listener)
listener
- - ConnectionListener
to notifypublic void unregisterListener(ConnectionListener listener)
ConnectionListener
listener
- ConnectionListener
to unregisterpublic void connect(java.net.InetAddress address, int pingPeriod) throws java.io.FileNotFoundException, java.io.IOException
InetAddress
address
- - IP address of the managed systempingPeriod
- - frequency of the no-op commands that will be sent to keep up
the sessionjava.io.IOException
- - when properties file was not foundjava.io.FileNotFoundException
- - when properties file was not founddisconnect()
public void disconnect()
connect(InetAddress, int)
public boolean isActive()
connect(InetAddress, int)
,
disconnect()
public java.util.List<CipherSuite> getAvailableCipherSuites(int tag) throws java.lang.Exception
CipherSuite
s. Should be
performed only immediately after connect(InetAddress, int)
.tag
- - the integer from range 0-63 to match request with responseCipherSuite
s supported by the managed system.ConnectionException
- when connection is in the state that does not allow to
perform this operation.java.lang.Exception
- when sending message to the managed system failspublic GetChannelAuthenticationCapabilitiesResponseData getChannelAuthenticationCapabilities(int tag, CipherSuite cipherSuite, PrivilegeLevel requestedPrivilegeLevel) throws java.lang.Exception
getAvailableCipherSuites(int)
tag
- - the integer from range 0-63 to match request with responsecipherSuite
- - CipherSuite
requested for the sessionrequestedPrivilegeLevel
- - PrivilegeLevel
requested for the sessionGetChannelAuthenticationCapabilitiesResponseData
ConnectionException
- when connection is in the state that does not allow to
perform this operation.java.lang.Exception
- when sending message to the managed system failspublic void startSession(int tag, CipherSuite cipherSuite, PrivilegeLevel privilegeLevel, java.lang.String username, java.lang.String password, byte[] bmcKey) throws java.lang.Exception
getChannelAuthenticationCapabilities(int, CipherSuite, PrivilegeLevel)
or closeSession()
tag
- - the integer from range 0-63 to match request with responsecipherSuite
- - CipherSuite
that will be used during the sessionprivilegeLevel
- - requested PrivilegeLevel
- most of the time it will
be PrivilegeLevel.User
username
- - the usernamepassword
- - the password matching the usernamebmcKey
- - the key that should be provided if the two-key
authentication is enabled, null otherwise.ConnectionException
- when connection is in the state that does not allow to
perform this operation.java.lang.Exception
- when sending message to the managed system or initializing
one of the cipherSuite's algorithms failspublic void closeSession() throws ConnectionException
ConnectionException
- when connection is in the state that does not allow to
perform this operation.public int sendIpmiCommand(IpmiCommandCoder commandCoder) throws ConnectionException, java.lang.ArithmeticException
commandCoder
- - IpmiCommandCoder
representing the requestConnectionException
- when connection isn't in state where sending commands is
allowedjava.lang.ArithmeticException
- when Connection
runs out of available ID's for the
messages. If this happens session needs to be restarted.@Deprecated public int retry(int tag, int maxAllowedRetries) throws java.lang.ArithmeticException, ConnectionException
tag
- - tag of the message to retrymaxAllowedRetries
- - maximum number of retries that are allowed to be performedConnectionException
- when connection isn't in state where sending commands is
allowedjava.lang.ArithmeticException
- when Connection
runs out of available ID's for the
messages. If this happens session needs to be restarted.public void notifyListeners(int handle, int tag, ResponseData responseData, java.lang.Exception exception)
public void notify(StateMachineAction action)
MachineObserver
notify
in interface MachineObserver
action
- - action performedpublic void run()
TimerTask
runner - periodically sends no-op messages to keep the
session uprun
in interface java.lang.Runnable
run
in class java.util.TimerTask
public java.net.InetAddress getRemoteMachineAddress()
public boolean isSessionValid()