Пример #1
0
        public void TestOioSamlToIdCardRequest()
        {
            var domBuilder = factory.CreateOiosamlAssertionToIdCardRequestDomBuilder();

            domBuilder.SigningVault          = (vocesVault);
            domBuilder.OioSamlAssertion      = (ParseOioSamlAssertion());
            domBuilder.ItSystemName          = ("EMS");
            domBuilder.UserAuthorizationCode = ("2345C");
            domBuilder.UserEducationCode     = ("7170");
            domBuilder.UserGivenName         = ("Fritz");
            domBuilder.UserSurName           = ("Müller");
            var requestDoc = domBuilder.Build();

            var assertionToIdCardRequest = factory.CreateOioSamlAssertionToIdCardRequestModelBuilder().Build(requestDoc);

            Assert.AreEqual("EMS", assertionToIdCardRequest.ItSystemName);
            Assert.AreEqual("2345C", assertionToIdCardRequest.UserAuthorizationCode);
            Assert.AreEqual("7170", assertionToIdCardRequest.UserEducationCode);
            Assert.AreEqual("Fritz", assertionToIdCardRequest.UserGivenName);
            Assert.AreEqual("Müller", assertionToIdCardRequest.UserSurName);
            Assert.AreEqual("http://sosi.dk", assertionToIdCardRequest.AppliesTo);
            Assert.AreEqual("http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue", assertionToIdCardRequest.Action);
            assertionToIdCardRequest.ValidateSignature();
            assertionToIdCardRequest.ValidateSignatureAndTrust(vocesVault);
            try
            {
                assertionToIdCardRequest.ValidateSignatureAndTrust(CredentialVaultTestUtil.GetOCES2CredentialVault());
            }
            catch (ModelException e)
            {
                Assert.AreEqual("The certificate that signed the security token is not trusted!", e.Message);
            }
            Assert.AreEqual(vocesVault.GetSystemCredentials(), assertionToIdCardRequest.GetSigningCertificate());

            var assertion = assertionToIdCardRequest.OioSamlAssertion;

            Assert.AreEqual("25520041", assertion.CvrNumberIdentifier);
            Assert.AreEqual("_5a49e560-5312-4237-8f32-2ed2b58cfcf7", assertion.Id);
            //assertion.ValidateSignatureAndTrust(SOSITestUtils.getOldIdPTrustVault());
        }
Пример #2
0
        public void TestIdCardToOioSamlRequest()
        {
            var domBuilder = factory.CreateIdCardToOioSamlAssertionRequestDomBuilder();

            domBuilder.SigningVault = (vocesVault);
            domBuilder.Audience     = ("Sundhed.dk");
            var idCard = CreateIdCard();

            domBuilder.IdCard = (idCard);
            var requestDoc = domBuilder.Build();

            var assertionRequest = factory.CreateIdCardToOioSamlAssertionRequestModelBuilder().Build(requestDoc);

            Assert.AreEqual("Sundhed.dk", assertionRequest.AppliesTo);
            Assert.AreEqual("http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue", assertionRequest.Action);
            assertionRequest.ValidateSignature();
            assertionRequest.ValidateSignatureAndTrust(vocesVault);
            try
            {
                assertionRequest.ValidateSignatureAndTrust(CredentialVaultTestUtil.GetOCES2CredentialVault());
            }
            catch (ModelException e)
            {
                Assert.AreEqual("The certificate that signed the security token is not trusted!", e.Message);
            }
            Assert.AreEqual(vocesVault.GetSystemCredentials(), assertionRequest.GetSigningCertificate());

            Assert.IsTrue(idCard.Equals(assertionRequest.UserIdCard));
            assertionRequest.UserIdCard.ValidateSignature();
            assertionRequest.UserIdCard.ValidateSignatureAndTrust(mocesVault);
            try
            {
                assertionRequest.UserIdCard.ValidateSignatureAndTrust(new SosiFederation(new CrlCertificateStatusChecker()));
            }
            catch (ModelException e)
            {
                Assert.AreEqual("The certificate that signed the security token is not trusted!", e.Message);
            }
        }