Class MessengingHelper
MessengingHelper is the class use to create, and get Messenging.
SESAR service use messenging. The messenging is usefull when is configured to keep a copy encrypted or not of all Secure Exchanges communications in you own organisation
Inheritance
System.Object
MessengingHelper
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Assembly: SecureExchangesSDK.dll
Syntax
public static class MessengingHelper
Methods
CreateMessenging(CreateMessengingArgs)
This method let you create a messenging to another SE licence
Declaration
public static CreateMessengingAnswer CreateMessenging(CreateMessengingArgs args)
Parameters
Returns
CreateRestoreRequest(CreateRestoreRequestArgs)
To create a SESAR restore request
Declaration
public static CreateRestoreRequestAnswer CreateRestoreRequest(CreateRestoreRequestArgs args)
Parameters
Returns
GetBusinessMessenginKeys(GetBusinessMessenginKeysArgs)
Retreived the public key to encrypts com AES and file AES keys
Declaration
public static GetBusinessMessenginKeysAnswer GetBusinessMessenginKeys(GetBusinessMessenginKeysArgs args)
Parameters
Returns
GetMessenging(GetMessengingArgs)
This method let you create a messenging to another SE licence
Declaration
public static GetMessengingResponse GetMessenging(GetMessengingArgs args)
Parameters
Returns
Examples
// Note: In this sample the Settings are get from a GlobalSettings object, it's only a object that store the value in memory
// Load the base 64 XmlKey from settings in that sample, but we recommand to store that key in a secure place of your choice
string privateXmlKey = SecureExchangesSDK.Helpers.SerializationHelper.DeserializeTextFromBase64(GlobalSettings.Base64MessengingPrivateKey);
// Call Secure Exchanges to validate if we get messengings for that serial
var messengings = SecureExchangesSDK.Helpers.MessengingHelper.GetMessenging(new SecureExchangesSDK.Models.Args.GetMessengingArgs()
{
EndPointConfigurationName = GlobalSettings.bindingSecure,
ApiPassword = GlobalSettings.ApiPasswordMessenging,
ApiUser = GlobalSettings.ApiUserMessenging,
Serial = GlobalSettings.serialMessenging,
// The hashkey is the SHA512 of the xml public key of the xml private key
HashKey = SecureExchangesSDK.Helpers.CryptoHelper.GetSHA512HashOfString(SecureExchangesSDK.Helpers.CryptoHelper.GetPublicKeyFromPrivateKey(privateXmlKey))
});
if (messengings == null) throw new Exception("No messenging");
if (messengings.Status != 200)
{
throw new Exception(messengings.Data);
}
foreach (var seM in messengings.Messengings)
{
// For each messenging get the cryptedCallObject
CallBackCryptedObject cryptedCallObject = SecureExchangesSDK.Helpers.SerializationHelper.DeserializeFromJson<CallBackCryptedObject>(seM.Message);
byte[] comKey, comiv;
// Retreived the communication crypted key. That key was crypted with the public key of the messenging
string jsonKeys = SecureExchangesSDK.Helpers.CryptoHelper.DecryptRSAContentToString(SecureExchangesSDK.Helpers.SerializationHelper.DeserializeTextFromBase64(GlobalSettings.Base64MessengingPrivateKey), Convert.FromBase64String(seM.CryptedAESKeyWithPublicKeyComMessenging), true);
var keys = SecureExchangesSDK.Helpers.SerializationHelper.DeserializeFromJson<Keys>(jsonKeys);
comKey = Convert.FromBase64String(keys.Base64Key);
comiv = Convert.FromBase64String(keys.Base64IV);
// Unencrypt the crypted with the key crypted with the AES key build bellow
string JSONCallBackObject = SecureExchangesSDK.Helpers.CryptoHelper.DecryptStringFromBase64(cryptedCallObject.CallBackObject, comKey, comiv);
// Construct the callbackobject
CallBackObject callBack = SecureExchangesSDK.Helpers.SerializationHelper.DeserializeFromJson<CallBackObject>(JSONCallBackObject);
// Load the Sesar manifest
SesarManifest manifest = SecureExchangesSDK.Helpers.SerializationHelper.DeserializeFromJson<SesarManifest>(callBack.CallBackParameters);
// Get the SEcureExchangesMessage from the callback url
SecureExchangesMessage msg = MessageHelper.GetSecureExchangesMessageFromLink(callBack.SecureExchangesURL);
// Call the GetResponse of the message url
GetMessageResponse response = SecureExchangesSDK.Helpers.MessageHelper.GetMessage(new SecureExchangesSDK.Models.Args.GetMessageArgs(
GlobalSettings.bindingSecure,
GlobalSettings.serialMessenging,
GlobalSettings.ApiUserMessenging,
GlobalSettings.ApiPasswordMessenging, msg.MessageID, msg.Cpart, msg.Sems, msg.NIv, msg.P2, callBack.Password, msg.Pit, string.Empty, msg.Sit));
// That object represent the keys of the encrypted callback.
// That key are encrypted with the public key of the communication keys
Keys parametersKeys = null;
// Create the callback parameters keys
if (!string.IsNullOrEmpty(response.CallBackParametersKeys))
{
// Get the callback parameters
string parameterJsonKey = SecureExchangesSDK.Helpers.CryptoHelper.DecryptRSAContentToString(privateXmlKey, Convert.FromBase64String(response.CallBackParametersKeys), true);
parametersKeys = SecureExchangesSDK.Helpers.SerializationHelper.DeserializeFromJson<Keys>(parameterJsonKey);
}
// Retretive the email from of the message
if (!string.IsNullOrEmpty(seM.CryptedFromEmailAddress) && parametersKeys != null)
{
// That determine if it's a reply
string fromEmail = SecureExchangesSDK.Helpers.CryptoHelper.DecryptStringFromBytes(Convert.FromBase64String(seM.CryptedFromEmailAddress), parametersKeys.Key, parametersKeys.IV);
}
// Retreveid the email to of the message
if (!string.IsNullOrEmpty(seM.CryptedToEmailAddress) && parametersKeys != null)
{
string toEmail = SecureExchangesSDK.Helpers.CryptoHelper.DecryptStringFromBytes(Convert.FromBase64String(seM.CryptedToEmailAddress), parametersKeys.Key, parametersKeys.IV);
}
// Retrevied callback parameters string.
if (!string.IsNullOrEmpty(response.CallBackParameters) && parametersKeys != null)
{
// You suppose to get your callback parameter in clear here
string callBackParameter = SecureExchangesSDK.Helpers.CryptoHelper.DecryptStringFromBytes(Convert.FromBase64String(response.CallBackParameters), parametersKeys.Key, parametersKeys.IV);
}
}
GetResendSignatureRequest(GetSESARResendSignatureRequestArgs)
To create a SESAR resend signature request
Declaration
public static GetResendSignatureRequestAnswer GetResendSignatureRequest(GetSESARResendSignatureRequestArgs args)
Parameters
Returns
GetRestoreRequest(GetRestoreRequestArgs)
To create a SESAR restore request
Declaration
public static GetRestoreRequestAnswer GetRestoreRequest(GetRestoreRequestArgs args)
Parameters
Returns
GetSESARLatestVersion(GetSESARLatestVersionArgs)
Get the latest version of SESAR
Declaration
public static GetSESARVersionResponse GetSESARLatestVersion(GetSESARLatestVersionArgs args)
Parameters
Returns
InitializeSesar(InitSesarArgs)
When you initialize a Sesar connection, you received the notification parameters and chontacts
Declaration
public static InitSesarResponse InitializeSesar(InitSesarArgs args)
Parameters
Returns
LogMessengingRequests(String, MessengingLogRequestType, NotificationBags, BaseAPIArgs, Boolean)
Declaration
public static Answer LogMessengingRequests(string message, MessengingLogRequestType messageType, NotificationBags bags, BaseAPIArgs args, bool notifyContacts = false)
Parameters
Returns
SetResendSignatureAsExecutedRequest(SetResendSignatureAsExecutedRequestArgs)
To set an executed date to resend signature
Declaration
public static SetResendSignatureAsExecutedRequestAnswer SetResendSignatureAsExecutedRequest(SetResendSignatureAsExecutedRequestArgs args)
Parameters
Returns
UpdateRestoreRequestStatus(UpdateRestoreRequestStatusArgs)
Update the restore request status to notify the execution
Declaration
public static UpdateRestoreRequestStatusAnswer UpdateRestoreRequestStatus(UpdateRestoreRequestStatusArgs args)
Parameters
Returns