Esempio n. 1
0
 public ConfigurationController(IIdentityResourceService identityResourceService,
                                IApiResourceService apiResourceService,
                                IClientService clientService,
                                IStringLocalizer <ConfigurationController> localizer,
                                IEncryptionKeyService encryptionKeyService,
                                ILogger <ConfigurationController> logger)
     : base(logger)
 {
     _identityResourceService = identityResourceService;
     _apiResourceService      = apiResourceService;
     _clientService           = clientService;
     _encryptionKeyService    = encryptionKeyService;
     _localizer = localizer;
 }
        public async Task InvokeAsync(HttpContext context, IEncryptionKeyService encryptionKeyService, IClientService clientService)
        {
            if (context.Request.HasFormContentType)
            {
                NameValueCollection fcnvc = context.Request.Form.AsNameValueCollection();
                Dictionary <string, StringValues> dictValues = new Dictionary <string, StringValues>();
                var option = _options.Where(m => m.Path == context.Request.Path).FirstOrDefault();
                if (option != null)
                {
                    foreach (var key in fcnvc.AllKeys)
                    {
                        var parameter = option.Parameters.Where(m => m == key).FirstOrDefault();
                        if (parameter != null)
                        {
                            if (option.RedirectPath?.Length > 0)
                            {
                                context.Request.Path = new PathString(option.RedirectPath);
                            }
                            var client        = clientService.GetClientsAsync(fcnvc["client_id"]).Result.Clients.Where(m => m.ClientId == fcnvc["client_id"]).FirstOrDefault();
                            var encryptionKey = encryptionKeyService.GetEncryptionKeyByClientIdAsync(client?.Id ?? 0).Result;
                            if (encryptionKey != null)
                            {
                                var encryptionSecret = Encoding.ASCII.GetBytes(encryptionKey.EncryptionSecret);
                                var decryptText      = DecryptStringFromBytes_Aes(fcnvc[key], encryptionSecret);

                                var      decodeStrings    = decryptText.Split("]-[");
                                DateTime dateClientSecret = DateTime.ParseExact(decodeStrings[1].Replace("]", ""), "yyyy-MM-ddTHH:mm:ss",
                                                                                System.Globalization.CultureInfo.InvariantCulture);
                                var minutes = (DateTime.Now - dateClientSecret).TotalMinutes;
                                if (minutes < 1 && minutes > -5 || true)
                                {
                                    var valueParameter = decodeStrings[0].Replace("[", "");
                                    fcnvc.Set(parameter, valueParameter);
                                }
                            }
                        }
                    }
                    foreach (var key in fcnvc.AllKeys)
                    {
                        dictValues.Add(key, fcnvc.Get(key));
                    }
                    var fc = new FormCollection(dictValues);
                    context.Request.Form = fc;
                }
            }

            await _next(context);
        }
Esempio n. 3
0
        public AndroidSecretStore(IEncryptionKeyService keyService)
        {
            _keyService = keyService;

            string storageDir;

            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
            {
                storageDir = AndroidApp.Application.Context.NoBackupFilesDir.AbsolutePath;
            }
            else
            {
                storageDir = AndroidApp.Application.Context.FilesDir.AbsolutePath;
            }

            _storePath = Path.Combine(new[] { storageDir, HealthVaultConstants.Storage.DirectoryName });
        }
Esempio n. 4
0
 public EncryptingService(IEncryptionKeyService encryptionKeyService)
 {
     _encryptionKeyService = encryptionKeyService;
 }
Esempio n. 5
0
 public MainController(IEncryptionKeyService encryptionKeyService, IEncryptionService encryptionService)
 {
     _encryptionKeyService = encryptionKeyService;
     _encryptionService    = encryptionService;
 }