Class ConnectionManager
java.lang.Object
org.metricshub.ipmi.core.connection.ConnectionManager
Manages multiple
Connection
s-
Constructor Summary
ConstructorsConstructorDescriptionConnectionManager
(int port) Initiates the connection manager.ConnectionManager
(int port, long pingPeriod) Initiates the connection manager.ConnectionManager
(int port, InetAddress address) Initiates the connection manager.ConnectionManager
(Messenger messenger) Initiates the connection manager. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes all open connections and disconnectsUdpListener
.void
closeConnection
(int index) Closes the connection with the given index.int
createConnection
(InetAddress address, int port) Creates and initiatesConnection
to the remote host with the default ping frequency.int
createConnection
(InetAddress address, int port, boolean skipCiphers) Creates and initiatesConnection
to the remote host with the default ping frequency.int
createConnection
(InetAddress address, int port, int pingPeriod) Creates and initiatesConnection
to the remote host.int
createConnection
(InetAddress address, int port, int pingPeriod, boolean skipCiphers) Creates and initiatesConnection
to the remote host.static void
freeTag
(int tag) Frees the sessionless tag for further usestatic int
The tag for messages sent outside the session generated by theConnectionManager
.getAvailableCipherSuites
(int connection) Gets from the managed system supportedCipherSuite
s.getChannelAuthenticationCapabilities
(int connection, CipherSuite cipherSuite, PrivilegeLevel requestedPrivilegeLevel) Queries the managed system for the details of the authentification process.getConnection
(int index) ReturnsConnection
identified by index.getConnection
(InetAddress address, int port) Returns firstConnection
associated with the addressvoid
registerListener
(int connection, ConnectionListener listener) Registers the listener so it will receive notifications from connectionint
startSession
(int connection, CipherSuite cipherSuite, PrivilegeLevel privilegeLevel, String username, String password, byte[] bmcKey) Initiates the session with the managed system.
-
Constructor Details
-
ConnectionManager
Initiates the connection manager. Wildcard IP address will be used.- Parameters:
port
- the port at whichUdpListener
will workpingPeriod
- frequency of the no-op commands that will be sent to keep up the session. 0 to disable ping requests.- Throws:
IOException
- If UdpMessenger encountered an error
-
ConnectionManager
Initiates the connection manager. Wildcard IP address will be used.- Parameters:
port
- - the port at whichUdpListener
will work- Throws:
IOException
- If UdpMessenger encountered an error
-
ConnectionManager
Initiates the connection manager.- Parameters:
port
- - the port at whichUdpListener
will workaddress
- - the IP interfaceUdpListener
will bind to- Throws:
IOException
- If UdpMessenger encountered an error
-
ConnectionManager
Initiates the connection manager.- Parameters:
messenger
- -Messenger
to be used in communication
-
-
Method Details
-
close
public void close()Closes all open connections and disconnectsUdpListener
. -
generateSessionlessTag
public static int generateSessionlessTag()The tag for messages sent outside the session generated by theConnectionManager
. Auto-incremented. -
freeTag
public static void freeTag(int tag) Frees the sessionless tag for further use- Parameters:
tag
- - tag to free
-
getConnection
ReturnsConnection
identified by index.- Parameters:
index
- - index of the connection to return
-
closeConnection
public void closeConnection(int index) Closes the connection with the given index. -
getConnection
Returns firstConnection
associated with the address- Parameters:
address
- -InetAddress
of the remote host to get connection with.- Returns:
- First
Connection
to the address or null if none found
-
createConnection
public int createConnection(InetAddress address, int port, int pingPeriod, boolean skipCiphers) throws IOException Creates and initiatesConnection
to the remote host.- Parameters:
address
- -InetAddress
of the remote hostpingPeriod
- - frequency of the no-op commands that will be sent to keep up the sessionskipCiphers
- - determines if the getAvailableCipherSuites and getChannelAuthenticationCapabilities phases should be skipped- Returns:
- index of the connection
- Throws:
IOException
- - when properties file was not found
-
createConnection
Creates and initiatesConnection
to the remote host.- Parameters:
address
- -InetAddress
of the remote hostpingPeriod
- - frequency of the no-op commands that will be sent to keep up the session- Returns:
- index of the connection
- Throws:
IOException
- - when properties file was not found
-
createConnection
Creates and initiatesConnection
to the remote host with the default ping frequency.- Parameters:
address
- -InetAddress
of the remote host- Returns:
- index of the connection
- Throws:
IOException
- when properties file was not found
-
createConnection
Creates and initiatesConnection
to the remote host with the default ping frequency.- Parameters:
address
- -InetAddress
of the remote hostskipCiphers
- - determines if the getAvailableCipherSuites and getChannelAuthenticationCapabilities phases should be skipped- Returns:
- index of the connection
- Throws:
IOException
- when properties file was not found
-
getAvailableCipherSuites
Gets from the managed system supportedCipherSuite
s. Should be performed only immediately aftercreateConnection(java.net.InetAddress, int, int, boolean)
.- Parameters:
connection
- - index of the connection to get available Cipher Suites from- Returns:
- list of the
CipherSuite
s supported by the managed system. - Throws:
ConnectionException
- when connection is in the state that does not allow to perform this operation.Exception
- when sending message to the managed system fails
-
getChannelAuthenticationCapabilities
public GetChannelAuthenticationCapabilitiesResponseData getChannelAuthenticationCapabilities(int connection, CipherSuite cipherSuite, PrivilegeLevel requestedPrivilegeLevel) throws Exception Queries the managed system for the details of the authentification process. Must be performed aftergetAvailableCipherSuites(int)
- Parameters:
connection
- - index of the connection to get Channel Authentication Capabilities fromcipherSuite
- -CipherSuite
requested for the sessionrequestedPrivilegeLevel
- -PrivilegeLevel
requested for the session- Returns:
GetChannelAuthenticationCapabilitiesResponseData
- Throws:
ConnectionException
- when connection is in the state that does not allow to perform this operation.Exception
- when sending message to the managed system fails
-
startSession
public int startSession(int connection, CipherSuite cipherSuite, PrivilegeLevel privilegeLevel, String username, String password, byte[] bmcKey) throws Exception Initiates the session with the managed system. Must be performed aftergetChannelAuthenticationCapabilities(int, CipherSuite, PrivilegeLevel)
- Parameters:
connection
- - index of the connection that starts the sessioncipherSuite
- -CipherSuite
that will be used during the sessionprivilegeLevel
- - requestedPrivilegeLevel
- most of the time it will bePrivilegeLevel.User
username
- - the usernamepassword
- - the password matching the usernamebmcKey
- - the key that should be provided if the two-key authentication is enabled, null otherwise.- Throws:
ConnectionException
- when connection is in the state that does not allow to perform this operation.Exception
- when sending message to the managed system or initializing one of the cipherSuite's algorithms fails
-
registerListener
Registers the listener so it will receive notifications from connection- Parameters:
connection
- - index of theConnection
to listen tolistener
- -ConnectionListener
to processResponse
-