public void ThenRepositoryFailsToGetCertificate_IfKeyInfoIsNull() { // Arrange var sut = new KeyInfoRepository(keyInfo: null); // Act X509Certificate2 actualCertificate = sut.GetCertificate(); // Assert Assert.Null(actualCertificate); }
public void ThenRepositoryFailsToGetCertificate_IfKeyInfoHasntAnyClauses() { // Arrange var sut = new KeyInfoRepository(new KeyInfo()); // Act X509Certificate2 actualCertificate = sut.GetCertificate(); // Assert Assert.Null(actualCertificate); }
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); }
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); }
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); }