Beispiel #1
0
        private void WriteOutputs(JsonWebKeyOutput output)
        {
            _outputAction(string.Empty);

            WriteSectionDivider();

            WriteSection("JsonWebKey", output.JsonWebKeyString);

            WriteSectionDivider();

            if (_options.OutputBase64)
            {
                WriteSection("Base64 Encoded JsonWebKey", output.Base64JsonWebKey);

                WriteSectionDivider();
            }

            if (_options.OutputRsaKeys)
            {
                WriteSection("RSA Private Key", output.RsaPrivateKey);

                WriteSectionDivider();

                WriteSection("RSA Public Key", output.RsaPublicKey);

                WriteSectionDivider();
            }
        }
        public async Task WriteAsync(JsonWebKeyOutput output)
        {
            if (!Directory.Exists(_options.Directory))
            {
                Directory.CreateDirectory(_options.Directory);
            }

            await File.WriteAllTextAsync(Path.Combine(_options.Directory, JsonWebKeyFileName), output.JsonWebKeyString);

            if (_options.OutputBase64)
            {
                await File.WriteAllTextAsync(Path.Combine(_options.Directory, JsonWebKeyFileName), output.Base64JsonWebKey);
            }
            if (_options.OutputRsaKeys)
            {
                await File.WriteAllTextAsync(Path.Combine(_options.Directory, RsaPublicKeyFileName), output.RsaPublicKey);

                await File.WriteAllTextAsync(Path.Combine(_options.Directory, RsaPrivateKeyFileName), output.RsaPrivateKey);
            }

            _logger.LogInformation($"JsonWebKey details written to files in {_options.Directory}");
        }
Beispiel #3
0
 public async Task WriteAsync(JsonWebKeyOutput output)
 {
     WriteOutputs(output);
     await Task.CompletedTask;
 }