org.netxms.base
Class EncryptionContext

java.lang.Object
  extended by org.netxms.base.EncryptionContext

public final class EncryptionContext
extends java.lang.Object

Encryption context for NXCP communication session


Constructor Summary
protected EncryptionContext(int cipher)
          Internal constructor
 
Method Summary
static EncryptionContext createInstance(NXCPMessage request)
          Create encryption context based on information from session key request message.
 byte[] decryptMessage(NXCPDataInputStream inputStream, int length)
           
 byte[] encryptMessage(NXCPMessage msg)
          Encrypt NXCP message.
 int getCipher()
          Get cipher
 byte[] getEncryptedIv(NXCPMessage msg)
          Encrypt initialization vector with public key from encryption setup message.
 byte[] getEncryptedSessionKey(NXCPMessage msg)
          Encrypt session key with public key from encryption setup message.
 int getIvLength()
           
 int getKeyLength()
          Get key length (in bytes)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncryptionContext

protected EncryptionContext(int cipher)
                     throws java.security.GeneralSecurityException
Internal constructor

Throws:
java.security.GeneralSecurityException
Method Detail

createInstance

public static EncryptionContext createInstance(NXCPMessage request)
                                        throws NXCPException
Create 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

getEncryptedSessionKey

public byte[] getEncryptedSessionKey(NXCPMessage msg)
                              throws java.security.GeneralSecurityException
Encrypt session key with public key from encryption setup message.

Parameters:
msg - encryption setup message
Returns:
encrypted session key
Throws:
java.security.GeneralSecurityException

getEncryptedIv

public byte[] getEncryptedIv(NXCPMessage msg)
                      throws java.security.GeneralSecurityException
Encrypt initialization vector with public key from encryption setup message.

Parameters:
msg - encryption setup message
Returns:
encrypted initialization vector
Throws:
java.security.GeneralSecurityException

encryptMessage

public byte[] encryptMessage(NXCPMessage msg)
                      throws java.io.IOException,
                             java.security.GeneralSecurityException
Encrypt NXCP message.

Parameters:
msg - message to encrypt
Returns:
encrypted message as sequence of bytes, ready to send over the network
Throws:
java.io.IOException
java.security.GeneralSecurityException
java.security.InvalidKeyException

decryptMessage

public byte[] decryptMessage(NXCPDataInputStream inputStream,
                             int length)
                      throws java.security.GeneralSecurityException,
                             java.io.IOException
Parameters:
inputStream -
length -
Returns:
Throws:
java.security.GeneralSecurityException
java.io.IOException

getCipher

public int getCipher()
Get cipher

Returns:

getKeyLength

public int getKeyLength()
Get key length (in bytes)

Returns:

getIvLength

public int getIvLength()
Returns:


Copyright © 2012. All Rights Reserved.