Пример #1
0
        public X509FederationClientTests()
        {
            var leafCertificateSupplier = new Mock <IX509CertificateSupplier>();
            var certificateKeyPair      = new CertificateAndPrivateKeyPair();

            certificateKeyPair.Certificate = new X509Certificate2("cacert.pem");
            rsaKeyParamMock = new Mock <RsaKeyParameters>(true, new BigInteger("1"), new BigInteger("2"));
            certificateKeyPair.PrivateKey = rsaKeyParamMock.Object;

            leafCertificateSupplier.Setup(p => p.Refresh());
            leafCertificateSupplier.Setup(p => p.GetCertificateAndKeyPair()).Returns(certificateKeyPair);

            var intermediateCertificateSuppliers = new Mock <HashSet <IX509CertificateSupplier> >();
            var certificate = new Mock <IX509CertificateSupplier>();

            certificate.Setup(p => p.Refresh());
            intermediateCertificateSuppliers.Object.Add(certificate.Object);

            x509FederationClient = new X509FederationClient("https://auth.us-phoenix-1.oraclecloud.com", "",
                                                            leafCertificateSupplier.Object,
                                                            new SessionKey(),
                                                            intermediateCertificateSuppliers.Object,
                                                            "test");

            signerMock = new Mock <ISigner>();
            signerMock.Setup(s => s.GenerateSignature()).Returns(new byte[] { 1, 2, 3, 4, 5 });
        }
 /// <summary> Update or extend the validity period for an Object. </summary>
 public void Refresh()
 {
     if (Client == null)
     {
         Client = new HttpClient();
     }
     try
     {
         var x509Certificate         = ReadRawCertificate(certificateDetails);
         RsaKeyParameters privateKey = ReadPrivateKey(this.privateKeyDetails, this.privateKeyPassphraseCharacters);
         this.certificateAndKeyPair             = new CertificateAndPrivateKeyPair();
         this.certificateAndKeyPair.Certificate = x509Certificate;
         this.certificateAndKeyPair.PrivateKey  = privateKey;
     }
     finally
     {
         Dispose();
     }
 }