Package org.netxms.base
Class EncryptionContext
java.lang.Object
org.netxms.base.EncryptionContext
Encryption context for NXCP communication session
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedEncryptionContext(int cipher, NXCPMessage request) Internal constructor
- 
Method SummaryModifier and TypeMethodDescriptionstatic EncryptionContextcreateInstance(NXCPMessage request) Create encryption context based on information from session key request message.byte[]decryptMessage(NXCPDataInputStream inputStream, int length) Decrypt message from input streambyte[]encryptMessage(NXCPMessage msg, boolean allowCompression) Encrypt NXCP message.intGet cipherstatic StringgetCipherName(int cipher) Get cipher namebyte[]Encrypt initialization vector with public key from encryption setup message.byte[]Encrypt session key with public key from encryption setup message.intGet initialization vector length (in bytes)intGet key length (in bytes)Get fingerprint of server public keystatic booleantestCipher(int cipherId) Test cipher with given IDtoString()
- 
Constructor Details- 
EncryptionContextInternal constructor- Parameters:
- cipher- cipher to use
- request- NXCP message with key exchange request
- Throws:
- GeneralSecurityException- if any of underlying crypto functions fails
 
 
- 
- 
Method Details- 
toString
- 
getCipherNameGet cipher name- Parameters:
- cipher- cipher ID
- Returns:
- cipher name or null if ID is invalid or cipher is not supported
 
- 
testCipherpublic static boolean testCipher(int cipherId) Test cipher with given ID- Parameters:
- cipherId- cipher ID
- Returns:
- true if cipher is available and working correctly
 
- 
createInstanceCreate encryption context based on information from session key request message.- Parameters:
- request- session key request message
- Returns:
- encryption context
- Throws:
- NXCPException- if encryption context cannot be created
 
- 
getEncryptedSessionKeyEncrypt session key with public key from encryption setup message.- Returns:
- encrypted session key
- Throws:
- GeneralSecurityException- if any of underlying crypto functions fail
 
- 
getEncryptedIvEncrypt initialization vector with public key from encryption setup message.- Returns:
- encrypted initialization vector
- Throws:
- GeneralSecurityException- if any of underlying crypto functions fail
 
- 
encryptMessagepublic byte[] encryptMessage(NXCPMessage msg, boolean allowCompression) throws IOException, GeneralSecurityException Encrypt NXCP message.- Parameters:
- msg- message to encrypt
- allowCompression- true if payload compression is allowed
- Returns:
- encrypted message as sequence of bytes, ready to send over the network
- Throws:
- IOException- if I/O error occurs
- GeneralSecurityException- if any of underlying crypto functions fails
- InvalidKeyException- if encryption key is invalid
 
- 
decryptMessagepublic byte[] decryptMessage(NXCPDataInputStream inputStream, int length) throws GeneralSecurityException, IOException Decrypt message from input stream- Parameters:
- inputStream- input stream
- length- length of encrypted message
- Returns:
- decrypted message
- Throws:
- GeneralSecurityException- if any of underlying crypto functions fails
- IOException- if I/O error occurs
 
- 
getCipherpublic int getCipher()Get cipher- Returns:
- cipher
 
- 
getKeyLengthpublic int getKeyLength()Get key length (in bytes)- Returns:
- key length (in bytes)
 
- 
getIvLengthpublic int getIvLength()Get initialization vector length (in bytes)- Returns:
- initialization vector length (in bytes)
 
- 
getServerKeyFingerprintGet fingerprint of server public key- Returns:
- fingerprint of server public key
 
 
-