public class IpmiAsyncConnector extends java.lang.Object implements ConnectionListener
Asynchronous API for connecting to BMC via IPMI.
Creating connection consists of the following steps:
Connection
and get associated with it
ConnectionHandle
via createConnection(InetAddress)
CipherSuite
s that are available for the connection via
getAvailableCipherSuites(ConnectionHandle)
CipherSuite
and PrivilegeLevel
that will be used
during session and get
GetChannelAuthenticationCapabilitiesResponseData
to find out allowed
authentication options via
getChannelAuthenticationCapabilities(ConnectionHandle, CipherSuite, PrivilegeLevel)
openSession(ConnectionHandle, String, String, byte[])
To send message register for receiving answers via
registerListener(IpmiListener)
and send message via
sendMessage(ConnectionHandle, IpmiCommandCoder)
To close session call closeSession(ConnectionHandle)
Constructor and Description |
---|
IpmiAsyncConnector(int port)
Starts
IpmiAsyncConnector and initiates the
ConnectionManager at the given port. |
IpmiAsyncConnector(int port,
java.net.InetAddress address)
Starts
IpmiAsyncConnector and initiates the
ConnectionManager at the given port and IP interface. |
Modifier and Type | Method and Description |
---|---|
void |
closeConnection(ConnectionHandle handle)
Closes the connection with the given handle
|
void |
closeSession(ConnectionHandle connectionHandle)
Closes the session with the remote host if it is currently in open state.
|
ConnectionHandle |
createConnection(java.net.InetAddress address)
Creates connection to the remote host.
|
java.util.List<CipherSuite> |
getAvailableCipherSuites(ConnectionHandle connectionHandle)
Gets
CipherSuite s available for the connection with the remote
host. |
GetChannelAuthenticationCapabilitiesResponseData |
getChannelAuthenticationCapabilities(ConnectionHandle connectionHandle,
CipherSuite cipherSuite,
PrivilegeLevel requestedPrivilegeLevel)
Gets the authentication capabilities for the connection with the remote
host.
|
void |
notify(ResponseData responseData,
int handle,
int tag,
java.lang.Exception exception)
Notifies the
ConnectionListener s of the one of the following
events: response to the request tagged with id arrived request
tagged with id timed out |
void |
openSession(ConnectionHandle connectionHandle,
java.lang.String username,
java.lang.String password,
byte[] bmcKey)
Establishes the session with the remote host.
|
void |
registerListener(IpmiListener listener)
Registers the listener so it will be notified of incoming messages.
|
int |
sendMessage(ConnectionHandle connectionHandle,
IpmiCommandCoder request)
Sends the IPMI message to the remote host.
|
void |
tearDown()
Finalizes the connector and closes all connections.
|
void |
unregisterListener(IpmiListener listener)
Unregisters the listener so it will no longer receive notifications of
received answers.
|
public IpmiAsyncConnector(int port) throws java.io.IOException
IpmiAsyncConnector
and initiates the
ConnectionManager
at the given port. The wildcard IP address will
be used.port
- - the port that will be used by IpmiAsyncConnector
to
communicate with the remote hosts.java.io.IOException
- when properties file was not foundpublic IpmiAsyncConnector(int port, java.net.InetAddress address) throws java.io.IOException
IpmiAsyncConnector
and initiates the
ConnectionManager
at the given port and IP interface.port
- - the port that will be used by IpmiAsyncConnector
to
communicate with the remote hosts.address
- - the IP address that will be used by
IpmiAsyncConnector
to communicate with the remote
hosts.java.io.IOException
- when properties file was not foundpublic ConnectionHandle createConnection(java.net.InetAddress address) throws java.io.FileNotFoundException, java.io.IOException
address
- - InetAddress
of the remote hostjava.io.IOException
- when properties file was not foundjava.io.FileNotFoundException
- when properties file was not foundpublic java.util.List<CipherSuite> getAvailableCipherSuites(ConnectionHandle connectionHandle) throws java.lang.Exception
CipherSuite
s available for the connection with the remote
host.connectionHandle
- ConnectionHandle
to the connection created beforeCipherSuite
s that are allowed during the
connectionjava.lang.Exception
- when sending message to the managed system failscreateConnection(InetAddress)
public GetChannelAuthenticationCapabilitiesResponseData getChannelAuthenticationCapabilities(ConnectionHandle connectionHandle, CipherSuite cipherSuite, PrivilegeLevel requestedPrivilegeLevel) throws java.lang.Exception
connectionHandle
- - ConnectionHandle
associated with the hostcipherSuite
- - CipherSuite
that will be used during the connectionrequestedPrivilegeLevel
- - PrivilegeLevel
that is 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 openSession(ConnectionHandle connectionHandle, java.lang.String username, java.lang.String password, byte[] bmcKey) throws java.lang.Exception
connectionHandle
- - ConnectionHandle
associated with the remote host.username
- - the usernamepassword
- - 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(ConnectionHandle connectionHandle) throws java.lang.Exception
connectionHandle
- - ConnectionHandle
associated with the remote host.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 int sendMessage(ConnectionHandle connectionHandle, IpmiCommandCoder request) throws java.lang.Exception
connectionHandle
- - ConnectionHandle
associated with the remote host.request
- - IpmiCommandCoder
containing the request to be sentConnectionException
- 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 registerListener(IpmiListener listener)
listener
- IpmiListener
to notifypublic void unregisterListener(IpmiListener listener)
listener
- - the IpmiListener
to unregisterpublic void notify(ResponseData responseData, int handle, int tag, java.lang.Exception exception)
ConnectionListener
ConnectionListener
s of the one of the following
events: notify
in interface ConnectionListener
responseData
- - ResponseData
specific for the request if it was
completed successfully, null if it timed out or an error
occured during decoding.handle
- - the id of the connection that received the messagetag
- - tag of the request-response pairexception
- - null if everything went correctly or timeout occured,
contains exception that occured during decoding if it failed.public void closeConnection(ConnectionHandle handle)
public void tearDown()