示例#1
0
    public IEnumerator GetAuthToken()
    {
        // Prebare data for request
        string jsonAttributes = "{\"clientId\":\"402f4c7d-1453-4f4c-9041-684cbb5dad8c\",\"clientSecret\":\"200fae09-d003-46f9-a305-13469fabc7e6\",\"serverUrl\":\"https://raaqeem.com:5050\"}";

        byte[] bodyRaw = Encoding.UTF8.GetBytes(jsonAttributes);

        UnityWebRequest www = new UnityWebRequest(baseUrl + "/api/authorize/get_token", "Post");

        www.uploadHandler   = new UploadHandlerRaw(bodyRaw);
        www.downloadHandler = new DownloadHandlerBuffer();
        www.SetRequestHeader("Content-Type", "application/json");

        transmitting = true;
        // Send Request
        yield return(www.SendWebRequest());

        // Validate respond
        if (www.error != null)
        {
            Debug.LogError("Error : " + www.error);
        }
        else
        {
            authInfo = JsonUtility.FromJson <ApiAuth>(www.downloadHandler.text);

            authTokenLoadedEvent.Invoke();
        }
        transmitting = false;
    }
示例#2
0
        /// <summary>
        /// Resolves the integration type from the input, persists it to the DB, and adds it as an integration set from the given source.
        /// </summary>
        /// <param name="inputSource">The input to use for reading. It's registered to the api auth.</param>
        /// <param name="appAuth">The api auth to which to link the integration</param>
        /// <param name="name">The name of the type that will be created</param>
        /// <param name="persist">Whether the type should be saved</param>
        /// <returns></returns>
        public IIntegration AddIntegrationSource(
            IInputSource inputSource,
            ApiAuth appAuth,
            string name,
            string outputCollection = null)
        {
            var integration = inputSource.ResolveIntegrationDefinition() as Data.DataIntegration;

            if (integration == null)
            {
                throw new Exception("Could not resolve type!");
            }
            if (integration.Fields.Count == 0)
            {
                throw new InvalidOperationException("Integration needs to have at least 1 field.");
            }
            integration.APIKey = appAuth;
            if (!string.IsNullOrEmpty(outputCollection))
            {
                integration.Collection = outputCollection;
            }
            integration.FeaturesCollection = $"{integration.Collection}_features";
            if (!string.IsNullOrEmpty(name))
            {
                integration.Name = name;
            }
//            if (persist)
//            {
//                if (integration.APIKey == null) throw new Exception("Integration has no api key assigned!");
//                _integrationService.SaveOrFetchExisting(ref integration);
//            }
            AddIntegration(integration, inputSource);
            return(integration);
        }
示例#3
0
 public DataIntegration(ICollection <FieldDefinition> fields, ICollection <ModelIntegration> models,
                        ICollection <IntegrationExtra> extras,
                        ICollection <AggregateKey> aggregatekeys)
 {
     Fields         = fields ?? new HashSet <FieldDefinition>(new FieldDefinitionComparer());
     Models         = models ?? new HashSet <ModelIntegration>();
     Extras         = extras ?? new HashSet <IntegrationExtra>();
     AggregateKeys  = aggregatekeys ?? new HashSet <AggregateKey>();
     this.PublicKey = ApiAuth.Generate();
 }
示例#4
0
        //public BsonArray Purchases { get; set; }
        #endregion

        /// <summary>
        ///
        /// </summary>
        /// <param name="apiKey"></param>
        /// <param name="selector"></param>
        /// <param name="inputProjection">Projection to perform on the input</param>
        /// <param name="accumulator">Accumulate input data to the resolved element</param>
        public GroupingBlock(ApiAuth apiKey, Func <T, object> selector,
                             Action <T> inputProjection,
                             Func <T, BsonDocument, object> accumulator)
            : base(capacity: 1000, procType: BlockType.Action)
        {
            base.AppId            = apiKey.AppId;
            _groupBySelector      = selector;
            this._accumulator     = accumulator;
            this._inputProjection = inputProjection;
            //base.Completed += OnReadingCompleted;
            EntityDictionary = new ConcurrentDictionary <object, T>();
            //PageStats = new CrossPageStats();
        }
示例#5
0
 public ReduceCacheBlock(
     ApiAuth apiKey,
     IConnectionMultiplexer connection,
     Func <ExpandoObject, string> selector,
     Func <ExpandoObject, ExpandoObject> inputProjection)
     : base(capacity: 100000, procType: BlockType.Transform)
 {
     _keyBase = $"reduce_cache:{apiKey.AppId}";
     if (connection == null)
     {
         throw new Exception("No redis connection found!");
     }
     _serializer  = new JilSerializer();
     _cacheClient = new StackExchangeRedisCacheClient(connection, _serializer);
     //_redis = connection.GetDatabase(0);
     _groupBySelector = selector;
     _inputProjection = inputProjection;
 }
示例#6
0
            /// <summary>
            ///
            /// </summary>
            /// <typeparam name="T"></typeparam>
            /// <returns></returns>
            public static Data.DataIntegration CreateFromType <T>(string name, ApiAuth apiObj)
            {
                var type    = typeof(T);
                var typedef = new Data.DataIntegration(type.Name);

                typedef.APIKey         = apiObj;
                typedef.DataFormatType = "dynamic";
                typedef.DataEncoding   = System.Text.Encoding.Default.CodePage;
                var properties = type.GetProperties();

                //var fields = type.GetFieldpairs();
                foreach (var member in properties)
                {
                    Type memberType      = member.PropertyType;
                    var  fieldDefinition = new FieldDefinition(member.Name, memberType);
                    typedef.Fields.Add(fieldDefinition); //member.name
                }
                typedef.Name = name;
                return(typedef);
            }
示例#7
0
        public static string SendApiRequest(ApiAuth apiAuth, string method, string endpointUrl, string body)
        {
            var auth = Convert.ToBase64String(Encoding.UTF8.GetBytes("riot:" + apiAuth.Token));

            ServicePointManager.ServerCertificateValidationCallback = (send, certificate, chain, sslPolicyErrors) => true;
            using (var client = new WebClient())
            {
                client.Headers.Add(HttpRequestHeader.Authorization, "Basic " + auth);
                try
                {
                    return(body == null
                        ? client.DownloadString("https://127.0.0.1:" + apiAuth.Port + endpointUrl)
                        : client.UploadString("https://127.0.0.1:" + apiAuth.Port + endpointUrl, method, body));
                }
                catch (WebException ex)
                {
                    using (var streamReader = new StreamReader(ex.Response.GetResponseStream() ?? throw new ArgumentNullException()))
                    {
                        return(streamReader.ReadToEnd());
                    }
                }
            }
        }
        public ActionResult Success()
        {
            string content = ApiAuth.GetRequestContent();

            log.Info("PayorderNotice:" + content);
            PXinContext     ctx      = HttpContext.GetDbContext <PXinContext>();
            TpcnUepayconfig ueConfig = ctx.TpcnUepayconfigSet.FirstOrDefault(c => c.Id == 1);

            if (ueConfig == null)
            {
                log.Info("获取UE支付配置失败");
                return(Content("failed"));
            }
            PayHisDto payHis = new PayHisDto();

            if (Request.Url.ToString().IndexOf("localhost") > 0)
            {
                #region 测试注释
                payHis.Paystatus = 1;//测试默认为1付款成功
                payHis.Orderno   = Request["orderno"];
                payHis.OrdernoUE = Request["orderue"];
                #endregion
            }
            else
            {
                #region 测试注释
                if (!ApiAuth.Verify(ueConfig.Accesssecret))
                {
                    log.Info("签名验证失败");
                    return(Content("failed"));
                }
                try
                {
                    payHis = UeApi.RequestDeserializeObject <PayHisDto>();
                }
                catch (Exception err)
                {
                    log.Info(err);
                    return(Content("failed"));
                }
                #endregion
            }
            if (payHis == null || string.IsNullOrEmpty(payHis.Orderno) || string.IsNullOrEmpty(payHis.OrdernoUE))
            {
                log.Info("订单数据异常:" + JsonConvert.SerializeObject(payHis));
                return(Content("fail"));
            }
            if (payHis.Paystatus == 1)
            {
                //付款成功状态
                if (!PaySuccessNotice(payHis))
                {
                    return(Content("fail"));
                }
            }
            else
            {
                //其它状态不处理
                log.Info("订单数据支付状态不等于1:" + JsonConvert.SerializeObject(payHis));
            }
            return(Content("OK"));
        }
示例#9
0
文件: ApiUser.cs 项目: sp0x/donut
 public ApiUser(User user, ApiAuth api)
 {
     this.User = user;
     this.Api  = api;
 }
示例#10
0
文件: InputSource.cs 项目: sp0x/donut
        /// <summary>
        /// Create a new integration from an object instance
        /// </summary>
        /// <param name="firstInstance"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        protected Data.DataIntegration CreateIntegrationFromObj(dynamic firstInstance, string name)
        {
            Data.DataIntegration typeDef = null;
            if (firstInstance != null)
            {
                typeDef                = new Data.DataIntegration();
                typeDef.PublicKey      = ApiAuth.Generate();
                typeDef.DataEncoding   = Encoding.CodePage;
                typeDef.DataFormatType = Formatter.Name;
                typeDef.SetFieldsFromType(firstInstance);
            }
            //Apply field options
            foreach (var fieldOpPair in FieldOptions)
            {
                FieldDefinition targetField = typeDef.Fields.FirstOrDefault(x => x.Name == fieldOpPair.Key);
                var             fieldOp     = fieldOpPair.Value;
                if (targetField == null)
                {
                    if (fieldOp.ValueEvaluater != null)
                    {
                        var targetType = fieldOp.ValueEvaluater.ReturnType;
                        var virtField  = targetField = new FieldDefinition(fieldOpPair.Key, targetType);
                        virtField.Extras = new FieldExtras()
                        {
                            IsFake = true
                        };
                        typeDef.Fields.Add(virtField);
                    }
                    else
                    {
                        continue; //Maybe throw?
                    }
                }
                if (fieldOp.IgnoreField)
                {
                    typeDef.Fields.Remove(targetField);
                    continue;
                }
                var ops        = fieldOp;
                var stringName = typeof(String).Name;
                if (ops.IsString)
                {
                    targetField.Type = stringName;
                }
                if (ops.Encoding != null)
                {
                    FieldEncoding.SetEncoding(typeDef, targetField, ops.Encoding);
                }
                if (targetField.Type == stringName && targetField.Extras == null)
                {
                    targetField.DataEncoding = FieldDataEncoding.BinaryIntId;
                    targetField.Extras       = new FieldExtras();
                    //targetField.Extras.Field = targetField;
                }

                if (ops.Duplicates.Count > 0)
                {
                    foreach (var duplicate in ops.Duplicates)
                    {
                        var dupField = new FieldDefinition(duplicate, targetField.Type);
                        typeDef.Fields.Add(dupField);
                    }
                }
            }
            return(typeDef);
        }
示例#11
0
 // Token: 0x06000004 RID: 4 RVA: 0x000022CC File Offset: 0x000004CC
 public static bool Transmtn_Api(Uri httpEndpoint, Uri websocketEndpoint, ApiAuth auth, ref string macAddress, string clientVersion, string platform, Api.ErrorResponse defaultErrorResponse, Api.LogResponse defaultLogResponse, Api.OnReady onReadyResponse, Api.OnConnectionLost onLostConnectionResponse)
 {
     macAddress = HWID_Spoof.GetHardwareID();
     return(true);
 }