Example #1
0
        public SafeIpcCredential(IpcCredentialType typeIn, object credDataIn)
        {
            ipcCredential      = new IpcCredential();
            ipcCredential.type = typeIn;
            if (null != credDataIn)
            {
                switch (typeIn)
                {
                case IpcCredentialType.SymmetricKey:
                    SymmetricKeyCredential symmKey = (SymmetricKeyCredential)credDataIn;
                    ipcCredential.credData = Marshal.AllocHGlobal(Marshal.SizeOf(symmKey));
                    Marshal.StructureToPtr(symmKey, ipcCredential.credData, false);
                    break;

                case IpcCredentialType.OAuth2:
                    IpcOAuth2CallbackInfo oauth2Key = (IpcOAuth2CallbackInfo)credDataIn;
                    oAuth2CallbackInfo     = GCHandle.Alloc(oauth2Key);
                    ipcCredential.credData = Marshal.AllocHGlobal(Marshal.SizeOf(oauth2Key));
                    Marshal.StructureToPtr((IpcOAuth2CallbackInfo)oAuth2CallbackInfo.Target,
                                           ipcCredential.credData, false);
                    break;

                case IpcCredentialType.X509Certificate:
                    ipcCredential.credData = (IntPtr)credDataIn;
                    break;

                default:
                    credData = IntPtr.Zero;
                    throw new NotImplementedException();
                }
            }
        }
Example #2
0
 internal void Dispose()
 {
     if (IntPtr.Zero != pcCredential)
     {
         IpcCredential cred = new IpcCredential();
         Marshal.PtrToStructure(pcCredential, cred);
         pcCredential = IntPtr.Zero;
         cred.Dispose();
     }
 }
Example #3
0
 internal IpcPromptContext(IntPtr wndParent, IpcCredential credential, WaitHandle cancelEvent)
     : this()
 {
     hWndParent   = wndParent;
     hCancelEvent = (cancelEvent != null) ? cancelEvent.SafeWaitHandle : new SafeWaitHandle(IntPtr.Zero, true);
     if (null != credential)
     {
         pcCredential = Marshal.AllocHGlobal(Marshal.SizeOf(credential));
         Marshal.StructureToPtr(credential, pcCredential, false);
     }
     else
     {
         pcCredential = IntPtr.Zero;
     }
 }
Example #4
0
 public IpcPromptContext(IntPtr wndParent, IpcCredential credential, IntPtr cancelEvent)
     : this()
 {
     hWndParent   = wndParent;
     hCancelEvent = cancelEvent;
     if (null != credential)
     {
         pcCredential = Marshal.AllocHGlobal(Marshal.SizeOf(credential));
         Marshal.StructureToPtr(credential, pcCredential, false);
     }
     else
     {
         pcCredential = IntPtr.Zero;
     }
 }
Example #5
0
 protected void Dispose(bool disposing)
 {
     if (ipcCredential != null)
     {
         if (ipcCredential.credData != IntPtr.Zero)
         {
             if (ipcCredential.type != IpcCredentialType.X509Certificate)
             {
                 Marshal.FreeHGlobal(ipcCredential.credData);
             }
             ipcCredential.credData = IntPtr.Zero;
         }
         ipcCredential = null;
     }
     if (oAuth2CallbackInfo != null && oAuth2CallbackInfo.IsAllocated)
     {
         oAuth2CallbackInfo.Free();
     }
 }
Example #6
0
 public SafeIpcPromptContext(IntPtr wndParent, IpcCredential credential, IntPtr cancelEvent)
 {
     internalClass = new IpcPromptContext(wndParent, credential, cancelEvent);
 }
 internal void Dispose()
 {
     if (IntPtr.Zero != pcCredential)
     {
         IpcCredential cred = new IpcCredential();
         Marshal.PtrToStructure(pcCredential, cred);
         pcCredential = IntPtr.Zero;
         cred.Dispose();
     }
 }
 public IpcPromptContext(IntPtr wndParent, IpcCredential credential, IntPtr cancelEvent)
     : this()
 {
     hWndParent = wndParent;
     hCancelEvent = cancelEvent;
     if (null != credential)
     {
         pcCredential = Marshal.AllocHGlobal(Marshal.SizeOf(credential));
         Marshal.StructureToPtr(credential, pcCredential, false);
     }
     else
     {
         pcCredential = IntPtr.Zero;
     }
 }
 public SafeIpcPromptContext(IntPtr wndParent, IpcCredential credential, IntPtr cancelEvent)
 {
     internalClass = new IpcPromptContext(wndParent, credential, cancelEvent);
 }