Esempio n. 1
0
            public void ThenRepositoryFailsToGetCertificate_IfKeyInfoIsNull()
            {
                // Arrange
                var sut = new KeyInfoRepository(keyInfo: null);

                // Act
                X509Certificate2 actualCertificate = sut.GetCertificate();

                // Assert
                Assert.Null(actualCertificate);
            }
Esempio n. 2
0
            public void ThenRepositoryFailsToGetCertificate_IfKeyInfoHasntAnyClauses()
            {
                // Arrange
                var sut = new KeyInfoRepository(new KeyInfo());

                // Act
                X509Certificate2 actualCertificate = sut.GetCertificate();

                // Assert
                Assert.Null(actualCertificate);
            }
Esempio n. 3
0
            public void ThenRepositoryFailsToGetCertificate_IfSecurityTokenReferenceHasntAnyCertificate()
            {
                // Arrange
                var keyInfo = new KeyInfo();

                keyInfo.AddClause(new BinarySecurityTokenReference(certificate: null));
                var repository = new KeyInfoRepository(keyInfo);

                // Act
                X509Certificate2 actualCertificate = repository.GetCertificate();

                // Assert
                Assert.Null(actualCertificate);
            }
Esempio n. 4
0
            public void ThenRepositoryGetsCertificate_IfKeyInfoHasEmbeddedCertificate()
            {
                // Arrange
                var     expectedCertificate = new X509Certificate2();
                KeyInfo keyInfo             = CreateKeyInfoWithEmbeddedCertificate(expectedCertificate);

                var sut = new KeyInfoRepository(keyInfo);

                // Act
                X509Certificate2 actualCertificate = sut.GetCertificate();

                // Assert
                Assert.Equal(expectedCertificate, actualCertificate);
            }
Esempio n. 5
0
        protected override AsymmetricAlgorithm GetPublicKey()
        {
            AsymmetricAlgorithm publicKey = base.GetPublicKey();

            if (publicKey != null)
            {
                return(publicKey);
            }

            X509Certificate2 signingCertificate = new KeyInfoRepository(KeyInfo).GetCertificate();

            if (signingCertificate != null)
            {
                publicKey = signingCertificate.PublicKey.Key;
            }

            return(publicKey);
        }