Example #1
0
        public static ErrorCode CheckSession2(string passport, string ip, string hwid, uint gamecode, out uint unreadNoteCount, out uint statusFlag, out long nexonSN64, out string nexonID, out string userIP, out byte sex, out ushort age, out string nationCode, out string metaData, out byte secureCode, out byte channelCode, out string channelUID, out bool newMembership, out byte mainAuthLevel, out byte subAuthLevel, out string errorMessage)
        {
            unreadNoteCount = 0u;
            statusFlag      = 0u;
            nexonSN64       = 0L;
            nexonID         = string.Empty;
            userIP          = string.Empty;
            sex             = 0;
            age             = 0;
            nationCode      = string.Empty;
            metaData        = string.Empty;
            secureCode      = 0;
            channelCode     = 0;
            channelUID      = string.Empty;
            newMembership   = false;
            mainAuthLevel   = 0;
            subAuthLevel    = 0;
            if (passport == null || passport.Length < 10 || !passport.StartsWith("NP"))
            {
                errorMessage = "'passport' is null or corrupted.";
                return(ErrorCode.InvalidArgument);
            }
            if (ip == null)
            {
                try
                {
                    ip = HttpContext.Current.Request.UserHostAddress;
                }
                catch (Exception)
                {
                    errorMessage = "Getting user ip address from HttpContext failed.";
                    return(ErrorCode.InvalidArgument);
                }
            }
            Default @default;

            try
            {
                @default = Authenticator.CreateClientFromPassport(passport);
            }
            catch (Authenticator.InvalidPassportException)
            {
                errorMessage = "'passport' is unrecognizable.";
                return(ErrorCode.InvalidArgument);
            }
            catch (Exception ex)
            {
                errorMessage = "A unknown exception occured while creating a soap client." + Environment.NewLine + ex.ToString();
                ErrorLogger.WriteLog(ErrorCode.Unknown, errorMessage, ex.StackTrace, nexonID, passport);
                return(ErrorCode.Unknown);
            }
            int       num = Config.Authenticator.Soap.RetryCount;
            ErrorCode result;

            for (;;)
            {
                try
                {
                    if (Config.Authenticator.Soap.SoapVersion == 4)
                    {
                        CheckSessionAndGetInfo4Result checkSessionAndGetInfo4Result = @default.CheckSessionAndGetInfo4(passport, ip, hwid, gamecode);
                        if (checkSessionAndGetInfo4Result.nErrorCode == 0)
                        {
                            unreadNoteCount = checkSessionAndGetInfo4Result.uUnreadNoteCount;
                            statusFlag      = checkSessionAndGetInfo4Result.uStatusFlag;
                        }
                        nexonSN64     = checkSessionAndGetInfo4Result.nNexonSN64;
                        nexonID       = checkSessionAndGetInfo4Result.strNexonID;
                        userIP        = Utility.IPToString(checkSessionAndGetInfo4Result.uIP);
                        sex           = checkSessionAndGetInfo4Result.uSex;
                        age           = checkSessionAndGetInfo4Result.uAge;
                        nationCode    = checkSessionAndGetInfo4Result.strNationCode;
                        metaData      = checkSessionAndGetInfo4Result.strMetaData;
                        secureCode    = checkSessionAndGetInfo4Result.uSecureCode;
                        channelCode   = checkSessionAndGetInfo4Result.uChannelCode;
                        channelUID    = checkSessionAndGetInfo4Result.strChannelUID;
                        newMembership = checkSessionAndGetInfo4Result.bNewMembership;
                        mainAuthLevel = checkSessionAndGetInfo4Result.nMainAuthLevel;
                        subAuthLevel  = checkSessionAndGetInfo4Result.nSubAuthLevel;
                        errorMessage  = checkSessionAndGetInfo4Result.strErrorMessage;
                        result        = (ErrorCode)checkSessionAndGetInfo4Result.nErrorCode;
                        break;
                    }
                    CheckSessionAndGetInfo2Result checkSessionAndGetInfo2Result = @default.CheckSessionAndGetInfo2(passport, ip, hwid, gamecode);
                    if (checkSessionAndGetInfo2Result.nErrorCode == 0)
                    {
                        unreadNoteCount = checkSessionAndGetInfo2Result.uUnreadNoteCount;
                        statusFlag      = checkSessionAndGetInfo2Result.uStatusFlag;
                    }
                    nexonSN64     = (long)checkSessionAndGetInfo2Result.nNexonSN;
                    nexonID       = checkSessionAndGetInfo2Result.strNexonID;
                    userIP        = Utility.IPToString(checkSessionAndGetInfo2Result.uIP);
                    sex           = checkSessionAndGetInfo2Result.uSex;
                    age           = checkSessionAndGetInfo2Result.uAge;
                    nationCode    = checkSessionAndGetInfo2Result.strNationCode;
                    metaData      = checkSessionAndGetInfo2Result.strMetaData;
                    secureCode    = checkSessionAndGetInfo2Result.uSecureCode;
                    newMembership = false;
                    mainAuthLevel = 0;
                    subAuthLevel  = 0;
                    errorMessage  = checkSessionAndGetInfo2Result.strErrorMessage;
                    result        = (ErrorCode)checkSessionAndGetInfo2Result.nErrorCode;
                    break;
                }
                catch (Exception ex2)
                {
                    if (num == 0 || !(ex2 is WebException))
                    {
                        errorMessage = "A unknown exception occured while calling a soap method." + Environment.NewLine + ex2.ToString();
                        ErrorLogger.WriteLog(ErrorCode.SoapCallFailed, errorMessage, ex2.StackTrace, nexonID, passport);
                        result = ErrorCode.SoapCallFailed;
                        break;
                    }
                }
                num--;
                if (num == 0)
                {
                    @default.Timeout = Config.Authenticator.Soap.LongTimeout;
                }
            }
            return(result);
        }
Example #2
0
        public static ErrorCode Login(string id, string pwd, string ip, int gameCode, int locale, int region, out string passport, out uint unreadNoteCount, out uint statusFlag, out string errorMessage, out int subErrCode)
        {
            passport        = string.Empty;
            unreadNoteCount = 0u;
            statusFlag      = 0u;
            subErrCode      = 0;
            if (id == null || pwd == null)
            {
                errorMessage = "'id' or 'pwd' are null.";
                return(ErrorCode.InvalidArgument);
            }
            if (ip == null)
            {
                try
                {
                    ip = HttpContext.Current.Request.UserHostAddress;
                }
                catch (Exception)
                {
                    errorMessage = "Getting user ip address from HttpContext failed.";
                    return(ErrorCode.InvalidArgument);
                }
            }
            Default @default;

            try
            {
                @default = Authenticator.CreateClientFromID(id);
            }
            catch (Exception ex)
            {
                errorMessage = "A unknown exception occured while creating a soap client." + Environment.NewLine + ex.ToString();
                ErrorLogger.WriteLog(ErrorCode.Unknown, errorMessage, ex.StackTrace, id, passport);
                return(ErrorCode.Unknown);
            }
            int       num = Config.Authenticator.Soap.RetryCount;
            ErrorCode result;

            for (;;)
            {
                try
                {
                    LoginResult2 loginResult = @default.Login4(id, pwd, ip, (uint)gameCode, (uint)locale, (uint)region);
                    if (loginResult.nErrorCode == 0 || loginResult.nErrorCode == 20019)
                    {
                        passport        = loginResult.strPassport;
                        unreadNoteCount = loginResult.uUnreadNoteCount;
                        statusFlag      = loginResult.uStatusFlag;
                    }
                    subErrCode   = loginResult.nSubErrCode;
                    errorMessage = loginResult.strErrorMessage;
                    result       = (ErrorCode)loginResult.nErrorCode;
                    break;
                }
                catch (Exception ex2)
                {
                    if (num == 0 || !(ex2 is WebException))
                    {
                        errorMessage = "A unknown exception occured while calling a soap method." + Environment.NewLine + ex2.ToString();
                        ErrorLogger.WriteLog(ErrorCode.SoapCallFailed, errorMessage, ex2.StackTrace, id, passport);
                        result = ErrorCode.SoapCallFailed;
                        break;
                    }
                }
                num--;
                if (num == 0)
                {
                    @default.Timeout = Config.Authenticator.Soap.LongTimeout;
                }
            }
            return(result);
        }
Example #3
0
        public static ErrorCode MobileLogin(string loginID, string password, string clientIP, out long nexonSN, out string nexonID, out ushort age, out bool newMembership, out byte mainAuthLevel, out byte subAuthLevel, out string errorMessage)
        {
            nexonSN       = 0L;
            nexonID       = string.Empty;
            age           = 0;
            newMembership = false;
            mainAuthLevel = 0;
            subAuthLevel  = 0;
            if (loginID == null || password == null)
            {
                errorMessage = "'id' or 'pwd' are null.";
                return(ErrorCode.InvalidArgument);
            }
            if (clientIP == null)
            {
                try
                {
                    clientIP = HttpContext.Current.Request.UserHostAddress;
                }
                catch (Exception)
                {
                    errorMessage = "Getting user ip address from HttpContext failed.";
                    return(ErrorCode.InvalidArgument);
                }
            }
            Default @default;

            try
            {
                @default = Authenticator.CreateClientFromID(loginID);
            }
            catch (Exception ex)
            {
                errorMessage = "A unknown exception occured while creating a soap client." + Environment.NewLine + ex.ToString();
                ErrorLogger.WriteLog(ErrorCode.Unknown, errorMessage, ex.StackTrace, loginID, string.Empty);
                return(ErrorCode.Unknown);
            }
            for (int i = 0; i <= Config.Authenticator.Soap.RetryCount; i++)
            {
                try
                {
                    MobileLoginResult mobileLoginResult = @default.MobileLogin(loginID, password, clientIP);
                    nexonSN       = mobileLoginResult.nNexonSN;
                    nexonID       = mobileLoginResult.strNexonID;
                    age           = mobileLoginResult.uAge;
                    newMembership = mobileLoginResult.bNewMembership;
                    mainAuthLevel = mobileLoginResult.nMainAuthLevel;
                    subAuthLevel  = mobileLoginResult.nSubAuthLevel;
                    errorMessage  = mobileLoginResult.strErrorMessage;
                    return((ErrorCode)mobileLoginResult.nErrorCode);
                }
                catch (Exception ex2)
                {
                    if (i == Config.Authenticator.Soap.RetryCount || !(ex2 is WebException))
                    {
                        errorMessage = "A unknown exception occured while calling a soap method." + Environment.NewLine + ex2.ToString();
                        ErrorLogger.WriteLog(ErrorCode.SoapCallFailed, errorMessage, ex2.StackTrace, loginID, string.Empty);
                        return(ErrorCode.SoapCallFailed);
                    }
                }
                if (i == Config.Authenticator.Soap.RetryCount - 1)
                {
                    @default.Timeout = Config.Authenticator.Soap.LongTimeout;
                }
            }
            errorMessage = string.Empty;
            return(ErrorCode.Unknown);
        }
Example #4
0
 public static ErrorCode Login(string id, string pwd, string ip, out string passport, out uint unreadNoteCount, out uint statusFlag, out string errorMessage, out int subErrCode)
 {
     return(Authenticator.Login(id, pwd, ip, 0, 0, 0, out passport, out unreadNoteCount, out statusFlag, out errorMessage, out subErrCode));
 }