Beispiel #1
0
        public bool ParseISBPath(string pRealPage, out Guid?pSessionID, out cdeSenderType pType, out long pFID, out string pVersion)
        {
            pSessionID = null;
            pType      = cdeSenderType.NOTSET;
            pFID       = 0;
            pVersion   = "";
            var tRealPage = CU.cdeDecrypt(pRealPage, MySecrets?.GetAI(), true);

            if (tRealPage?.StartsWith(MySecrets?.GetApID5()) != true)
            {
                return(false);
            }

            string[] tQ = tRealPage.Split('&');

            pType = tQ.Length == 4 ? (cdeSenderType)(CU.CInt(tQ[2])) : cdeSenderType.NOTSET;
            if (tQ.Length > 1)
            {
                pFID = CU.CLng(tQ[1]);
            }
            if (tQ.Length > 3)
            {
                pSessionID = CU.CGuid(tQ[3]);
            }
            if (tQ[0].Length == 7)
            {
                pVersion = tQ[0].Substring(5);
            }
            return(true);
        }
Beispiel #2
0
        public string GetISBPath(string PathPrefix, cdeSenderType pOriginType, cdeSenderType pDestinationType, long pCounter, Guid pSessionID, bool IsWS)
        {
            if (string.IsNullOrEmpty(MySecrets?.GetApID5()))
            {
                return("");
            }
            if (string.IsNullOrEmpty(PathPrefix))
            {
                PathPrefix = "/";
            }
            else
            {
                if (!PathPrefix.EndsWith("/"))
                {
                    PathPrefix += "/";
                }
            }
            string pSessID = pSessionID.ToString();

            if (pCounter == 1 && pSessionID == Guid.Empty && !(MyServiceHostInfo?.UseFixedConnectionUrl == true))
            {
                pSessID = "P" + GetCryptoGuid().ToString().Substring(1);
            }
            MyServiceHostInfo?.MyKPIs?.IncrementKPI(eKPINames.KPI4);
            string tPath = PathPrefix + "ISB" + Uri.EscapeUriString(CU.cdeEncrypt($"{MySecrets?.GetApID5()}{(MyServiceHostInfo?.ProtocolVersion == null ? "40" : MyServiceHostInfo?.ProtocolVersion)}&{pCounter}&{((int)(pOriginType))}&{pSessID}", MySecrets?.GetAI())); //3.083: Must be cdeAI

            if (IsWS && (pDestinationType == cdeSenderType.CDE_CLOUDROUTE || pDestinationType == cdeSenderType.CDE_SERVICE || pDestinationType == cdeSenderType.CDE_CUSTOMISB))                                                                                           //TODO: Might need this for Local Services that are IIS but not CloudRoutes
            {
                tPath += ".ashx";
            }
            return(tPath);
        }
        public string GetISBPath(string PathPrefix, cdeSenderType pOriginType, cdeSenderType pDestinationType, long pCounter, Guid pSessionID, bool IsWS)
        {
            if (string.IsNullOrEmpty(TheBaseAssets.MySecrets.GetApID5()))
            {
                return("");
            }
            if (string.IsNullOrEmpty(PathPrefix))
            {
                PathPrefix = "/";
            }
            else
            {
                if (!PathPrefix.EndsWith("/"))
                {
                    PathPrefix += "/";
                }
            }
            string pSessID = pSessionID.ToString();

            if (pCounter == 1 && pSessionID == Guid.Empty && !(MyServiceHostInfo?.UseFixedConnectionUrl == true))
            {
                pSessID = "P" + GetCryptoGuid().ToString().Substring(1);
            }
            MyServiceHostInfo?.MyKPIs?.IncrementKPI(eKPINames.KPI4);
            string tPath = PathPrefix + "ISB" + Uri.EscapeUriString(Base64Encode($"{string.Format("{0:00000}",CU.GetRandomUInt(0, 99999))}{(string.IsNullOrEmpty(MyServiceHostInfo?.ProtocolVersion)?"40":MyServiceHostInfo?.ProtocolVersion)}_{pCounter}_{((int)(pOriginType))}_{pSessID}"));

            if (IsWS && (pDestinationType == cdeSenderType.CDE_CLOUDROUTE || pDestinationType == cdeSenderType.CDE_SERVICE || pDestinationType == cdeSenderType.CDE_CUSTOMISB))
            {
                tPath += ".ashx";
            }
            return(tPath);
        }
        public bool ParseISBPath(string pRealPage, out Guid?pSessionID, out cdeSenderType pType, out long pFID, out string pVersion)
        {
            pSessionID = null;
            pType      = cdeSenderType.NOTSET;
            pFID       = 0;
            pVersion   = "";

            try
            {
                string[] tQ = Base64Decode(pRealPage).Split('_');

                pType = tQ.Length == 4 ? (cdeSenderType)(CU.CInt(tQ[2])) : cdeSenderType.NOTSET;
                if (tQ.Length > 1)
                {
                    pFID = CU.CLng(tQ[1]);
                }
                if (tQ.Length > 3)
                {
                    pSessionID = CU.CGuid(tQ[3]);
                }
                if (tQ[0].Length == 7)
                {
                    pVersion = tQ[0].Substring(5);
                }
            }
            catch (Exception)
            {
                // ignored
            }
            return(true);
        }
Beispiel #5
0
 /// <summary>
 /// Use this method to change the maximum message sizes allowed for the various cdeSenderTypes
 /// </summary>
 /// <param name="pType"></param>
 /// <param name="pSize"></param>
 public static void SetMessageSize(cdeSenderType pType, int pSize)
 {
     if (pSize < MAX_MessageSize.Length && pSize > 1024)
     {
         MAX_MessageSize[(int)pType] = pSize;
     }
 }
        public Guid GenerateNewAppDeviceID(cdeSenderType tS)
        {
            string tg = Guid.NewGuid().ToString();
            string t  = tg.Substring(0, 35);

            t += ((int)tS).ToString();
            return(CU.CGuid(t));
        }
 /// <summary>
 /// Creates a new DeviceID/NodeID for the current Application Scope
 /// </summary>
 /// <param name="tS">Sender Type of the Node</param>
 /// <returns></returns>
 public static Guid GenerateNewAppDeviceID(cdeSenderType tS)
 {
     if (TheBaseAssets.MyScopeManager == null)
     {
         return(Guid.NewGuid());
     }
     return(TheBaseAssets.MyScopeManager.GenerateNewAppDeviceID(tS));
 }
Beispiel #8
0
        /// <summary>
        /// Creates a new DeviceID/NodeID for the current Application Scope
        /// </summary>
        /// <param name="tS">Sender Type of the Node</param>
        /// <returns></returns>
        public Guid GenerateNewAppDeviceID(cdeSenderType tS)
        {
            string tg = GetCryptoGuid().ToString();
            //return new Guid(tg.Substring(0, 11) + ((int)tS).ToString() + (new Guid(TheBaseAssets.cdeAK)).ToString().Substring(12, "0-0000-0000-000000000000".Length));
            string t = tg.Substring(0, 29);

            t += ((int)tS).ToString();
            t += (CU.CGuid(MySecrets?.GetAK())).ToString().Substring(29, 6);
            return(CU.CGuid(t));
        }
Beispiel #9
0
        /// <summary>
        /// Used to create a random new EasyScopeID.
        /// </summary>
        /// <returns></returns>
        public string GenerateCode(int pDigits = 8)
        {
            cdeSenderType tSender = cdeSenderType.NOTSET;

            if (MyServiceHostInfo != null)
            {
                tSender = MyServiceHostInfo.MyDeviceSenderType;
            }
            return(GetRegisterCode(GenerateNewAppDeviceID(tSender), pDigits));
        }
Beispiel #10
0
        /// <summary>
        /// Used to create a random new EasyScopeID.
        /// </summary>
        /// <returns></returns>
        public string GenerateNewScopeID()
        {
            cdeSenderType tSender = cdeSenderType.NOTSET;

            if (MyServiceHostInfo != null)
            {
                tSender = MyServiceHostInfo.MyDeviceSenderType;
            }
            return(CalculateRegisterCode(GenerateNewAppDeviceID(tSender)));
        }
Beispiel #11
0
        /// <summary>
        /// Returns the cdeSenderType of a given NodeID
        /// </summary>
        /// <param name="pNodeID">Source NodeID</param>
        /// <returns></returns>
        public cdeSenderType GetSenderTypeFromDeviceID(Guid pNodeID)
        {
            cdeSenderType tRes = cdeSenderType.NOTSET;
            string        tN   = pNodeID.ToString();

            if (string.IsNullOrEmpty(AKEnd))
            {
                AKEnd = CU.CGuid(MySecrets?.GetAK()).ToString().Substring(29, 6);
            }
            if (tN.EndsWith(AKEnd))
            {
                tRes = (cdeSenderType)CU.CInt(tN.Substring(29, 1));
            }
            return(tRes);
        }