Пример #1
0
        public void IdCardNullUserInfoTest()
        {
            //Create factory
            SOSIFactory factory = CreateSOSIFactory(Global.MocesCprGyldig);

            //Create IdCard with missing UserInfo
            Assert.Throws <ModelException>(delegate {
                UserIdCard idCard = factory.CreateNewUserIdCard("ItSystem", null, new CareProvider(SubjectIdentifierType.medcomcvrnumber, "25520041", "TRIFORK SERVICES A/S // CVR:25520041"), AuthenticationLevel.MocesTrustedUser, "", "", factory.GetCredentialVault().GetSystemCredentials(), "alt");
            });
        }
Пример #2
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); });
        }
Пример #3
0
        //	private Federation getMockFederation()
        //	{
        //		return new SOSITestFederation(System.getProperties()) {
        //			@Override

        //			public boolean isValidSTSCertificate(X509Certificate certificate)
        //		{
        //			return vocesVault.getSystemCredentialPair().getCertificate().equals(certificate);
        //		}
        //	};
        //}

        //private UserInfo BuildUserInfo(OioSamlAssertionToIdCardRequest request)
        //	{
        //		var assertion = request.OioSamlAssertion;
        //		string cpr = "XXXXXXXX"; // Perform lookup based on assertion.getCvrNumberIdentifier() and assertion.getRidNumberIdentifier()
        //		string givenName;
        //		string surName;
        //		if (request.UserGivenName != null && request.UserSurName != null)
        //		{
        //			givenName = request.UserGivenName;
        //			surName = request.UserSurName;
        //		}
        //		else
        //		{
        //			// The IdP cannot split CommonName and neither should we (assertion.getSurName() returns null)
        //			givenName =
        //				assertion.CommonName;
        //			surName = "-";
        //		}
        //		//var email = assertion.GetAttributeValue("urn:oid:0.9.2342.19200300.100.1.3");
        //		var email = assertion.Email;
        //		string occupation = null;
        //		var role = "YYYYY"; // Lookup based on CPR, use request.getUserEducationCode() to pick the right one (or validate)
        //		var authorizationCode = "ZZZZZ";// Lookup based on CPR, use request.getUserAuthorizationCode() to pick the right one (or validate)
        //		return new UserInfo(cpr, givenName, surName, email, occupation, role, authorizationCode);
        //	}

        private UserIdCard CreateIdCard()
        {
            SOSIFactory  sosiFactory           = new SOSIFactory(null, new CredentialVaultSignatureProvider(mocesVault));
            CareProvider careProvider          = new CareProvider(SubjectIdentifierType.medcomcvrnumber, "30808460", "Lægehuset på bakken");
            UserInfo     userInfo              = new UserInfo("1111111118", "Hans", "Dampf", "", "", "7170", "341KY");
            String       alternativeIdentifier = new CertificateInfo(mocesVault.GetSystemCredentials()).ToString();
            var          userIdCard            = sosiFactory.CreateNewUserIdCard("IT-System", userInfo, careProvider, AuthenticationLevel.MocesTrustedUser, null, null, null, alternativeIdentifier);

            userIdCard.Sign <Assertion>(sosiFactory.SignatureProvider);
            return(userIdCard);
        }
Пример #4
0
 public UserIdCard CreateIdCardForSTS(SOSIFactory factory)
 {
     return(factory.CreateNewUserIdCard("Sygdom.dk", new UserInfo("1802602810", "Stine", "Svendsen", "*****@*****.**", "læge", "7170", "ZXCVB"), new CareProvider(SubjectIdentifierType.medcomcvrnumber, "30808460", "Statens Serum Institut"), AuthenticationLevel.MocesTrustedUser, "", "", Global.MocesCprGyldig, ""));
 }
Пример #5
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"));
 }
Пример #6
0
 public UserIdCard CreateMocesUserIdCard(SOSIFactory factory)
 {
     return(factory.CreateNewUserIdCard("Sygdom.dk", new UserInfo("2408631478", "Amaja", "Christiansen", "*****@*****.**", "Læge", "5175", "5GXFR"), new CareProvider(SubjectIdentifierType.medcomcvrnumber, "25520041", "TRIFORK SERVICES A/S // CVR:25520041"), AuthenticationLevel.MocesTrustedUser, null, null, Global.MocesCprGyldig, null));
 }