Example #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()); });
        }
Example #2
0
 public SystemIdCard CreateVocesSystemIdCard(SOSIFactory factory)
 {
     return(factory.CreateNewSystemIdCard("ItSystem", new CareProvider(SubjectIdentifierType.medcomcvrnumber, "25520041", "TRIFORK SERVICES A/S // CVR:25520041"), AuthenticationLevel.VocesTrustedSystem, null, null, factory.GetCredentialVault().GetSystemCredentials(), "alt"));
 }
Example #3
0
 public UserIdCard CreateUserIdCard(SOSIFactory factory, string userName, string passWord)
 {
     return(factory.CreateNewUserIdCard("ItSystem", new UserInfo("12345678", "Test", "Person", "*****@*****.**", "Tester", "Læge", "12345"), new CareProvider(SubjectIdentifierType.medcomcvrnumber, "25520041", "TRIFORK SERVICES A/S // CVR:25520041"), AuthenticationLevel.UsernamePasswordAuthentication, userName, passWord, factory.GetCredentialVault().GetSystemCredentials(), "alt"));
 }
Example #4
0
        public void IdCardNullCareProviderTest()
        {
            //Create factory
            SOSIFactory factory = CreateSOSIFactory(Global.MocesCprGyldig);

            //Create IdCard with missing UserInfo
            Assert.Throws <ModelException>(delegate {
                factory.CreateNewSystemIdCard("ItSystem", null, AuthenticationLevel.MocesTrustedUser, null, null, factory.GetCredentialVault().GetSystemCredentials(), "alt");
            });
        }
Example #5
0
        public void IdCardNullSystemInfoTest()
        {
            //Create factory
            SOSIFactory factory = CreateSOSIFactory(Global.MocesCprGyldig);

            //Create IdCard with missing UserInfo
            Assert.Throws <ModelException>(delegate {
                factory.CreateNewSystemIdCard("", new CareProvider(SubjectIdentifierType.medcomcvrnumber, "25520041", "TRIFORK SERVICES A/S // CVR:25520041"), AuthenticationLevel.MocesTrustedUser, null, null, factory.GetCredentialVault().GetSystemCredentials(), "alt");
            });
        }
Example #6
0
        public void IdCardValidatorTest()
        {
            //Create factory
            SOSIFactory factory = CreateSOSIFactory(Global.MocesCprGyldig);

            //Create IdCard with missing UserGivenName
            UserIdCard idCard = factory.CreateNewUserIdCard("ItSystem", new UserInfo("12345678", null, "Person", "*****@*****.**", "Tester", "Læge", "12345"), new CareProvider(SubjectIdentifierType.medcomcvrnumber, "25520041", "TRIFORK SERVICES A/S // CVR:25520041"), AuthenticationLevel.MocesTrustedUser, "", "", factory.GetCredentialVault().GetSystemCredentials(), "alt");

            //Try to sign the idCard
            Assert.Throws <ModelException>(delegate { idCard.Sign <Assertion>(factory.SignatureProvider); });
        }
Example #7
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";
            }
        }