Class ConnectionManager
java.lang.Object
org.metricshub.ipmi.core.connection.ConnectionManager
Manages multiple
Connections-
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 TypeMethodDescriptionvoidclose()Closes all open connections and disconnectsUdpListener.voidcloseConnection(int index) Closes the connection with the given index.intcreateConnection(InetAddress address, int port) Creates and initiatesConnectionto the remote host with the default ping frequency.intcreateConnection(InetAddress address, int port, boolean skipCiphers) Creates and initiatesConnectionto the remote host with the default ping frequency.intcreateConnection(InetAddress address, int port, int pingPeriod) Creates and initiatesConnectionto the remote host.intcreateConnection(InetAddress address, int port, int pingPeriod, boolean skipCiphers) Creates and initiatesConnectionto the remote host.static voidfreeTag(int tag) Frees the sessionless tag for further usestatic intThe tag for messages sent outside the session generated by theConnectionManager.getAvailableCipherSuites(int connection) Gets from the managed system supportedCipherSuites.getChannelAuthenticationCapabilities(int connection, CipherSuite cipherSuite, PrivilegeLevel requestedPrivilegeLevel) Queries the managed system for the details of the authentification process.getConnection(int index) ReturnsConnectionidentified by index.getConnection(InetAddress address, int port) Returns firstConnectionassociated with the addressvoidregisterListener(int connection, ConnectionListener listener) Registers the listener so it will receive notifications from connectionintstartSession(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 whichUdpListenerwill 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 whichUdpListenerwill work- Throws:
IOException- If UdpMessenger encountered an error
-
ConnectionManager
Initiates the connection manager.- Parameters:
port- - the port at whichUdpListenerwill workaddress- - the IP interfaceUdpListenerwill bind to- Throws:
IOException- If UdpMessenger encountered an error
-
ConnectionManager
Initiates the connection manager.- Parameters:
messenger- -Messengerto 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
ReturnsConnectionidentified 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 firstConnectionassociated with the address- Parameters:
address- -InetAddressof the remote host to get connection with.- Returns:
- First
Connectionto the address or null if none found
-
createConnection
public int createConnection(InetAddress address, int port, int pingPeriod, boolean skipCiphers) throws IOException Creates and initiatesConnectionto the remote host.- Parameters:
address- -InetAddressof 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 initiatesConnectionto the remote host.- Parameters:
address- -InetAddressof 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 initiatesConnectionto the remote host with the default ping frequency.- Parameters:
address- -InetAddressof the remote host- Returns:
- index of the connection
- Throws:
IOException- when properties file was not found
-
createConnection
Creates and initiatesConnectionto the remote host with the default ping frequency.- Parameters:
address- -InetAddressof 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 supportedCipherSuites. 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
CipherSuites 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- -CipherSuiterequested for the sessionrequestedPrivilegeLevel- -PrivilegeLevelrequested 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- -CipherSuitethat will be used during the sessionprivilegeLevel- - requestedPrivilegeLevel- most of the time it will bePrivilegeLevel.Userusername- - 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 theConnectionto listen tolistener- -ConnectionListenerto processResponse
-