Exemplo n.º 1
0
        public void ValidateSignatureTest()
        {
            SOSIFactory factory = CreateSOSIFactory(Global.MocesCprGyldig);
            UserIdCard  idCard  = CreateMocesUserIdCard(factory);

            idCard.Sign <Assertion>(factory.SignatureProvider);

            //This throws if you are not connected to VPN
            Assert.DoesNotThrow(delegate { idCard.ValidateSignatureAndTrust(factory.GetCredentialVault()); });
        }
Exemplo n.º 2
0
        public void SelfSignedIdCardTest()
        {
            //Create factory
            SOSIFactory factory = CreateSOSIFactoryWithTestFederation(Global.MocesCprGyldig);

            //Create IdCard
            UserIdCard idCard = CreateIdCardForSTS(factory);

            //Sign IdCard
            idCard.Sign <Assertion>(factory.SignatureProvider);

            //Assert that selfsigned idCard fails
            Assert.Throws <ModelException>(delegate { idCard.ValidateSignatureAndTrust(factory.Federation); });
        }
Exemplo n.º 3
0
        public void IsTrustedStsCertificateTest()
        {
            //Create factory
            SOSIFactory factory = CreateSOSIFactoryWithTestFederation(Global.MocesCprGyldig);

            //Create IdCard
            UserIdCard idCard = CreateIdCardForSTS(factory);

            //Sign IdCard
            idCard.Sign <Assertion>(factory.SignatureProvider);

            UserIdCard idc = (UserIdCard)SealUtilities.SignIn(idCard, "NETS DANID A/S", Settings.Default.SecurityTokenService);

            //Assert that STS certificate goes through
            Assert.DoesNotThrow(delegate { idc.ValidateSignatureAndTrust(factory.Federation); });
        }
Exemplo n.º 4
0
        public void SosiFederationTest()
        {
            //Create factory
            SOSIFactory factory = CreateSOSIFactoryWithSosiFederation(Global.MocesCprGyldig);

            //Create IdCard
            UserIdCard idCard = CreateIdCardForSTS(factory);

            //Sign IdCard
            idCard.Sign <Assertion>(factory.SignatureProvider);

            UserIdCard idc = (UserIdCard)SealUtilities.SignIn(idCard, "NETS DANID A/S", Settings.Default.SecurityTokenService);

            //Assert that STS certificate fails due to mismatch in prefix/cvr
            Assert.Throws <ModelException>(delegate { idc.ValidateSignatureAndTrust(factory.Federation); });
        }
Exemplo n.º 5
0
        public void ValidateSignatureNegativeTest()
        {
            if (ConfigurationManager.AppSettings.AllKeys.Contains("CheckDate"))
            {
                ConfigurationManager.AppSettings["CheckDate"] = "True";
            }
            //Get invalid certificate
            X509Certificate2 newCert = new X509Certificate2(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "Resources", "oces2", "PP", "MOCES_udloebet.p12"), "Test1234");
            SOSIFactory      factory = CreateSOSIFactory(newCert);
            UserIdCard       idCard  = CreateMocesUserIdCard(factory);

            idCard.Sign <Assertion>(factory.SignatureProvider);

            Assert.Throws <ModelException>(delegate { idCard.ValidateSignatureAndTrust(factory.GetCredentialVault()); });
            if (ConfigurationManager.AppSettings.AllKeys.Contains("CheckDate"))
            {
                ConfigurationManager.AppSettings["CheckDate"] = "False";
            }
        }