Class SessionManager
java.lang.Object
org.metricshub.ipmi.core.connection.SessionManager
Manages multiple
Sessions.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SessionestablishSession(IpmiConnector connector, String remoteHost, int remotePort, String user, byte[] password, byte[] bmcKey, CipherSuiteSelectionHandler cipherSuiteSelectionHandler) Opens a new connection and session, at the Administrator privilege level, raised to it right after the login.static SessionestablishSession(IpmiConnector connector, String remoteHost, int remotePort, String user, String password, CipherSuiteSelectionHandler cipherSuiteSelectionHandler) Opens a new connection and session, at the Administrator privilege level, raised to it right after the login.static SessionestablishSession(IpmiConnector connector, ConnectionHandle connectionHandle, int remotePort) Opens a new connection and session on another UDP port of the BMC of the given connection (the port of a payload, IPMI 2.0 section 24.1), with its user name, password, BMC key and privilege level, and a copy of its cipher suite: opening the session keys the algorithms of its suite.static intGenerates the console session ID of a new session.getSessionForCriteria(InetAddress remoteAddress, int remotePort, String user) Returns session already bound to given connection handle fulfilling given criteria.registerSession(int newSessionId, int managedSystemSessionId, ConnectionHandle connectionHandle) registerSession(int newSessionId, ConnectionHandle connectionHandle) voidunregisterSession(ConnectionHandle connectionHandle) Unregisters session for given connection handle, and wipes the credentials of the handle it was registered with.voidWipes the credentials of the connections of all the registered sessions, when their connector tears down without closing each connection.
-
Constructor Details
-
SessionManager
public SessionManager()
-
-
Method Details
-
generateSessionId
public static int generateSessionId()Generates the console session ID of a new session.- Returns:
- a session ID between 1 and
Integer.MAX_VALUE / 4(never 0, the ID of session-less messages), different from the previous ones
-
establishSession
public static Session establishSession(IpmiConnector connector, String remoteHost, int remotePort, String user, String password, CipherSuiteSelectionHandler cipherSuiteSelectionHandler) throws SessionException Opens a new connection and session, at the Administrator privilege level, raised to it right after the login.- Parameters:
connector- the connector of the connectionremoteHost- the address of the BMCremotePort- the UDP port of the BMCuser- the user namepassword- the password, sent in UTF-8cipherSuiteSelectionHandler- chooses the cipher suite among those the BMC offers- Returns:
- the new session
- Throws:
SessionException- when the session cannot be opened, or the account is not allowed the Administrator privilege
-
establishSession
public static Session establishSession(IpmiConnector connector, String remoteHost, int remotePort, String user, byte[] password, byte[] bmcKey, CipherSuiteSelectionHandler cipherSuiteSelectionHandler) throws SessionException Opens a new connection and session, at the Administrator privilege level, raised to it right after the login.- Parameters:
connector- the connector of the connectionremoteHost- the address of the BMCremotePort- the UDP port of the BMCuser- the user namepassword- the password, as sent to the BMCbmcKey- the BMC key (Kg) for a two-key login, or nullcipherSuiteSelectionHandler- chooses the cipher suite among those the BMC offers- Returns:
- the new session
- Throws:
SessionException- when the session cannot be opened, or the account is not allowed the Administrator privilege
-
establishSession
public static Session establishSession(IpmiConnector connector, ConnectionHandle connectionHandle, int remotePort) throws SessionException Opens a new connection and session on another UDP port of the BMC of the given connection (the port of a payload, IPMI 2.0 section 24.1), with its user name, password, BMC key and privilege level, and a copy of its cipher suite: opening the session keys the algorithms of its suite.- Parameters:
connector- the connector of the connectionconnectionHandle- the connection whose credentials, cipher suite and privilege level the session takesremotePort- the UDP port of the BMC- Returns:
- the new session
- Throws:
SessionException- when the session cannot be opened, or the account is not allowed the privilege level
-
registerSession
Either returns theSessionregistered for given connection, or creates new IPMISessionand registers it for the given connection handle, if no session was found for the connection.- Parameters:
connectionHandle- handle of the connection, for which this session should be registered.- Returns:
- newly created session object or session already registered for the connection
-
registerSession
public Session registerSession(int newSessionId, int managedSystemSessionId, ConnectionHandle connectionHandle) Either returns theSessionregistered for given connection, or creates new IPMISessionand registers it for the given connection handle, if no session was found for the connection.- Parameters:
newSessionId- the remote console session ID of the new sessionmanagedSystemSessionId- the managed system session ID of the new session, which the BMC generatedconnectionHandle- handle of the connection, for which this session should be registered.- Returns:
- newly created session object or session already registered for the connection
-
unregisterSession
Unregisters session for given connection handle, and wipes the credentials of the handle it was registered with.- Parameters:
connectionHandle- handle of the connection, for which the session should be unregistered.
-
wipeCredentials
public void wipeCredentials()Wipes the credentials of the connections of all the registered sessions, when their connector tears down without closing each connection. -
getSessionForCriteria
Returns session already bound to given connection handle fulfilling given criteria.- Parameters:
remoteAddress- IP addres of the managed systemremotePort- UDP port of the managed systemuser- IPMI user for whom the connection is established- Returns:
- session object fulfilling given criteria, or null if no session was registered for such connection.
-