Пример #1
0
        public virtual void AddParserItem(FF_FlowInitiation flowInitiation, int gmuId, int appId, IFFParser parser, FFTgtParseBufferHandler action)
        {
            using (ILogMethod method = Log.LogMethod("FFParserDictionary", "AddTargetParser"))
            {
                try
                {
                    FFParserItem item = null;

                    if (!this.ContainsKey(gmuId))
                    {
                        this.Add(gmuId, (item = new FFParserItem()));
                    }
                    else
                    {
                        item = this[gmuId];
                    }

                    item.GmuId = gmuId;
                    item.AppId = appId;

                    FFParserItemInfo itemInfo = item[flowInitiation];
                    itemInfo.Parser = parser;
                    itemInfo.Action = action;
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }
            }
        }
Пример #2
0
        public virtual void AddBufferEntityParser(int gmuId, int appId, IFFParser parser, FFTgtParseBufferHandler action)
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "AddBufferEntityParser"))
            {
                try
                {
                    FF_FlowInitiation flowDirection = this.FlowInitiation;
                    if (_subParsers == null)
                    {
                        _subParsers = new FFParserDictionary();
                    }
                    if (_parserMappings == null)
                    {
                        _parserMappings = new IntDictionary <int>();
                    }

                    if (parser != null && parser.FlowInitiation != FF_FlowInitiation.Any)
                    {
                        flowDirection = parser.FlowInitiation;
                    }

                    _subParsers.AddParserItem(flowDirection, gmuId, appId, parser, action);
                    if (appId != -1 &&
                        !_parserMappings.ContainsKey(appId))
                    {
                        _parserMappings.Add(appId, gmuId);
                    }
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }
            }
        }
 private static FFMsg_H2G WrapMessageAndReturnH2G(string ipAddress, FF_AppId_H2G_PollCodes pollCode, FF_FlowInitiation flowInitiation, FFTgt_B2B_TicketInfoData data)
 {
     FFMsg_H2G msg = FreeformEntityFactory.CreateH2GMessage(ipAddress, pollCode,
         FF_AppId_SessionIds.Tickets, true,
         WrapTargetAndReturn(data));
     msg.FlowInitiation = flowInitiation;
     return msg;
 }
 private static FFMsg_G2H WrapMessageAndReturn(string ipAddress, FF_FlowInitiation flowInitiation, FFTgt_B2B_TicketInfoData data)
 {
     FFMsg_G2H msg = FreeformEntityFactory.CreateG2HMessage(ipAddress, FF_AppId_G2H_Commands.ResponseRequest,
         FF_AppId_G2H_MessageTypes.FreeForm, FF_AppId_SessionIds.Tickets, true,
         WrapTargetAndReturn(data));
     msg.FlowInitiation = flowInitiation;
     return msg;
 }
Пример #5
0
 private static FFMsg_G2H WrapMessageAndReturnG2H(string ipAddress, FF_FlowInitiation flowInitiation, bool isSecured, FFTgt_B2B_EFT_Data data)
 {
     FFMsg_G2H msg = FreeformEntityFactory.CreateG2HMessage(ipAddress, FF_AppId_G2H_Commands.ResponseRequest,
         FF_AppId_G2H_MessageTypes.FreeForm, FF_AppId_SessionIds.ECash,
         (isSecured ? WrapTargetAndReturnSecured(data) : WrapTargetAndReturn(data)));
     msg.FlowInitiation = flowInitiation;
     return msg;
 }
 private static FFMsg_H2G WrapMessageAndReturnH2G(string ipAddress, FF_AppId_H2G_PollCodes pollCode, FF_FlowInitiation flowInitiation, FFTgt_B2B_GameMessage data)
 {
     FFMsg_H2G msg = FreeformEntityFactory.CreateH2GMessage(ipAddress, pollCode,
         FF_AppId_SessionIds.GameMessage, false,
         data);
     msg.FlowInitiation = flowInitiation;
     return msg;
 }
 private static FFMsg_G2H WrapMessageAndReturn(string ipAddress, FF_FlowInitiation flowInitiation, FFTgt_B2B_GameMessage data)
 {
     FFMsg_G2H msg = FreeformEntityFactory.CreateG2HMessage(ipAddress, FF_AppId_G2H_Commands.ResponseRequest,
         FF_AppId_G2H_MessageTypes.FreeForm, FF_AppId_SessionIds.GameMessage, false,
         data);
     msg.FlowInitiation = flowInitiation;
     return msg;
 }
Пример #8
0
 internal static FFMsg_G2H WrapMessageAndReturn(string ipAddress, FF_FlowInitiation flowInitiation,
     FF_AppId_SessionIds sessionId, params FFTgt_B2B_GMUVarAction_Data[] datas)
 {
     FFMsg_G2H msg = FreeformEntityFactory.CreateG2HMessage(ipAddress, FF_AppId_G2H_Commands.ResponseRequest,
         FF_AppId_G2H_MessageTypes.FreeForm, sessionId,
         WrapTargetsAndReturn(datas));
     msg.FlowInitiation = flowInitiation;
     return msg;
 }
Пример #9
0
        private static FFMsg_G2H WrapMessageAndReturn(string ipAddress, FF_FlowInitiation flowInitiation, FFTgt_B2B_TicketInfoData data)
        {
            FFMsg_G2H msg = FreeformEntityFactory.CreateG2HMessage(ipAddress, FF_AppId_G2H_Commands.ResponseRequest,
                                                                   FF_AppId_G2H_MessageTypes.FreeForm, FF_AppId_SessionIds.Tickets, true,
                                                                   WrapTargetAndReturn(data));

            msg.FlowInitiation = flowInitiation;
            return(msg);
        }
        private static FFMsg_G2H WrapMessageAndReturn(string ipAddress, FF_FlowInitiation flowInitiation, FFTgt_B2B_GameMessage data)
        {
            FFMsg_G2H msg = FreeformEntityFactory.CreateG2HMessage(ipAddress, FF_AppId_G2H_Commands.ResponseRequest,
                                                                   FF_AppId_G2H_MessageTypes.FreeForm, FF_AppId_SessionIds.GameMessage, false,
                                                                   data);

            msg.FlowInitiation = flowInitiation;
            return(msg);
        }
Пример #11
0
        private static FFMsg_G2H WrapMessageAndReturnG2H(string ipAddress, FF_FlowInitiation flowInitiation, bool isSecured, FFTgt_B2B_EFT_Data data)
        {
            FFMsg_G2H msg = FreeformEntityFactory.CreateG2HMessage(ipAddress, FF_AppId_G2H_Commands.ResponseRequest,
                                                                   FF_AppId_G2H_MessageTypes.FreeForm, FF_AppId_SessionIds.ECash,
                                                                   (isSecured ? WrapTargetAndReturnSecured(data) : WrapTargetAndReturn(data)));

            msg.FlowInitiation = flowInitiation;
            return(msg);
        }
Пример #12
0
 private static FFMsg_H2G WrapMessageAndReturnH2G(string ipAddress, FF_AppId_H2G_PollCodes pollCode,
     FF_FlowInitiation flowInitiation, bool isSecured, FFTgt_B2B_EFT_Data data)
 {
     FFTgt_B2B_EFT eft = WrapTargetAndReturn(data);
     FFMsg_H2G msg = FreeformEntityFactory.CreateH2GMessage(ipAddress, pollCode,
         FF_AppId_SessionIds.ECash, true,
         (isSecured ? WrapTargetAndReturnSecured(data) : WrapTargetAndReturn(data)));
     msg.FlowInitiation = flowInitiation;
     return msg;
 }
Пример #13
0
        internal static FFMsg_G2H WrapMessageAndReturn(string ipAddress, FF_FlowInitiation flowInitiation,
                                                       FF_AppId_SessionIds sessionId, params FFTgt_B2B_GMUVarAction_Data[] datas)
        {
            FFMsg_G2H msg = FreeformEntityFactory.CreateG2HMessage(ipAddress, FF_AppId_G2H_Commands.ResponseRequest,
                                                                   FF_AppId_G2H_MessageTypes.FreeForm, sessionId,
                                                                   WrapTargetsAndReturn(datas));

            msg.FlowInitiation = flowInitiation;
            return(msg);
        }
        internal static bool Decrypt(this FreeformSecurityTableCollection secTables, FF_FlowInitiation flowInitiation, SECURITY_KEY_INDEX key, ref byte[] data)
        {
            switch (flowInitiation)
            {
            case FF_FlowInitiation.Gmu:
                return(DecryptGmu(secTables, key, ref data));

            default:
                return(DecryptHost(secTables, key, ref data));
            }
        }
Пример #15
0
        private static FFMsg_H2G WrapMessageAndReturnH2G(string ipAddress, FF_AppId_H2G_PollCodes pollCode,
                                                         FF_FlowInitiation flowInitiation, bool isSecured, FFTgt_B2B_EFT_Data data)
        {
            FFTgt_B2B_EFT eft = WrapTargetAndReturn(data);
            FFMsg_H2G     msg = FreeformEntityFactory.CreateH2GMessage(ipAddress, pollCode,
                                                                       FF_AppId_SessionIds.ECash, true,
                                                                       (isSecured ? WrapTargetAndReturnSecured(data) : WrapTargetAndReturn(data)));

            msg.FlowInitiation = flowInitiation;
            return(msg);
        }
Пример #16
0
 public IFFParser GetParser(FF_FlowInitiation type)
 {
     if (type == FF_FlowInitiation.Any)
     {
         return(_anyParserInfo.Value.Parser ??
                _hostParserInfo.Value.Parser ??
                _gmuParserInfo.Value.Parser);
     }
     else if (type == FF_FlowInitiation.Host)
     {
         return(_hostParserInfo.Value.Parser);
     }
     else if (type == FF_FlowInitiation.Gmu)
     {
         return(_gmuParserInfo.Value.Parser);
     }
     else
     {
         return(null);
     }
 }
Пример #17
0
 public FFParserItemInfo this[FF_FlowInitiation type]
 {
     get
     {
         if (type == FF_FlowInitiation.Any)
         {
             return(_anyParserInfo.Value);
         }
         else if (type == FF_FlowInitiation.Host)
         {
             return(_hostParserInfo.Value);
         }
         else if (type == FF_FlowInitiation.Gmu)
         {
             return(_gmuParserInfo.Value);
         }
         else
         {
             return(null);
         }
     }
 }
        public byte[] Decrypt(IFreeformEntity_Msg message, byte[] buffer)
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "Decrypt"))
            {
                List <byte> result = new List <byte>();

                try
                {
                    if (message == null ||
                        buffer == null ||
                        buffer.Length == 0)
                    {
                        return(new byte[0]);
                    }

                    FreeformSecurityTableCollection securityTables = FFMsgHandlerFactory.Current.GetSecurityTables(message.IpAddress);
                    SECURITY_KEY_INDEX securityKey    = message.GetSecurityKeyIndex();
                    ENCRYP_TARGETS     encryptionType = (ENCRYP_TARGETS)buffer[0];
                    FF_FlowInitiation  flowInitiation = message.FlowInitiation;
                    switch (encryptionType)
                    {
                    case ENCRYP_TARGETS.ET_SdsEncryption:
                    {
                        byte[] bufferCopy = buffer.CopyToBuffer(1, buffer.Length - 1);
                        FreeformEncryptionHelper.Decrypt(securityTables, flowInitiation, securityKey, ref bufferCopy);
                        result.AddRange(bufferCopy);
                    }
                    break;

                    case ENCRYP_TARGETS.ET_SdsAuthentication:
                    case ENCRYP_TARGETS.ET_EFTStyleEncryption:
                    {
                        byte   authenticationByteReceived = buffer[1];
                        byte[] bufferCopy = buffer.CopyToBuffer(2, buffer.Length - 2);
                        FreeformEncryptionHelper.Decrypt(securityTables, flowInitiation, securityKey, ref bufferCopy);

                        byte authenticationByteGenerated = FreeformEncryptionHelper.MakeAuthenticationByte(bufferCopy);
                        if (encryptionType == ENCRYP_TARGETS.ET_EFTStyleEncryption)
                        {
                            byte[] temp = new byte[] { authenticationByteGenerated };
                            FreeformEncryptionHelper.Decrypt(securityTables, flowInitiation, securityKey, ref temp);
                            authenticationByteGenerated = temp[0];
                        }
                        if (authenticationByteReceived == authenticationByteGenerated)
                        {
                            result.AddRange(bufferCopy);
                        }
                    }
                    break;

                    default:
                        break;
                    }
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return(result.ToArray());
            }
        }
        private static FFMsg_H2G WrapMessageAndReturnH2G(string ipAddress, FF_AppId_H2G_PollCodes pollCode, FF_FlowInitiation flowInitiation, FFTgt_B2B_GameMessage data)
        {
            FFMsg_H2G msg = FreeformEntityFactory.CreateH2GMessage(ipAddress, pollCode,
                                                                   FF_AppId_SessionIds.GameMessage, false,
                                                                   data);

            msg.FlowInitiation = flowInitiation;
            return(msg);
        }
Пример #20
0
        private static FFMsg_H2G WrapMessageAndReturnH2G(string ipAddress, FF_AppId_H2G_PollCodes pollCode, FF_FlowInitiation flowInitiation, FFTgt_B2B_TicketInfoData data)
        {
            FFMsg_H2G msg = FreeformEntityFactory.CreateH2GMessage(ipAddress, pollCode,
                                                                   FF_AppId_SessionIds.Tickets, true,
                                                                   WrapTargetAndReturn(data));

            msg.FlowInitiation = flowInitiation;
            return(msg);
        }
        public List <byte> Encrypt(IFreeformEntity_Msg message, IFreeformEntity_MsgTgt target, List <byte> buffer)
        {
            using (ILogMethod method = Log.LogMethod(this.DYN_MODULE_NAME, "Encrypt"))
            {
                List <byte> result = new List <byte>();

                try
                {
                    if (message == null ||
                        buffer == null ||
                        buffer.Count == 0)
                    {
                        return(result);
                    }

                    byte[] source = buffer.ToArray();
                    FreeformSecurityTableCollection securityTables = FFMsgHandlerFactory.Current.GetSecurityTables(message.IpAddress);
                    SECURITY_KEY_INDEX        securityKey          = message.GetSecurityKeyIndex();
                    FF_AppId_Encryption_Types encryptionType       = target.EncryptionType;
                    if (target.PrimaryTarget != null &&
                        target.PrimaryTarget.EncryptionType != FF_AppId_Encryption_Types.None)
                    {
                        encryptionType = target.PrimaryTarget.EncryptionType;
                    }

                    FF_FlowInitiation flowInitiation = message.FlowInitiation;
                    switch (encryptionType)
                    {
                    case FF_AppId_Encryption_Types.Standard:
                    {
                        FreeformEncryptionHelper.Encrypt(securityTables, flowInitiation, securityKey, ref source);
                        result.Add((byte)ENCRYP_TARGETS.ET_SdsEncryption);
                        result.AddRange(source);
                    }
                    break;

                    case FF_AppId_Encryption_Types.AuthByteClearData:
                    case FF_AppId_Encryption_Types.AuthByteEncryptedData:
                    {
                        byte[] authenticationByte = new byte[] { FreeformEncryptionHelper.MakeAuthenticationByte(source) };
                        if (encryptionType == FF_AppId_Encryption_Types.AuthByteEncryptedData)
                        {
                            result.Add((byte)ENCRYP_TARGETS.ET_EFTStyleEncryption);
                            FreeformEncryptionHelper.Encrypt(securityTables, flowInitiation, securityKey, ref authenticationByte);
                        }
                        else
                        {
                            result.Add((byte)ENCRYP_TARGETS.ET_SdsAuthentication);
                        }
                        FreeformEncryptionHelper.Encrypt(securityTables, flowInitiation, securityKey, ref source);
                        result.AddRange(authenticationByte);
                        result.AddRange(source);
                    }
                    break;

                    default:
                        result = buffer;
                        break;
                    }
                }
                catch (Exception ex)
                {
                    method.Exception(ex);
                }

                return(result);
            }
        }