public class CommunicationUtils extends Object
Constructor and Description |
---|
CommunicationUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
decryptMessage(String encryptedMessage,
Key decryptKey)
Encrypts the message with the key that's passed in.
|
static String |
encryptMessage(String message,
Key encryptionKey)
Encrypts the message with the key that's passed in.
|
static String |
signMessage(String message,
PrivateKey signatureKey)
Signed a given message using the PrivateKey that's passes in.
|
static boolean |
verifySignature(String data,
String signedData,
PublicKey verificationKey)
Verifies some signed-data against the a Public-Key to ensure that it was produced by the holder of the
corresponding Private Key.
|
public static String encryptMessage(String message, Key encryptionKey) throws TransportHandlerException
message
- the message to be encrypted.encryptionKey
- the key to use for the encryption of the message.TransportHandlerException
- if an error occurs with the encryption flow which can be due to Padding
issues, encryption key being invalid or the algorithm used is unrecognizable.public static String signMessage(String message, PrivateKey signatureKey) throws TransportHandlerException
message
- the message to be signed. Ideally some encrypted payload.signatureKey
- the PrivateKey with which the message is to be signed.TransportHandlerException
- if some error occurs with the signing process which may be related to the
signature algorithm used or the key used for signing.public static boolean verifySignature(String data, String signedData, PublicKey verificationKey) throws TransportHandlerException
data
- the actual payoad which was signed by some Private Key.signedData
- the signed data produced by signing the payload using a Private Key.verificationKey
- the corresponding Public Key which is an exact pair of the Private-Key with we expect
the data to be signed by.TransportHandlerException
- if some error occurs with the verification process which may be related to
the signature algorithm used or the key used for signing.public static String decryptMessage(String encryptedMessage, Key decryptKey) throws TransportHandlerException
encryptedMessage
- the encrypted message that is supposed to be decrypted.decryptKey
- the key to use in the decryption process.TransportHandlerException
- if an error occurs with the encryption flow which can be due to Padding
issues, encryption key being invalid or the algorithm used is unrecognizable.Copyright © 2017 WSO2. All rights reserved.