public string InitializeBinding(int binderCoupon,object propertyNames,object propertyValues,ref string binderPublicKey)
Function InitializeBinding( _ByVal binderCoupon As Integer, _ByVal propertyNames As Object, _ByVal propertyValues As Object, _ByRef binderPublicKey As String _) As String
String^ InitializeBinding(int binderCoupon,Object^ propertyNames,Object^ propertyValues,String^% binderPublicKey)
binderCoupon
The binder coupon.
propertyNames
The property names of the technology-specific secure binding-related properties for which the bindee wishes to establish agreement.
propertyValues
The property values.
binderPublicKey
The binder public key.
When a passcode-based secure binding is to be established, the value of the output mac is a message authentication code. This code shall be used by the bindee to prove the identity of the binder, and to ensure that the value of binderPublicKey has not been tampered with. When a PKI-based secure binding is to be established, the value of the output mac is a digital signature.
A secure binding shall be established by the bindee before it attempts to interact with the binder via methods that entail the use of either the bindee's or the binder's digital signature. For example, an application or user mapping agent shall establish a secure binding with the context manager before it attempts to access the context manager in order to set or get context item values that require the bindee's digital signature.
Joins a common context and set patient information.
using Leadtools;using Leadtools.Ccow;using Leadtools.Ccow.UI;public void SecureBinding(){IContextManager contextManager = Utils.COMCreateObject<IContextManager>(CcowProgId);SecureParticipant participant = new SecureParticipant();ISecureBinding secure = contextManager as ISecureBinding;int coupon = 0;try{string binderPublicKey = string.Empty;string mac = string.Empty, hash;object access;coupon = contextManager.JoinCommonContext(participant, ApplicationName, true, false);//// Bind securely context manager//mac = secure.InitializeBinding(coupon, Constants.PassCodeNames, Constants.PassCodeValues, ref binderPublicKey);hash = Utils.BinaryEncode(Utils.Hash(binderPublicKey + SecureParticipant.Passcode));Debug.Assert(mac.ToLower() == hash.ToLower());//// Create participant mac and finalize binding//mac = Utils.BinaryEncode(Utils.Hash(participant.PublicKey + SecureParticipant.Passcode));access = secure.FinalizeBinding(coupon, participant.PublicKey, mac);//// Display access//if (access != null){string[] a = (string[])access;for (int i = 0; i < a.Length; i += 2){Debug.WriteLine(string.Format(" {0}\t{1}", a[i], a[i + 1]));}}SetUserContext(contextManager, participant, coupon);contextManager.LeaveCommonContext(coupon);}catch (Exception e){Debug.WriteLine(e.Message);}}private void SetUserContext(IContextManager contextManager, SecureParticipant participant, int coupon){ISecureContextData secure = contextManager as ISecureContextData;Subject userSubject = new Subject("User");int transactionCoupon = 0;bool noContinue = true, disconnect = false;object reasons;string decision = "accept";userSubject.Items.Add(new ContextItem("User.id.logon"));userSubject.Items[0].Value = "test";userSubject.Items.Add(new ContextItem("User.co.Name"));userSubject.Items[1].Value = "Test User";try{string messageDigest, appSignature;List<string> values = new List<string>();foreach (object v in userSubject.ToItemValueArray()){values.Add(v.ToString());}transactionCoupon = contextManager.StartContextChanges(coupon);//// Create digital signature//messageDigest = coupon.ToString() + string.Join("", userSubject.ToItemNameArray()) +string.Join("", values.ToArray()) + transactionCoupon.ToString();appSignature = participant.CreateSignature(messageDigest);secure.SetItemValues(coupon, userSubject.ToItemNameArray(), userSubject.ToItemValueArray(),transactionCoupon, appSignature);reasons = contextManager.EndContextChanges(transactionCoupon, ref noContinue);//// If any application responded that they cannot apply the change we need to display// a dialog that displays the reasons for the problems.//if ((reasons != null && ((string[])reasons).Length > 0) || noContinue){ProblemDialog pd = new ProblemDialog((string[])reasons, noContinue);DialogResult result;result = pd.ShowDialog();if (noContinue)decision = "cancel";if (result == DialogResult.OK)decision = "accept";else if (result == DialogResult.Cancel)decision = "cancel";else{decision = "cancel";disconnect = true;}}//// If user decided to break context we must leave//contextManager.PublishChangesDecision(transactionCoupon, decision);if (disconnect){contextManager.LeaveCommonContext(coupon);}}catch (Exception e){Debug.WriteLine(e.Message);}}[ComVisible(true)]public class SecureParticipant : IContextParticipant{public const string Passcode = "A2C053FC-182C-4167-BB56-EE394BC5DB05";public const string ApplicationName = "LEADTOOLS CCOW App";private KeyContainer _KeyContainer = null;public string PublicKey{get{if (_KeyContainer != null)return Utils.BinaryEncode(_KeyContainer.GetPublicKey());return string.Empty;}}public SecureParticipant(){_KeyContainer = new KeyContainer(ApplicationName);}public string CreateSignature(string messageDigest){byte[] signature = _KeyContainer.Sign(messageDigest);return Utils.BinaryEncode(signature);}#region IContextParticipant Memberspublic void CommonContextTerminated(){Console.WriteLine("CommonContextTerminated");}public void ContextChangesAccepted(int contextCoupon){Console.WriteLine("ContextChangesAccepted");}public void ContextChangesCanceled(int contextCoupon){Console.WriteLine("ContextChangesCanceled");}public string ContextChangesPending(int contextCoupon, ref string reason){reason = string.Empty;Console.WriteLine("ContextChangesPending");return "accept";}public void Ping(){}#endregion}
Imports LeadtoolsImports Leadtools.CcowImports Leadtools.Ccow.UIPublic Sub SecureBinding()Dim contextManager As IContextManager = Utils.COMCreateObject(Of IContextManager)(CcowProgId)Dim participant As SecureParticipant = New SecureParticipant()Dim secure As ISecureBinding = TryCast(contextManager, ISecureBinding)Dim coupon As Integer = 0TryDim binderPublicKey As String = String.EmptyDim mac As String = String.Empty, hash As StringDim access As Objectcoupon = contextManager.JoinCommonContext(participant, ApplicationName, True, False)'' Bind securely context manager'mac = secure.InitializeBinding(coupon, Leadtools.Ccow.Constants.PassCodeNames, Leadtools.Ccow.Constants.PassCodeValues, binderPublicKey)hash = Utils.BinaryEncode(Utils.Hash(binderPublicKey & SecureParticipant.Passcode))Debug.Assert(mac.ToLower() = hash.ToLower())'' Create participant mac and finalize binding'mac = Utils.BinaryEncode(Utils.Hash(participant.PublicKey + SecureParticipant.Passcode))access = secure.FinalizeBinding(coupon, participant.PublicKey, mac)'' Display access'If Not access Is Nothing ThenDim a As String() = CType(access, String())Dim i As Integer = 0Do While i < a.LengthDebug.WriteLine(String.Format(" {0}" & Microsoft.VisualBasic.Constants.vbTab & "{1}", a(i), a(i + 1)))i += 2LoopEnd IfSetUserContext(contextManager, participant, coupon)contextManager.LeaveCommonContext(coupon)Catch e As ExceptionDebug.WriteLine(e.Message)End TryEnd SubPrivate Sub SetUserContext(ByVal contextManager As IContextManager, ByVal participant As SecureParticipant, ByVal coupon As Integer)Dim secure As ISecureContextData = TryCast(contextManager, ISecureContextData)Dim userSubject As Subject = New Subject("User")Dim transactionCoupon As Integer = 0Dim noContinue As Boolean = True, disconnect As Boolean = FalseDim reasons As ObjectDim decision As String = "accept"userSubject.Items.Add(New ContextItem("User.id.logon"))userSubject.Items(0).Value = "test"userSubject.Items.Add(New ContextItem("User.co.Name"))userSubject.Items(1).Value = "Test User"TryDim messageDigest, appSignature As StringDim values As List(Of String) = New List(Of String)()For Each v As Object In userSubject.ToItemValueArray()values.Add(v.ToString())Next vtransactionCoupon = contextManager.StartContextChanges(coupon)'' Create digital signature'messageDigest = coupon.ToString() & String.Join("", userSubject.ToItemNameArray()) + String.Join("", values.ToArray()) + transactionCoupon.ToString()appSignature = participant.CreateSignature(messageDigest)secure.SetItemValues(coupon, userSubject.ToItemNameArray(), userSubject.ToItemValueArray(), transactionCoupon, appSignature)reasons = contextManager.EndContextChanges(transactionCoupon, noContinue)'' If any application responded that they cannot apply the change we need to display' a dialog that displays the reasons for the problems.'If (Not reasons Is Nothing AndAlso (CType(reasons, String())).Length > 0) OrElse noContinue ThenDim pd As ProblemDialog = New ProblemDialog(CType(reasons, String()), noContinue)Dim result As DialogResultresult = pd.ShowDialog()If noContinue Thendecision = "cancel"End IfIf result = System.Windows.Forms.DialogResult.OK Thendecision = "accept"ElseIf result = DialogResult.Cancel Thendecision = "cancel"Elsedecision = "cancel"disconnect = TrueEnd IfEnd If'' If user decided to break context we must leave'contextManager.PublishChangesDecision(transactionCoupon, decision)If disconnect ThencontextManager.LeaveCommonContext(coupon)End IfCatch e As ExceptionDebug.WriteLine(e.Message)End TryEnd Sub<ComVisible(True)>Public Class SecureParticipantImplements IContextParticipantPublic Const Passcode As String = "A2C053FC-182C-4167-BB56-EE394BC5DB05"Public Const ApplicationName As String = "LEADTOOLS CCOW App"Private _KeyContainer As KeyContainer = NothingPublic ReadOnly Property PublicKey() As StringGetIf Not _KeyContainer Is Nothing ThenReturn Utils.BinaryEncode(_KeyContainer.GetPublicKey())End IfReturn String.EmptyEnd GetEnd PropertyPublic Sub New()_KeyContainer = New KeyContainer(ApplicationName)End SubPublic Function CreateSignature(ByVal messageDigest As String) As StringDim signature As Byte() = _KeyContainer.Sign(messageDigest)Return Utils.BinaryEncode(signature)End FunctionPublic Sub CommonContextTerminated() Implements IContextParticipant.CommonContextTerminatedConsole.WriteLine("CommonContextTerminated")End SubPublic Sub ContextChangesAccepted(ByVal contextCoupon As Integer) Implements IContextParticipant.ContextChangesAcceptedConsole.WriteLine("ContextChangesAccepted")End SubPublic Sub ContextChangesCanceled(ByVal contextCoupon As Integer) Implements IContextParticipant.ContextChangesCanceledConsole.WriteLine("ContextChangesCanceled")End SubPublic Function ContextChangesPending(ByVal contextCoupon As Integer, ByRef reason As String) As String Implements IContextParticipant.ContextChangesPendingreason = String.EmptyConsole.WriteLine("ContextChangesPending")Return "accept"End FunctionPublic Sub Ping() Implements IContextParticipant.PingEnd SubEnd Class
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
