public static string GetTarget_ContentRootLocation(AuthenticatedAsActiveDevice authenticatedAsActiveDevice)
 {
     var contentRootLocation = StorageSupport.GetOwnerContentLocation(InformationContext.CurrentOwner, authenticatedAsActiveDevice.RelativeLocation) + "/";
     if (contentRootLocation.EndsWith("/") == false)
         contentRootLocation += "/";
     return contentRootLocation;
 }
 public static void ExecuteMethod_CopyItemsToCopyToTargetDevice(AuthenticatedAsActiveDevice authenticatedAsActiveDevice, SyncCopyContentToDeviceTarget.CallPrepareTargetAndListItemsToCopyReturnValue callPrepareTargetAndListItemsToCopyOutput)
 {
     var itemsToCopy = callPrepareTargetAndListItemsToCopyOutput.ItemsToCopy;
     foreach(var itemToCopy in itemsToCopy)
     {
         string ownerRelatedLocation = StorageSupport.RemoveOwnerPrefixIfExists(itemToCopy.ContentLocation);
         DeviceSupport.PushContentToDevice(authenticatedAsActiveDevice, ownerRelatedLocation, ownerRelatedLocation);
     }
 }
 public static void ExecuteMethod_NegotiateWithTarget(AuthenticatedAsActiveDevice authenticatedAsActiveDevice, byte[] sharedSecretData, byte[] sharedSecretPayload)
 {
     var negotiationResult =
         SecurityNegotiationManager.PerformEKEInitiatorAsBob(authenticatedAsActiveDevice.NegotiationURL,
                                                             sharedSecretData, authenticatedAsActiveDevice.AuthenticationDescription,
                                                             sharedSecretPayload);
     authenticatedAsActiveDevice.ActiveSymmetricAESKey = negotiationResult.AESKey;
     authenticatedAsActiveDevice.EstablishedTrustID = negotiationResult.EstablishedTrustID;
     authenticatedAsActiveDevice.IsValidatedAndActive = true;
 }
        public static void ExecuteMethod_CallDeleteDeviceOnRemoteSide(AuthenticatedAsActiveDevice authenticatedAsActiveDevice)
        {
            try
            {
                var result = DeviceSupport.ExecuteRemoteOperation<DeviceOperationData>(authenticatedAsActiveDevice.ID,
                                                                                       "TheBall.CORE.RemoteDeviceCoreOperation", new DeviceOperationData {OperationRequestString = "DELETEREMOTEDEVICE"});
            }
            catch
            {

            }
        }
 public static SyncCopyContentToDeviceTarget.CallPrepareTargetAndListItemsToCopyReturnValue ExecuteMethod_CallPrepareTargetAndListItemsToCopy(AuthenticatedAsActiveDevice authenticatedAsActiveDevice, ContentItemLocationWithMD5[] thisSideContentMd5List)
 {
     DeviceOperationData deviceOperationData = new DeviceOperationData
         {
             OperationRequestString = "SYNCCOPYCONTENT",
             OperationSpecificContentData = thisSideContentMd5List,
             OperationParameters = new string[] { SyncSupport.RelativeRootFolderValue}
         };
     deviceOperationData = DeviceSupport.ExecuteRemoteOperation<DeviceOperationData>(authenticatedAsActiveDevice.ID,
                                                                                     "TheBall.CORE.RemoteDeviceCoreOperation", deviceOperationData);
     var returnValue = new SyncCopyContentToDeviceTarget.CallPrepareTargetAndListItemsToCopyReturnValue
         {
             ItemsToCopy = deviceOperationData.OperationSpecificContentData.Where(item => item.ItemDatas.Any(iData => iData.DataName == "OPTODO" && iData.ItemTextData == "COPY")).ToArray(),
             ItemsDeleted = deviceOperationData.OperationSpecificContentData.Where(item => item.ItemDatas.Any(iData => iData.DataName == "OPDONE" && iData.ItemTextData == "DELETED")).ToArray()
         };
     return returnValue;
 }
 public static void ExecuteMethod_FetchInputToStorage(IContainerOwner owner, string queryParameters, InformationInput informationInput, string inputFetchLocation, string inputFetchName, AuthenticatedAsActiveDevice authenticatedAsActiveDevice)
 {
     string url = string.IsNullOrEmpty(queryParameters)
                          ? informationInput.LocationURL
                          : informationInput.LocationURL + queryParameters;
     if (authenticatedAsActiveDevice == null)
     {
         WebRequest getRequest = WebRequest.Create(url);
         var response = getRequest.GetResponse();
         var stream = response.GetResponseStream();
         var targetBlob = StorageSupport.CurrActiveContainer.GetBlob(inputFetchLocation + "/" + inputFetchName,
                                                                     owner);
         targetBlob.UploadFromStream(stream);
     }
     else
     {
         HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
         request.Method = "GET";
         request.Headers.Add("Authorization", "DeviceAES::" + authenticatedAsActiveDevice.EstablishedTrustID + ":");
         HttpWebResponse response = (HttpWebResponse) request.GetResponse();
         if (response.StatusCode != HttpStatusCode.OK)
             throw new InvalidOperationException("Authroized fetch failed with non-OK status code");
         string ivStr = response.Headers["IV"];
         string contentRoot = inputFetchLocation;
         string blobName = contentRoot + "/" + inputFetchName;
         var blob = StorageSupport.GetOwnerBlobReference(owner, blobName);
         if (blob.Name != blobName)
             throw new InvalidDataException("Invalid content name");
         var respStream = response.GetResponseStream();
         AesManaged aes = new AesManaged();
         aes.KeySize = SymmetricSupport.AES_KEYSIZE;
         aes.BlockSize = SymmetricSupport.AES_BLOCKSIZE;
         aes.IV = Convert.FromBase64String(ivStr);
         aes.Key = authenticatedAsActiveDevice.ActiveSymmetricAESKey;
         aes.Padding = SymmetricSupport.PADDING_MODE;
         aes.Mode = SymmetricSupport.AES_MODE;
         aes.FeedbackSize = SymmetricSupport.AES_FEEDBACK_SIZE;
         var decryptor = aes.CreateDecryptor(aes.Key, aes.IV);
         CryptoStream cryptoStream = new CryptoStream(respStream, decryptor, CryptoStreamMode.Read);
         blob.UploadFromStream(cryptoStream);
     }
 }
示例#7
0
 private void CopyContentFrom(AuthenticatedAsActiveDevice sourceObject)
 {
     AuthenticationDescription = sourceObject.AuthenticationDescription;
             SharedSecret = sourceObject.SharedSecret;
             ActiveSymmetricAESKey = sourceObject.ActiveSymmetricAESKey;
             EstablishedTrustID = sourceObject.EstablishedTrustID;
             IsValidatedAndActive = sourceObject.IsValidatedAndActive;
             NegotiationURL = sourceObject.NegotiationURL;
             ConnectionURL = sourceObject.ConnectionURL;
 }
示例#8
0
partial         static void CreateCustomDemo(ref AuthenticatedAsActiveDevice customDemoObject);
示例#9
0
 public static AuthenticatedAsActiveDevice CreateDefault()
 {
     var result = new AuthenticatedAsActiveDevice();
             return result;
 }
 public static void ExecuteMethod_PushToInformationOutput(IContainerOwner owner, InformationOutput informationOutput, string destinationUrl, string destinationContentName, string localContentUrl, AuthenticatedAsActiveDevice authenticatedAsActiveDevice)
 {
     if(authenticatedAsActiveDevice == null)
         throw new NotSupportedException("Push not currently supported without authenticated as device connection");
     DeviceSupport.PushContentToDevice(authenticatedAsActiveDevice, localContentUrl, destinationContentName);
 }
 public static void ExecuteMethod_DeleteAuthenticatedAsActiveDevice(AuthenticatedAsActiveDevice authenticatedAsActiveDevice)
 {
     authenticatedAsActiveDevice.DeleteInformationObject();
 }
 public static string GetTarget_RemoteBallSecretRequestUrl(AuthenticatedAsActiveDevice authenticatedAsActiveDevice)
 {
     string baseWebsocketUrl = authenticatedAsActiveDevice.NegotiationURL.Replace("wss://", "https://").Replace("ws://", "http://");
     int lastIndexOfSlash = baseWebsocketUrl.LastIndexOf('/');
     return baseWebsocketUrl.Substring(0, lastIndexOfSlash) + "/RequestSharedSecret";
 }
 public static void ExecuteMethod_StoreObject(AuthenticatedAsActiveDevice authenticatedAsActiveDevice)
 {
     authenticatedAsActiveDevice.StoreInformation();
 }