コード例 #1
0
        public static async Task Setup()
        {
            //Loaded in API keys for contex providers
            dynamic dAPIKeys = await PrototypeContexProvider.src.Utils.ReadFromJson(
                @"C:\Users\pfsar\OneDrive\Documents\GitHub\PrototypeContextProvider\PrototypeContexProvider\APIKeys.json"
                );

            APIKeyManger.GetInstance().ReadIn(dAPIKeys);
            PolciyResouce.GetInstance().LoadDB();
            //await PolciyResouce.GetInstance().SaveDB();
        }
コード例 #2
0
        public ActionResult <string> CreateShareTokken(string apiKey, string resouceID)
        {
            var pr          = PolciyResouce.GetInstance();
            var apiKeyEntry = pr.OwnershipTable[apiKey];

            if (!apiKeyEntry.PolciesResocuce.ContainsKey(resouceID))
            {
                return(NotFound());
            }

            var newTokken = Utils.CreateKey(10);

            _shareTokkens[newTokken] = new ShareTokkenEntry {
                ApiKey = apiKey, ResID = resouceID
            };
            return(newTokken);
        }
コード例 #3
0
        public ActionResult <string> Create(string shareTokken, string resouceID, DataSharingPolciy polciy)
        {
            if (polciy.Id == null)
            {
                //TODO make this not bad
                polciy.Id = Utils.LongRandom(_random);
            }

            if (polciy.Interval == null)
            {
                polciy.Interval = -1;
            }

            if (!polciy.Vaild())
            {
                return("ERROR:Invaild Json");
            }

            var apiKey        = _shareTokkens[shareTokken].ApiKey;
            var polciyResouce = PolciyResouce.GetInstance();

            if (polciyResouce.OwnershipTable.ContainsKey(apiKey))
            {
                var newTokken = Utils.CreateKey(10);

                var id = (long)polciy.Id;

                _secTokken.Add(newTokken, new SecTokenEntry()
                {
                    PolicyID = id, ResID = resouceID
                });

                ExportToFile(id, polciy);

                return(newTokken);
            }

            return("FAILLED");
        }
コード例 #4
0
 public ActionResult <string> Get()
 {
     return(PolciyResouce.GetInstance().GenrateAndAddAPIKey());
 }