how to encrypt and decrypt messages with more than one sender and more than one receiver?

I am creating a chat app. This app contains private messages and channels. These channels include more than one user.

I want to encrypt messages using AES and to transfer the AES key to users of this channel.

I need a secure transport channel so I used diffie hellman. The problem now is how will I get users to generate the same diffie hellman keys so that I can create a shared key which will be the AES encryption key? I have learned the encryption, but between a sender and a receiver only, but here I have more than one sender and more than one receiver.

I had an idea, to make for all users who share the same channel, the same public and private key. Any user who opens the channel takes the public key from the channel and with his own keys he generates the shared key which forms the AES key. user can encrypts and decrypts any message, no matter who sent it, because all users of this channel have the same keys.

Any other ideas?

Note: I am required to use AES encryption but not deffie hellman, so is there another algorithm better than deffie hellman to do this?

Can a Logitech wireless headphone usb receiver be infected?

So I think they call them “dongles”? The usb wireless receiver that’s plugged into your computer? Can they get virus from a computer that has been infected? I imagine it’s no more vulnerable than say a usb mouse is?

But since these Logitech usb devices like your mouse or headphone receivers do contain some firmwares, I imagine they can be infected though uncommon?

Can’t change data in the Host web from a Remote Event Receiver ItemAdding Event

I’ve build a SharePoint that should modify some information when the user create data.

The addin has some pages (asp.mvc) that lists the lists in the host web. The user select one of the list, then the code registers dynamically the event receiver.

The event receiver itself handles both ItemAdding and ItemUpdating event and should change some of the item’s field dynamically.

I was able to register the RER, I can even step into the receiver when debugging with Visual Studio, and I can actually see the SPRemoteEventResult.ChangedProperties correctly populated. However, even though I’ve no error, the actual date does not reflect my changed.

I suspect this is due to the fact I dynamically register RER, which leeds to authentication troubles.

Here’s how I register my RER (from a POST action in my MVC app) :

    [SharePointContextFilter]     [HttpPost]     public ActionResult Enable(Guid listId)     {         var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);         using (var clientContext = spContext.CreateAppOnlyClientContextForSPHost())         {             if (listId != Guid.Empty)             {                 var serviceUrlRoot = $  "{Request.Url.Scheme}://{Request.Url.Authority}" + Url.Content("~/Services");                  var list = clientContext.Web.Lists.GetById(listId);                 clientContext.Load(list, lst => lst.Title, lst => lst.EventReceivers);                  clientContext.ExecuteQuery();                 var receiver = new EventReceiverDefinitionCreationInformation                 {                     EventType = EventReceiverType.ItemAdding                 };                  //Get WCF URL where this message was handled                 receiver.ReceiverUrl = serviceUrlRoot + "/Services/myreceiver.svc";                  receiver.ReceiverName = "some name";                 receiver.Synchronization = EventReceiverSynchronization.Synchronous;                  //Add the new event receiver to a list in the host web                 list.EventReceivers.Add(receiver);                 clientContext.ExecuteQuery();              }         }         return RedirectToAction("Lists", new { SPHostUrl = spContext.SPHostUrl.ToString() });     } 

I guess this code is OK since the RER are actually triggering.

Here’s how I handle the adding event :

    public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)     {         var result = new SPRemoteEventResult();         var webUrl = properties.ItemEventProperties.WebUrl;          var webUri = new Uri(webUrl);         var realm = TokenHelper.GetRealmFromTargetUrl(webUri);         var accessToken = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, webUri.Authority, realm).AccessToken;          using (var ctx = TokenHelper.GetClientContextWithAccessToken(webUrl, accessToken))         {              result.ChangedItemProperties.Add("MyField", "My dynamic value");          }          return result;     } 

This code does not throw any error when executing. But the list item does not have it’s MyField changed.

As you can see, both registering the RER and handling it’s event is done using App Only context. I tries various other combination, but I never succeed in making everything work as expected.

What’s the correct way to dynamically register RER on list in the host web, on user’s action ?

What’s the correct way to handle adding and updating event when the RER was registered dynamically ?

How to uninstall Citrix Receiver package with confirmation

I am trying to run a command line task on a HP thin Client to uninstall citrix receiver.

The task runs the below command on the client.

sudo apt-get –purge remove -y icaclient-term

it shows it has completed successfully but when I check I can see the receiver is still installed.

On x-terminal I can successfully uninstall by just running sudo apt-get –purge remove icaclient-term

What is the correct command to unsintall with a confirmation when prompted for y/n?

How to post to external api within a SharePoint event receiver

I currently have a working eventReceiver for when an item is updated. It adds some values into fields on the item. no problem.

However, when I add the part I actually need (posting those values somewhere else) it breaks. I simply need to pass those two fields to a remote end point. If I remove that internal try catch which does the post, it all works fine and my fields update.

Any ideas?

Is this even allowed in an event receiver, is there a better way to do this?

using System; using System.Security.Permissions; using Microsoft.SharePoint; using Microsoft.SharePoint.Utilities; using Microsoft.SharePoint.Workflow; using System.Net; using System.Collections.Specialized; using System.Text; namespace DocumentLibrary.BRCS_EventReceiver { /// <summary> /// List Item Events /// </summary> public class BRCS_EventReceiver : SPItemEventReceiver {     /// <summary>     /// An item was added.     /// </summary>     public override void ItemAdded(SPItemEventProperties properties)     {         base.ItemAdded(properties);     }      /// <summary>     /// An item was updated.     /// </summary>     ///      public override void ItemUpdated(SPItemEventProperties properties)     {          base.ItemUpdated(properties);         string fullDocPath = "";         string fullDocID = "";         string responsebody = "hello";         try         {             using (SPWeb web = properties.OpenWeb())             {                 SPListItem currentItem = properties.ListItem;                 string currentSiteURL = properties.ListItem.Web.Site.Url;                 fullDocPath = currentSiteURL + "/" + currentItem.Url;                 fullDocID = properties.ListItemId.ToString();                 currentItem["MajorCategory"] = fullDocPath;                  currentItem["MinorCategory"] = "id: " + fullDocID;                 try                 {                     using (var client = new WebClient())                     {                         NameValueCollection values = new NameValueCollection();                         values["thing1"] = "hello";                         values["thing2"] = "world";                          var response = client.UploadValues("", values);                          responsebody = "done" + Encoding.Default.GetString(response);                     }                 }                 catch (Exception abc) {                     throw abc;                 }                 currentItem["MajorCategoryConfidence"] = responsebody;                 currentItem.Update();              }         }         catch (Exception ex)         {             System.Diagnostics.Debug.WriteLine("error{0}", ex.Message);             System.IO.File.WriteAllText("C:\Temp\ErrorLogBT.txt", ex.Message);             throw ex;         }     }   } 


Unable to Debug Remote Event Receiver using Ngrok reverse proxy. ClientContext will be null + Error “iisexpress.exe has exited with code -1”

I want to test and debug a remote event receiver for my custom list inside sharepoint online. So i did these steps:-

  1. Inside our sharepoint online i created a new developer site collection.

  2. using Visual Studio pro 2015 >> i create a new Visual Studio project of type SP Add-in.

  3. The type = provider-hosted, as follow:- enter image description here

  4. after that i changed the Handle Add-in installed/uninstalled to True:- enter image description here

  5. then i open the Ngrok command line, i enter the following:-

ngrok http –host-header=rewrite 50452// where this port is our RER port inside visual studio

where 50452 is the port for the VS project:- enter image description here

i got the following:- enter image description here

so i updated the AappManifest.xml with the forwarding url:- enter image description here

  1. I update the app permission as follow:- enter image description here

  2. then i run the project >> i got this popup >> i select the custom list named “projects”:- enter image description here

  3. where i got to the break-point inside my code >> but the client content inside my code will be empty:- enter image description here

  4. after that the VS stop running and i got this error:- enter image description here

Here is the full code inside my “AppEventReceiver.svc”

public class AppEventReceiver : IRemoteEventService     {         private const string ReceiverName = "ItemAddedEvent";         private const string ListName = "projects";         /// <summary>         /// Handles app events that occur after the app is installed or upgraded, or when app is being uninstalled.         /// </summary>         /// <param name="properties">Holds information about the app event.</param>         /// <returns>Holds information returned from the app event.</returns>         public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)         {             SPRemoteEventResult result = new SPRemoteEventResult();              switch (properties.EventType)             {                 case SPRemoteEventType.AppInstalled:                     HandleAppInstalled(properties);                     break;                 case SPRemoteEventType.AppUninstalling:                     HandleAppUninstalling(properties);                     break;                 case SPRemoteEventType.ItemAdded:                     HandleItemAdded(properties);                     break;             }               return result;         }         private void HandleAppUninstalling(SPRemoteEventProperties properties)          {              using (ClientContext clientContext =                TokenHelper.CreateAppEventClientContext(properties, false))              {                  if (clientContext != null)                  {                      List myList = clientContext.Web.Lists.GetByTitle(ListName);                      clientContext.Load(myList, p => p.EventReceivers);                      clientContext.ExecuteQuery();                        var rer = myList.EventReceivers.Where(                          e => e.ReceiverName == ReceiverName).FirstOrDefault();                        try                      {                          System.Diagnostics.Trace.WriteLine("Removing ItemAdded receiver at "                                 + rer.ReceiverUrl);                            //This will fail when deploying via F5, but works                          //when deployed to production                          rer.DeleteObject();                          clientContext.ExecuteQuery();                        }                      catch (Exception oops)                      {                          System.Diagnostics.Trace.WriteLine(oops.Message);                      }                    }              }          }         private void HandleAppInstalled(SPRemoteEventProperties properties)          {              using (ClientContext clientContext =                   TokenHelper.CreateAppEventClientContext(properties, false))              {                  if (clientContext != null)                  {                      List myList = clientContext.Web.Lists.GetByTitle(ListName);                      clientContext.Load(myList, p => p.EventReceivers);                      clientContext.ExecuteQuery();                        bool rerExists = false;                        foreach (var rer in myList.EventReceivers)                      {                          if (rer.ReceiverName == ReceiverName)                         {                              rerExists = true;                              System.Diagnostics.Trace.WriteLine("Found existing ItemAdded receiver at "                                  + rer.ReceiverUrl);                          }                      }                        if (!rerExists)                      {                          EventReceiverDefinitionCreationInformation receiver =                               new EventReceiverDefinitionCreationInformation();                          receiver.EventType = EventReceiverType.ItemAdded;                           //Get WCF URL where this message was handled                          OperationContext op = OperationContext.Current;                         Message msg = op.RequestContext.RequestMessage;                            receiver.ReceiverUrl = msg.Headers.To.ToString();                            receiver.ReceiverName = ReceiverName;                          receiver.Synchronization = EventReceiverSynchronization.Synchronous;                         myList.EventReceivers.Add(receiver);                            clientContext.ExecuteQuery();                            System.Diagnostics.Trace.WriteLine("Added ItemAdded receiver at "                                  + msg.Headers.To.ToString());                      }                  }              }          }         private void HandleItemAdded(SPRemoteEventProperties properties)          {              using (ClientContext clientContext =                   TokenHelper.CreateRemoteEventReceiverClientContext(properties))              {                  if (clientContext != null)                  {                      try                      {                          List photos = clientContext.Web.Lists.GetById(                                properties.ItemEventProperties.ListId);                          ListItem item = photos.GetItemById(                               properties.ItemEventProperties.ListItemId);                          clientContext.Load(item);                          clientContext.ExecuteQuery();                            item["Title"] += "\nUpdated by RER " +                                 System.DateTime.Now.ToLongTimeString();                          item.Update();                          clientContext.ExecuteQuery();                      }                      catch (Exception oops)                      {                          System.Diagnostics.Trace.WriteLine(oops.Message);                      }                  }                }            }          /// <summary>         /// This method is a required placeholder, but is not used by app events.         /// </summary>         /// <param name="properties">Unused.</param>         public void ProcessOneWayEvent(SPRemoteEventProperties properties)         {             throw new NotImplementedException();         }      } 

So can anyone advice why i am getting Null for the ClientContext ? and why the project will stop running?

How to get deleted file when itemDeleted event fire in remote event receiver

How to get the deleted file when itemDeleted event fire in remote event receiver in SharePoint Online.

I have tried as follows but this does not work:

List photos = clientContext.Web.Lists.GetById(properties.ItemEventProperties.ListId); ListItem item = photos.GetItemById(properties.ItemEventProperties.ListItemId); string filename = Convert.ToString(item["FileLeafRef"]);