Implements OpenSSH Agent
Inheriting classes should implement the platform specific communication to get a message from a client and then call AnswerMessage method
Inheritance: IAgent, IDisposable
Example #1
0
        private void PageantAgent_MessageReceived(object aSender,
            Agent.MessageReceivedEventArgs aEventArgs)
        {
            var mainWindow = pluginHost.MainWindow;

              var thread = new Thread(
            delegate()
            {
              mainWindow.Invoke(
            (MethodInvoker)delegate()
              {
            // don't do anything - we are just seeing if the thread is blocked
              });
            });
              thread.Name = "Check";
              thread.Start();
              // only try to unlock databases if main thread is not blocked
              if (thread.Join(1000)) {
            mainWindow.Invoke((MethodInvoker)delegate()
            {
              if (Options.UnlockOnActivity) {
            foreach (var document in mainWindow.DocumentManager.Documents) {
            if (mainWindow.IsFileLocked(document)) {
                mainWindow.OpenDatabase(document.LockedIoc, null, false);
              }
            }
              }
            });
              } else {
            thread.Abort();
              }
        }
Example #2
0
 private void PageantAgent_KeyUsed(object sender, Agent.KeyUsedEventArgs e)
 {
     if (Options.ShowBalloon) {
       var appText = e.OtherProcess == null
       ? Translatable.NotifyKeyFetchedUnknownApplication
       : string.Format("{0} ({1})", e.OtherProcess.MainWindowTitle, e.OtherProcess.ProcessName);
     string notifyText = string.Format(Translatable.NotifyKeyFetched,
       e.Key.Comment, appText);
     uiHelper.ShowBalloonNotification(notifyText);
       }
 }
Example #3
0
 private void PageantAgent_Locked(object aSender, Agent.LockEventArgs aEventArgs)
 {
     if (Options.ShowBalloon) {
     string notifyText;
     if (aEventArgs.IsLocked) {
       notifyText = Translatable.NotifyLocked;
     } else {
       notifyText = Translatable.NotifyUnlocked;
     }
     uiHelper.ShowBalloonNotification(notifyText);
       }
 }
Example #4
0
 void mAgent_KeyListChanged(object aSender, Agent.KeyListChangeEventArgs aEventArgs)
 {
     // TODO figure out how to invoke Qt UI thread
       ReloadData ();
 }
Example #5
0
 void mAgent_Locked(object aSender, Agent.LockEventArgs aEventArgs)
 {
     // TODO figure out how to invoke Qt UI thread
       UpdateUIState ();
 }
 private void Agent_Locked(object aSender, Agent.LockEventArgs aEventArgs)
 {
     UpdateUI();
 }
Example #7
0
   private void mAgent_KeyListChanged(object aSender,
 Agent.KeyListChangeEventArgs aEventArgs)
   {
       ReloadData();
   }
Example #8
0
 public void AddConstraint(Agent.KeyConstraint aConstraint)
 {
     if ((aConstraint.Data == null && aConstraint.Type.GetDataType() != null) ||
       (aConstraint.Data != null &&
        aConstraint.Data.GetType() != aConstraint.Type.GetDataType())) {
     throw new ArgumentException("Malformed constraint", "aConstraint");
       }
       keyConstraints.Add(aConstraint);
 }
Example #9
0
   public static bool HasConstraint(this ISshKey aKey,
 Agent.KeyConstraintType aType)
   {
       return aKey.Constraints.Count(c => c.Type == aType) > 0;
   }
Example #10
0
 /// <summary>
 /// Prepends header 
 /// </summary>
 /// <param name="aMessage">message number to include in header</param>
 public void InsertHeader(Agent.Message aMessage)
 {
     byteList.Insert(0, (byte)aMessage);
       byte[] blobLength = byteList.Count.ToBytes();
       byteList.InsertRange(0, blobLength);
 }
Example #11
0
 /// <summary>
 /// Prepends header 
 /// </summary>
 /// <param name="aMessage">message number to include in header</param>
 /// <param name="aHeaderData">data to include in header</param>
 public void InsertHeader(Agent.Message aMessage, int aHeaderData)
 {
     byteList.InsertRange(0, aHeaderData.ToBytes());
       InsertHeader(aMessage);
 }
Example #12
0
 private void AgentLockHandler(object aSender, Agent.LockEventArgs aArgs)
 {
     //      Invoke((MethodInvoker)delegate()
     //      {
     //        UpdateVisibility();
     //        UpdateButtonStates();
     //      });
 }
Example #13
0
        private void AgentKeyListChangeHandler(object aSender,
      Agent.KeyListChangeEventArgs aArgs)
        {
            //      if (IsDisposed) {
            //        return;
            //      }
              switch (aArgs.Action) {
            case Agent.KeyListChangeEventAction.Add:
              Gtk.Application.Invoke(delegate(object aSender1, EventArgs aEventArgs1)
              {
            mKeyCollection.AddNode(new KeyNode(aArgs.Key));
            UpdateVisibility();
              });
              break;
            case Agent.KeyListChangeEventAction.Remove:
              Gtk.Application.Invoke(delegate(object aSender1, EventArgs aEventArgs1)
              {
            var matchFingerprint = aArgs.Key.GetMD5Fingerprint().ToHexString();

            var matches = mKeyCollection.Cast<KeyNode>()
              .Where(k => k.Fingerprint == matchFingerprint);
            foreach (var keyNode in matches) {
              mKeyCollection.RemoveNode(keyNode);
            }
            UpdateVisibility();
              });
              break;
              }
        }
Example #14
0
 /// <summary>
 /// prepares a message with no data
 /// </summary>
 private void PrepareSimpleMessage(Agent.Message aMessage)
 {
   BlobBuilder builder = new BlobBuilder();
   builder.InsertHeader(aMessage);
   PrepareMessage(builder);
 }