Пример #1
0
        /// <summary>
        /// Call the execute method of a given node an enqueues all temporarily added nodes
        /// </summary>
        /// <typeparam name="T">Node type</typeparam>
        /// <param name="nodeScope">Scope to put and push data from/to</param>
        /// <param name="index">Index where the temporarily created nodes should be added to</param>
        /// <returns>Return value of the executed node</returns>
        public bool Execute <T>(NodeScope <T> nodeScope, int?index = null) where T : ActionNode
        {
            tempNextNodes = new List <NodeScope <ActionNode> >();

            if (nodeScope.Node.Execute(this, nodeScope.Scope))
            {
                // Zero based index addon for index
                int indexAddon = 0;
                foreach (var nextNode in tempNextNodes)
                {
                    if (nextNode != null)
                    {
                        if (index.HasValue)
                        {
                            nextNodes.Insert(index.Value + indexAddon, nextNode);
                        }
                        else
                        {
                            nextNodes.Add(nextNode);
                        }
                    }

                    /* Increase index for next item
                     * Item 1
                     *   Item a
                     *   Item b
                     *   Item c <--- increased index = 2
                     * Item 2
                     * Item 3
                     */
                    indexAddon++;
                }

                return(true);
            }

            return(false);
        }
        internal TheUserDetails CloneToUser(Guid pUserID)
        {
            TheUserDetails tMinUser = TheUserManager.GetUserByID(pUserID);

            if (tMinUser == null)
            {
                return(null);
            }

            Guid pSessionID = tMinUser.CurrentSessionID;

            TheUserDetails tU = new TheUserDetails
            {
                ApplicationName   = ApplicationName,
                AssignedEasyScope = AssignedEasyScope,  //OK
                cdeAVA            = cdeAVA,
                cdeCTIM           = cdeCTIM,
                cdeMID            = cdeMID,
                cdePRI            = cdePRI,
                cdeO                = cdeO,
                EMail               = EMail,
                Name                = Name,
                AccessMask          = -1,
                HomeScreen          = HomeScreen,
                IsReadOnly          = IsReadOnly,
                LoginGesture        = LoginGesture,
                HomeNode            = TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID,
                PrimaryDeviceID     = PrimaryDeviceID,
                PrimaryRole         = PrimaryRole,
                ThemeName           = ThemeName,
                UserName            = UserName,
                TeTo                = TeTo,
                LCID                = LCID,
                ShowClassic         = ShowClassic,
                ShowToolTipsInTable = ShowToolTipsInTable,
                SpeakToasts         = SpeakToasts,
                HomeNodeName        = HomeNodeName
            };

            if (string.IsNullOrEmpty(NodeScope) || NodeScope.ToUpper() == "THIS")
            {
                NodeScope = TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID.ToString();
            }
            tU.NodeScope = NodeScope;
            if (string.IsNullOrEmpty(HomeNodeName))
            {
                HomeNodeName = TheBaseAssets.MyServiceHostInfo.MyStationName;
            }

            if (!string.IsNullOrEmpty(SecToken))
            {
                string[] tSec = TheCommonUtils.cdeSplit(TheCommonUtils.cdeRSADecrypt(pSessionID, SecToken), ";:;", false, false);
                if ("CDE!" == tSec[0])
                {
                    for (int i = 1; i < tSec.Length; i++)
                    {
                        int tPos = tSec[i].IndexOf('=');
                        if (tPos < 0)
                        {
                            continue;
                        }
                        int    tFldNo = TheCommonUtils.CInt(tSec[i].Substring(0, tPos));
                        string tPara  = tSec[i].Substring(tPos + 1);
                        if (TheCommonUtils.IsNullOrWhiteSpace(tPara) || tPara == "null")
                        {
                            continue;
                        }
                        switch (tFldNo)
                        {
                        case 40:
                            tU.EMail = tPara;
                            break;

                        case 20:                                 //Name of User
                            tU.Name = tPara;
                            break;

                        case 50:                                                             //Password
                            tU.Password = TheBaseAssets.MySecrets.CreatePasswordHash(tPara); //PW-SECURITY-REVIEW: Create Hash Here
                            break;

                        case 56:     //Pin
                            if (string.IsNullOrEmpty(tU.TeTo))
                            {
                                tU.TeTo = TheBaseAssets.MyScopeManager.GenerateCode(8);
                            }
                            tU.PinHash = TheBaseAssets.MySecrets.CreatePasswordHash($"{tU.TeTo.ToUpper()}@@{tPara}");
                            break;

                        case 120:                             //HomeScreen
                            if (tU.PrimaryRole != "NMIADMIN") //not allowed to set a HomeScreen for NMIAdmin
                            {
                                tU.HomeScreen = tPara;
                            }
                            break;

                        case 110:                                 //Language ID
                            tU.LCID = TheCommonUtils.CInt(tPara);
                            break;

                        case 6:                                 //Node Scope
                            tU.NodeScope = tPara;
                            break;

                        case 70:                                 //AccessMask
                            tU.AccessMask = TheCommonUtils.CInt(tPara);
                            break;
                        }
                    }
                }
                else
                {
                    //Should no come here
                    //tU.Password = tSec[0]; //PW-SECURITY-REVIEW: should contain hash
                    //               if (tSec.Length > 1)
                    //	tU.AssignedEasyScope = tSec[1]; //ok - not used at this point
                    //if (tSec.Length > 2)
                    //	tU.AccessMask = TheCommonUtils.CInt(tSec[2]);
                }
            }
            else
            {
                tU.Password   = TheBaseAssets.MySecrets.CreatePasswordHash(Password);               //PW-SECURITY-REVIEW: should contain hash
                tU.AccessMask = AccessMask;
            }
            tU.SecToken = TheCommonUtils.cdeEncrypt(tU.Password + ";:;" + tU.AssignedEasyScope + ";:;" + tU.AccessMask, TheBaseAssets.MySecrets.GetAI());              //AES OK ; PW Should be Hash
            return(tU);
        }
 /// <summary>
 /// Sets the scope connected to the node.
 /// </summary>
 /// <param name="dataProvider">
 /// The data provider.
 /// </param>
 /// <param name="node">
 /// The node.
 /// </param>
 /// <param name="scope">
 /// The scope.
 /// </param>
 public static void SetScope([NotNull] this INodeDataProvider dataProvider, Node node, NodeScope scope)
 {
     dataProvider.Set(node, "Scope", scope);
 }