public static void ExecuteMethod_UpdateAccountGroupSummaryContainers(string groupId, GroupContainer groupContainer, string[] accountIDs)
        {
            foreach (string accountID in accountIDs)
            {
                int retryCount = 3;
                VirtualOwner accountOwner = new VirtualOwner("acc", accountID);
                while (retryCount-- > 0)
                {
                    try
                    {
                        GroupSummaryContainer summaryContainer =
                            GroupSummaryContainer.RetrieveFromOwnerContent(accountOwner, "default");
                        var groupToUpdate =
                            summaryContainer.GroupCollection.CollectionContent.FirstOrDefault(grp => grp.ID == groupId);
                        if (groupToUpdate != null)
                        {
                            summaryContainer.GroupCollection.CollectionContent.Remove(groupToUpdate);
                            summaryContainer.GroupCollection.CollectionContent.Add(groupContainer.GroupProfile);
                            summaryContainer.StoreInformation(accountOwner);
                        }
                        break; // break while
                    }
                    catch
                    {

                    }
                }
            }
        }
 public static AccountContainer GetTarget_AccountContainer(string accountID)
 {
     VirtualOwner owner = new VirtualOwner("acc", accountID);
     var accountContainer = AccountContainer.RetrieveFromOwnerContent(owner, "default");
     if (accountContainer == null)
     {
         accountContainer = AccountContainer.CreateDefault();
         accountContainer.SetLocationAsOwnerContent(owner, "default");
         accountContainer.StoreInformation();
     }
     return accountContainer;
 }
 public static AccountRootAndContainer[] GetTarget_AccountRootsAndContainers(TBRGroupRoot groupRoot)
 {
     var accountIDs = groupRoot.Group.Roles.CollectionContent.
         Select(role => role.Email.EmailAddress).
         Select(email =>
         {
             string emailRootID = TBREmailRoot.GetIDFromEmailAddress(email);
             TBREmailRoot emailRoot = TBREmailRoot.RetrieveFromDefaultLocation(emailRootID);
             return emailRoot.Account.ID;
         }).Distinct().ToArray();
     List<AccountRootAndContainer> result = new List<AccountRootAndContainer>();
     foreach(var accountID in accountIDs)
     {
         TBRAccountRoot accountRoot = TBRAccountRoot.RetrieveFromDefaultLocation(accountID);
         VirtualOwner owner = new VirtualOwner("acc", accountID);
         var accountContainer = AccountContainer.RetrieveFromOwnerContent(owner, "default");
         AccountRootAndContainer accountRootAndContainer = new AccountRootAndContainer
                                                               {
                                                                   AccountContainer = accountContainer,
                                                                   AccountRoot = accountRoot
                                                               };
         result.Add(accountRootAndContainer);
     }
     return result.ToArray();
 }
 public static GroupContainer GetTarget_GroupContainer(TBRGroupRoot groupRoot)
 {
     string groupID = groupRoot.Group.ID;
     VirtualOwner owner = new VirtualOwner("grp", groupID);
     var groupContainer = GroupContainer.RetrieveFromOwnerContent(owner, "default");
     if (groupContainer == null)
     {
         groupContainer = GroupContainer.CreateDefault();
         groupContainer.SetLocationAsOwnerContent(owner, "default");
         groupContainer.GroupProfile.GroupName = groupRoot.Group.Title;
         groupContainer.StoreInformation();
     }
     return groupContainer;
 }
 public static GroupSummaryContainer GetTarget_GroupSummaryContainer(string accountID)
 {
     VirtualOwner owner = new VirtualOwner("acc", accountID);
     var groupSummaryContainer = GroupSummaryContainer.RetrieveFromOwnerContent(owner, "default");
     return groupSummaryContainer;
 }
 public static GroupContainer GetTarget_GroupContainer(TBRGroupRoot groupRoot)
 {
     VirtualOwner groupOwner = new VirtualOwner("grp", groupRoot.Group.ID);
     var groupContainer = GroupContainer.RetrieveFromOwnerContent(groupOwner, "default");
     return groupContainer;
 }
 public static AccountContainer GetTarget_AccountContainer(string accountID)
 {
     VirtualOwner owner = new VirtualOwner("acc", accountID);
     var accountContainer = AccountContainer.RetrieveFromOwnerContent(owner, "default");
     return accountContainer;
 }
コード例 #8
0
        private void HandleEncryptedDeviceRequest(HttpContext context)
        {
            var request = context.Request;
            var response = context.Response;
            var authorization = request.Headers["Authorization"];
            var authTokens = authorization.Split(':');
            IContainerOwner owner = null;
            if (request.Path.StartsWith("/auth/grp/"))
            {
                string groupID = GetGroupID(context.Request.Path);
                owner = new VirtualOwner("grp", groupID);
            }
            else
                throw new NotSupportedException("Account device requests not yet supported");
            string ivStr = authTokens[1];
            string trustID = authTokens[2];
            string contentName = authTokens[3];
            DeviceMembership deviceMembership = DeviceMembership.RetrieveFromOwnerContent(owner, trustID);
            if(deviceMembership == null)
                throw new InvalidDataException("Device membership not found");
            if(deviceMembership.IsValidatedAndActive == false)
                throw new SecurityException("Device membership not valid and active");
            InformationContext.Current.Owner = owner;
            InformationContext.Current.ExecutingForDevice = deviceMembership;
            if (request.RequestType == "GET")
            {
                string contentPath = request.Path.Substring(AuthGroupPrefixLen + GuidIDLen + 1);
                if(contentPath.Contains("TheBall.CORE"))
                    throw new SecurityException("Invalid request location");
                var blob = StorageSupport.GetOwnerBlobReference(owner, contentPath);

                AesManaged aes = new AesManaged();
                aes.KeySize = SymmetricSupport.AES_KEYSIZE;
                aes.BlockSize = SymmetricSupport.AES_BLOCKSIZE;
                aes.GenerateIV();
                aes.Key = deviceMembership.ActiveSymmetricAESKey;
                aes.Padding = SymmetricSupport.PADDING_MODE;
                aes.Mode = SymmetricSupport.AES_MODE;
                aes.FeedbackSize = SymmetricSupport.AES_FEEDBACK_SIZE;
                var ivBase64 = Convert.ToBase64String(aes.IV);
                response.Headers.Add("IV", ivBase64);
                var responseStream = response.OutputStream;
                var encryptor = aes.CreateEncryptor(aes.Key, aes.IV);
                var cryptoStream = new CryptoStream(responseStream, encryptor, CryptoStreamMode.Write);
                blob.DownloadToStream(cryptoStream);
                cryptoStream.Close();
            } else if (request.RequestType == "POST")
            {
                if (contentName.StartsWith(DeviceSupport.OperationPrefixStr))
                {
                    string operationName = contentName.Substring(DeviceSupport.OperationPrefixStr.Length);
                    var reqStream = request.GetBufferedInputStream();
                    AesManaged decAES = new AesManaged
                        {
                            KeySize = SymmetricSupport.AES_KEYSIZE,
                            BlockSize = SymmetricSupport.AES_BLOCKSIZE,
                            IV = Convert.FromBase64String(ivStr),
                            Key = deviceMembership.ActiveSymmetricAESKey,
                            Padding = SymmetricSupport.PADDING_MODE,
                            Mode = SymmetricSupport.AES_MODE,
                            FeedbackSize = SymmetricSupport.AES_FEEDBACK_SIZE
                        };
                    var reqDecryptor = decAES.CreateDecryptor(decAES.Key, decAES.IV);

                    AesManaged encAES = new AesManaged
                        {
                            KeySize = SymmetricSupport.AES_KEYSIZE,
                            BlockSize = SymmetricSupport.AES_BLOCKSIZE,
                            Key = deviceMembership.ActiveSymmetricAESKey,
                            Padding = SymmetricSupport.PADDING_MODE,
                            Mode = SymmetricSupport.AES_MODE,
                            FeedbackSize = SymmetricSupport.AES_FEEDBACK_SIZE
                        };
                    encAES.GenerateIV();
                    var respivBase64 = Convert.ToBase64String(encAES.IV);
                    response.Headers.Add("IV", respivBase64);
                    var responseStream = response.OutputStream;
                    var respEncryptor = encAES.CreateEncryptor(encAES.Key, encAES.IV);

                    using (CryptoStream reqDecryptStream = new CryptoStream(reqStream, reqDecryptor, CryptoStreamMode.Read),
                            respEncryptedStream = new CryptoStream(responseStream, respEncryptor, CryptoStreamMode.Write))
                    {
                        OperationSupport.ExecuteOperation(operationName,
                            new Tuple<string, object>("InputStream", reqDecryptStream),
                            new Tuple<string, object>("OutputStream", respEncryptedStream));
                    }
                }
                else
                {
                    string contentRoot = deviceMembership.RelativeLocation + "_Input";
                    string blobName = contentRoot + "/" + contentName;
                    var blob = StorageSupport.GetOwnerBlobReference(owner, blobName);
                    if (blob.Name != blobName)
                        throw new InvalidDataException("Invalid content name");
                    var reqStream = request.GetBufferedInputStream();
                    AesManaged aes = new AesManaged();
                    aes.KeySize = SymmetricSupport.AES_KEYSIZE;
                    aes.BlockSize = SymmetricSupport.AES_BLOCKSIZE;
                    aes.IV = Convert.FromBase64String(ivStr);
                    aes.Key = deviceMembership.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(reqStream, decryptor, CryptoStreamMode.Read);
                    blob.UploadFromStream(cryptoStream);
                }
                response.StatusCode = 200;
                response.End();
            }
            else
                throw new NotSupportedException("Device request type not supported: " + request.RequestType);
        }
コード例 #9
0
 public static GroupContainer GetTarget_GroupInternalContainer(string groupID)
 {
     VirtualOwner owner = new VirtualOwner("grp", groupID);
     var groupContainer = GroupContainer.RetrieveFromOwnerContent(owner, "default");
     return groupContainer;
 }
コード例 #10
0
ファイル: WorkerSupport.cs プロジェクト: kallex/Caloom
 private static void ProcessSingleOperation(OperationRequest operationRequest)
 {
     if (operationRequest.PublishWebContent != null)
         ProcessPublishWebContent(operationRequest.PublishWebContent);
     if (operationRequest.UpdateWebContentOperation != null)
         ProcessUpdateWebContent(operationRequest.UpdateWebContentOperation);
     if (operationRequest.SubscriberNotification != null)
         WorkerSupport.ExecuteSubscription(operationRequest.SubscriberNotification);
     if (operationRequest.RefreshDefaultViewsOperation != null)
         WorkerSupport.RefreshDefaultViews(operationRequest.RefreshDefaultViewsOperation);
     if (operationRequest.DeleteEntireOwner != null)
     {
         VirtualOwner virtualOwner = new VirtualOwner(operationRequest.DeleteEntireOwner.ContainerName,
             operationRequest.DeleteEntireOwner.LocationPrefix);
         DeleteEntireOwner(virtualOwner);
     }
     if(operationRequest.DeleteOwnerContent != null)
     {
         VirtualOwner virtualOwner = new VirtualOwner(operationRequest.DeleteOwnerContent.ContainerName,
             operationRequest.DeleteOwnerContent.LocationPrefix);
         DeleteOwnerContent(virtualOwner);
     }
     if(operationRequest.SubscriptionChainRequest != null)
         WorkerSupport.ExecuteSubscriptionChain(operationRequest.SubscriptionChainRequest);
 }
コード例 #11
0
ファイル: WorkerSupport.cs プロジェクト: kallex/Caloom
 private static void DeleteOwnerContent(VirtualOwner containerOwner)
 {
     StorageSupport.DeleteContentsFromOwner(containerOwner);
 }
 public static GroupSummaryContainer GetTarget_GroupSummaryContainer(string accountID)
 {
     VirtualOwner owner = new VirtualOwner("acc", accountID);
     var groupSummaryContainer = GroupSummaryContainer.RetrieveFromOwnerContent(owner, "default");
     if (groupSummaryContainer == null)
     {
         groupSummaryContainer = GroupSummaryContainer.CreateDefault();
         groupSummaryContainer.SetLocationAsOwnerContent(owner, "default");
         groupSummaryContainer.StoreInformation();
     }
     return groupSummaryContainer;
 }
コード例 #13
0
 /*
 private static string GetBlobPath(HttpRequest request)
 {
     string contentPath = request.Path;
     if (contentPath.StartsWith(AboutPrefix) == false)
         throw new NotSupportedException("Content path for other than about/ is not supported");
     return contentPath.Substring(1);
 }*/
 private void HandleDeveloperRequest(HttpContext context)
 {
     string requestPath = context.Request.Path;
     string groupID = GetGroupID(context.Request.Path);
     string roleValue = TBCollaboratorRole.CollaboratorRoleValue;
     InformationContext.Current.CurrentGroupRole = roleValue;
     string contentPath;
     if(requestPath.Contains("MediaContent"))
         contentPath = requestPath.Substring(AuthDeveloperPrefixLen);
     else
         contentPath = requestPath.Substring(AuthDeveloperPrefixLen + GuidIDLen + 1);
     VirtualOwner owner = new VirtualOwner(DeveloperAuthPrefix, DeveloperGroupID);
     HandleOwnerRequest(owner, context, contentPath, roleValue);
 }
 public static GroupContainer GetTarget_GroupContainer(string groupId)
 {
     VirtualOwner owner = new VirtualOwner("grp", groupId);
     return GroupContainer.RetrieveFromOwnerContent(owner, "default");
 }