Class ConnectionHandle
java.lang.Object
org.metricshub.ipmi.core.api.async.ConnectionHandle
Identifies one
Connection (one BMC) of a connector: its index in the connector, the address and UDP port of
the BMC, the cipher suite and privilege level of its session, and the user name, password and BMC key (Kg) the
session was opened with, which the connector keeps to open another session on a payload port of the same BMC (Serial
over LAN). Returned by createConnection() of IpmiConnector and
IpmiAsyncConnector, which fill it in as the connection is set up.
The responses delivered to an IpmiResponseListener carry a new ConnectionHandle with only the
index, address and port of the connection: compare getHandle() to match a response with its connection.
-
Constructor Summary
ConstructorsConstructorDescriptionConnectionHandle(int handle, InetAddress remoteAddress, int remotePort) Creates the handle of a connection. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Returns the BMC key (Kg) of the session: the array the handle holds, not a copy, so do not modify it.Returns the cipher suite of the session, declared withgetChannelAuthenticationCapabilities()orcreateConnection().intReturns the index of the connection in its connector, which is not reused once the connection is closed.Returns the password of the session, decoded from UTF-8.byte[]Returns the password of the session as bytes: the array the handle holds, not a copy, so do not modify it.Returns the maximum privilege level requested for the session, declared withgetChannelAuthenticationCapabilities()orcreateConnection():PrivilegeLevel.MaximumAvailablestaysMaximumAvailable, whatever level the session runs at.Returns the address of the BMC.intReturns the UDP port of the BMC.getUser()Returns the user name of the session, set byopenSession().voidsetBmcKey(byte[] bmcKey) Sets the BMC key (Kg) of the session.voidsetCipherSuite(CipherSuite cipherSuite) Sets the cipher suite of the session.voidsetPassword(String password) Sets the password of the session, encoded in UTF-8.voidsetPasswordBytes(byte[] passwordBytes) Sets the password of the session as bytes.voidsetPrivilegeLevel(PrivilegeLevel privilegeLevel) Sets the maximum privilege level requested for the session.voidSets the user name of the session.toString()Returns the index, address and port of the connection, and the cipher suite, privilege level and user name of its session, without the password or the BMC key.voidWipes the password and the BMC key (Kg) of the session, and the password that MD5-128 integrity keeps, once the connection is closed.
-
Constructor Details
-
ConnectionHandle
Creates the handle of a connection. The connector creates it: seeIpmiConnector.createConnection(InetAddress).- Parameters:
handle- the index of the connection in its connectorremoteAddress- the address of the BMCremotePort- the UDP port of the BMC
-
-
Method Details
-
getCipherSuite
Returns the cipher suite of the session, declared withgetChannelAuthenticationCapabilities()orcreateConnection().- Returns:
- the cipher suite, or null before it is declared
-
setCipherSuite
Sets the cipher suite of the session. The connector sets it; changing it once the session is open has no effect on that session.- Parameters:
cipherSuite- the cipher suite of the session
-
getPrivilegeLevel
Returns the maximum privilege level requested for the session, declared withgetChannelAuthenticationCapabilities()orcreateConnection():PrivilegeLevel.MaximumAvailablestaysMaximumAvailable, whatever level the session runs at.- Returns:
- the privilege level, or null before it is declared
-
setPrivilegeLevel
Sets the maximum privilege level requested for the session. The connector sets it; changing it once the session is open has no effect on that session.- Parameters:
privilegeLevel- the privilege level of the session
-
getHandle
public int getHandle()Returns the index of the connection in its connector, which is not reused once the connection is closed. The response delivered to anIpmiResponseListenercarries a newConnectionHandleobject, and this class does not overrideequals(): match a response with its connection by comparingresponse.getHandle().getHandle()with this index.- Returns:
- the index of the connection
-
getRemoteAddress
Returns the address of the BMC.- Returns:
- the address of the BMC
-
getRemotePort
public int getRemotePort()Returns the UDP port of the BMC.- Returns:
- the UDP port of the BMC
-
getUser
Returns the user name of the session, set byopenSession().- Returns:
- the user name, or null before the session is opened
-
setUser
Sets the user name of the session.openSession()sets it.- Parameters:
user- the user name of the session
-
getPassword
Returns the password of the session, decoded from UTF-8.- Returns:
- the password of the session, decoded from UTF-8, or null
-
setPassword
Sets the password of the session, encoded in UTF-8.- Parameters:
password- the password of the session, sent to the BMC in UTF-8
-
getPasswordBytes
public byte[] getPasswordBytes()Returns the password of the session as bytes: the array the handle holds, not a copy, so do not modify it.- Returns:
- the password of the session, as sent to the BMC, or null
-
setPasswordBytes
public void setPasswordBytes(byte[] passwordBytes) Sets the password of the session as bytes.openSession()sets it.- Parameters:
passwordBytes- the password of the session, as sent to the BMC: the handle keeps a copy, so the caller can clear the array
-
getBmcKey
public byte[] getBmcKey()Returns the BMC key (Kg) of the session: the array the handle holds, not a copy, so do not modify it.- Returns:
- the BMC key (Kg) of the session, or null for a one-key login
-
setBmcKey
public void setBmcKey(byte[] bmcKey) Sets the BMC key (Kg) of the session.openSession()sets it.- Parameters:
bmcKey- the BMC key (Kg) of the session, or null: the handle keeps a copy, so the caller can clear the array
-
wipeCredentials
public void wipeCredentials()Wipes the password and the BMC key (Kg) of the session, and the password that MD5-128 integrity keeps, once the connection is closed.closeConnection()calls it. -
toString
Returns the index, address and port of the connection, and the cipher suite, privilege level and user name of its session, without the password or the BMC key.
-