Class Rakp1
java.lang.Object
org.metricshub.ipmi.core.coding.PayloadCoder
org.metricshub.ipmi.core.coding.commands.IpmiCommandCoder<Rakp1ResponseData>
org.metricshub.ipmi.core.coding.commands.session.Rakp1
A wrapper for RMCP+ RAKP1 message and it's response - RAKP2 message. The same instance of this class that was used to prepare RAKP Message 1 should be also used to decode matching RAKP Message 2 since the generated random number is used in encryption process.
Capable of calculating SIK (Session Integrity Key) when RAKP Message 2 is
given (calculateSik(Rakp1ResponseData)).
-
Constructor Summary
ConstructorsConstructorDescriptionRakp1(int managedSystemSessionId, PrivilegeLevel privilegeLevel, String username, byte[] password, byte[] bmcKey, CipherSuite cipherSuite) Initiates class for encoding and decoding. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]calculateSik(Rakp1ResponseData responseData) Calculates SIK (Session Integrity Key) based on RAKP Messages 1 and 2static voidcheckCredentials(String username, byte[] password, byte[] bmcKey) Checks the credentials of a session against what a BMC stores: a user name of at most 16 bytes in UTF-8, a password and a BMC key (Kg) of at most 20 bytes.encodePayload(int messageSequenceNumber, int sessionSequenceNumber, int sessionId) Prepares an IPMI request message containing class-specific payload.byte[]byteRetrieves command code specific for command represented by this classbyte[]intRetrieves network function specific for command represented by this class.getResponseData(IpmiMessage message) Retrieves payload-specific response data from IPMI messagebooleanisCommandResponse(IpmiMessage message) Checks if given message contains response command specific for this class.voidsetManagedSystemSessionId(int managedSystemSessionId) voidsetRequestedMaximumPrivilegeLevel(PrivilegeLevel requestedMaximumPrivilegeLevel) voidsetUsername(String username) Methods inherited from class org.metricshub.ipmi.core.coding.commands.IpmiCommandCoder
answers, getNetworkFunctionCode, getSupportedPayloadTypeMethods inherited from class org.metricshub.ipmi.core.coding.PayloadCoder
getAuthenticationType, getCipherSuite, getIpmiVersion, setAuthenticationType, setCipherSuite, setIpmiVersion, setSessionParameters
-
Constructor Details
-
Rakp1
public Rakp1(int managedSystemSessionId, PrivilegeLevel privilegeLevel, String username, byte[] password, byte[] bmcKey, CipherSuite cipherSuite) Initiates class for encoding and decoding. Sets IPMI version toIpmiVersion.V20since RAKP1 is a RMCP+ command. Sets Authentication Type to RMCP+.- Parameters:
managedSystemSessionId- - The Managed System's Session ID for this session. Must be as returned by the Managed System in the Open Session Response message.privilegeLevel- - Requested MaximumPrivilegeLevelusername- - ASCII character Name that the user at the Remote Console wishes to assume for this session. It's length cannot exceed 16.password- - password matching username, as sent to the BMC (UTF-8 for a text password), at most 20 bytesbmcKey- - BMC specific key. Should be null if Get Channel Authentication Capabilities Response indicated that Kg is disabled which means that 'one-key' logins are being used (GetChannelAuthenticationCapabilitiesResponseData.isKgEnabled()== false)cipherSuite- -CipherSuitecontaining authentication, confidentiality and integrity algorithms for this session.
-
-
Method Details
-
setManagedSystemSessionId
public void setManagedSystemSessionId(int managedSystemSessionId) -
getManagedSystemSessionId
public int getManagedSystemSessionId() -
setRequestedMaximumPrivilegeLevel
-
getRequestedMaximumPrivilegeLevel
-
setUsername
-
checkCredentials
Checks the credentials of a session against what a BMC stores: a user name of at most 16 bytes in UTF-8, a password and a BMC key (Kg) of at most 20 bytes.- Parameters:
username- the user namepassword- the password as sent to the BMC, or nullbmcKey- the BMC key, or null- Throws:
IllegalArgumentException- when one of them is too long
-
getUsername
-
getConsoleRandomNumber
public byte[] getConsoleRandomNumber() -
getBmcKey
public byte[] getBmcKey() -
encodePayload
public IpmiMessage encodePayload(int messageSequenceNumber, int sessionSequenceNumber, int sessionId) Description copied from class:PayloadCoderPrepares an IPMI request message containing class-specific payload.- Overrides:
encodePayloadin classPayloadCoder- Parameters:
messageSequenceNumber- - A generated sequence number used for matching request and response. For all IPMI messages, messageSequenceNumber is used as a IPMI LAN Message sequence number and as an IPMI payload message tag.sessionSequenceNumber- - If IPMI message is sent in a session, it is used as a Session Sequence NumbersessionId- - ID of the managed system's session message is being sent in. For sessionless commands should b set to 0.- Returns:
- IPMI message
-
getCommandCode
public byte getCommandCode()Description copied from class:IpmiCommandCoderRetrieves command code specific for command represented by this class- Specified by:
getCommandCodein classIpmiCommandCoder<Rakp1ResponseData>- Returns:
- command code
-
getNetworkFunction
Description copied from class:IpmiCommandCoderRetrieves network function specific for command represented by this class.- Specified by:
getNetworkFunctionin classIpmiCommandCoder<Rakp1ResponseData>- Returns:
- network function, or null for a command of a network function
NetworkFunctiondoes not list, which overridesIpmiCommandCoder.getNetworkFunctionCode()instead - See Also:
-
getResponseData
public Rakp1ResponseData getResponseData(IpmiMessage message) throws IPMIException, NoSuchAlgorithmException, InvalidKeyException Description copied from class:PayloadCoderRetrieves payload-specific response data from IPMI message- Specified by:
getResponseDatain classIpmiCommandCoder<Rakp1ResponseData>- Parameters:
message- - IPMI message- Returns:
- response data
- Throws:
IllegalArgumentException- when message is not a response for class-specific command, response has invalid length or authentication check fails.NoSuchAlgorithmException- - when authentication, confidentiality or integrity algorithm fails.InvalidKeyException- - when creating of the algorithm key failsIPMIException- when response completion code isn't OK.
-
calculateSik
public byte[] calculateSik(Rakp1ResponseData responseData) throws InvalidKeyException, NoSuchAlgorithmException Calculates SIK (Session Integrity Key) based on RAKP Messages 1 and 2- Parameters:
responseData- RAKP Message 2 data- Returns:
- Session Integrity Key
- Throws:
NoSuchAlgorithmException- - when authentication, confidentiality or integrity algorithm fails.InvalidKeyException- - when creating of the algorithm key fails
-
isCommandResponse
Description copied from class:IpmiCommandCoderChecks if given message contains response command specific for this class.- Overrides:
isCommandResponsein classIpmiCommandCoder<Rakp1ResponseData>- Parameters:
message-IpmiMessagewrapping the IPMI message- Returns:
- True if message contains response command specific for this class, false otherwise.
-