Class ConnectionHandle

java.lang.Object
org.metricshub.ipmi.core.api.async.ConnectionHandle

public class ConnectionHandle extends Object
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

    Constructors
    Constructor
    Description
    ConnectionHandle(int handle, InetAddress remoteAddress, int remotePort)
    Creates the handle of a connection.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    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 with getChannelAuthenticationCapabilities() or createConnection().
    int
    Returns 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 with getChannelAuthenticationCapabilities() or createConnection(): PrivilegeLevel.MaximumAvailable stays MaximumAvailable, whatever level the session runs at.
    Returns the address of the BMC.
    int
    Returns the UDP port of the BMC.
    Returns the user name of the session, set by openSession().
    void
    setBmcKey(byte[] bmcKey)
    Sets the BMC key (Kg) of the session.
    void
    Sets the cipher suite of the session.
    void
    setPassword(String password)
    Sets the password of the session, encoded in UTF-8.
    void
    setPasswordBytes(byte[] passwordBytes)
    Sets the password of the session as bytes.
    void
    Sets the maximum privilege level requested for the session.
    void
    Sets the user name of the session.
    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.
    void
    Wipes the password and the BMC key (Kg) of the session, and the password that MD5-128 integrity keeps, once the connection is closed.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ConnectionHandle

      public ConnectionHandle(int handle, InetAddress remoteAddress, int remotePort)
      Creates the handle of a connection. The connector creates it: see IpmiConnector.createConnection(InetAddress).
      Parameters:
      handle - the index of the connection in its connector
      remoteAddress - the address of the BMC
      remotePort - the UDP port of the BMC
  • Method Details

    • getCipherSuite

      public CipherSuite getCipherSuite()
      Returns the cipher suite of the session, declared with getChannelAuthenticationCapabilities() or createConnection().
      Returns:
      the cipher suite, or null before it is declared
    • setCipherSuite

      public void setCipherSuite(CipherSuite cipherSuite)
      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

      public PrivilegeLevel getPrivilegeLevel()
      Returns the maximum privilege level requested for the session, declared with getChannelAuthenticationCapabilities() or createConnection(): PrivilegeLevel.MaximumAvailable stays MaximumAvailable, whatever level the session runs at.
      Returns:
      the privilege level, or null before it is declared
    • setPrivilegeLevel

      public void setPrivilegeLevel(PrivilegeLevel privilegeLevel)
      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 an IpmiResponseListener carries a new ConnectionHandle object, and this class does not override equals(): match a response with its connection by comparing response.getHandle().getHandle() with this index.
      Returns:
      the index of the connection
    • getRemoteAddress

      public InetAddress 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

      public String getUser()
      Returns the user name of the session, set by openSession().
      Returns:
      the user name, or null before the session is opened
    • setUser

      public void setUser(String user)
      Sets the user name of the session. openSession() sets it.
      Parameters:
      user - the user name of the session
    • getPassword

      public String getPassword()
      Returns the password of the session, decoded from UTF-8.
      Returns:
      the password of the session, decoded from UTF-8, or null
    • setPassword

      public void setPassword(String password)
      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

      public String 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.
      Overrides:
      toString in class Object