예제 #1
0
        public static void MyClassInitialize()
        {
            selfSignedSession = CertGenerator.GenerateSelfSigned(TimeSpan.FromMinutes(30));


            IList <XmlElement> claims;

            claims = new List <XmlElement>();
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<saml:Attribute xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" AttributeNamespace=\"urn:be:fgov:identification-namespace\" AttributeName=\"urn:be:fgov:person:ssin\">" +
                        "<saml:AttributeValue xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">79021802145</saml:AttributeValue>" +
                        "</saml:Attribute>");
            claims.Add(doc.DocumentElement);
            doc = new XmlDocument();
            doc.LoadXml("<saml:Attribute xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" AttributeNamespace=\"urn:be:fgov:identification-namespace\" AttributeName=\"urn:be:fgov:ehealth:1.0:certificateholder:person:ssin\">" +
                        "<saml:AttributeValue xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">79021802145</saml:AttributeValue>" +
                        "</saml:Attribute>");
            claims.Add(doc.DocumentElement);
            assertedDefault = new Collection <XmlElement>(claims);

            IList <ClaimTypeRequirement> claimReq;

            claimReq = new List <ClaimTypeRequirement>();
            claimReq.Add(new ClaimTypeRequirement("{urn:be:fgov:identification-namespace}urn:be:fgov:person:ssin"));
            requestedDefault = new Collection <ClaimTypeRequirement>(claimReq);
        }
예제 #2
0
        public static void MyClassInitialize(TestContext testContext)
        {
            ehSsl = new X509Certificate2("ehealthfgovbe.crt");

            X509Store my = new X509Store(StoreName.My, StoreLocation.CurrentUser);

            my.Open(OpenFlags.ReadOnly);
            try
            {
                X509Certificate2Collection fcollection = my.Certificates.Find(X509FindType.FindByTimeValid, DateTime.Now, false);
                X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(fcollection, "Certificate Select", "Select a session certificate (cancel to generate a self signed)", X509SelectionFlag.SingleSelection);
                if (scollection.Count == 0)
                {
                    session = CertGenerator.GenerateSelfSigned(TimeSpan.FromMinutes(120));
                }
                else
                {
                    session = scollection[0];
                }
                X509Certificate2Collection acollection = X509Certificate2UI.SelectFromCollection(fcollection, "Certificate Select", "Select a authentication certificate (e.g. eID)", X509SelectionFlag.SingleSelection);
                auth = acollection[0];
            }
            finally
            {
                my.Close();
            }



            IList <XmlElement> claims;

            claims = new List <XmlElement>();
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<saml:Attribute xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" AttributeNamespace=\"urn:be:fgov:identification-namespace\" AttributeName=\"urn:be:fgov:person:ssin\">" +
                        "<saml:AttributeValue xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">79021802145</saml:AttributeValue>" +
                        "</saml:Attribute>");
            claims.Add(doc.DocumentElement);
            doc = new XmlDocument();
            doc.LoadXml("<saml:Attribute xmlns:saml=\"urn:oasis:names:tc:SAML:1.0:assertion\" AttributeNamespace=\"urn:be:fgov:identification-namespace\" AttributeName=\"urn:be:fgov:ehealth:1.0:certificateholder:person:ssin\">" +
                        "<saml:AttributeValue xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">79021802145</saml:AttributeValue>" +
                        "</saml:Attribute>");
            claims.Add(doc.DocumentElement);
            assertedDefault = new Collection <XmlElement>(claims);

            IList <ClaimTypeRequirement> claimReq;

            claimReq = new List <ClaimTypeRequirement>();
            claimReq.Add(new ClaimTypeRequirement("{urn:be:fgov:identification-namespace}urn:be:fgov:person:ssin"));
            claimReq.Add(new ClaimTypeRequirement("{urn:be:fgov:identification-namespace}urn:be:fgov:ehealth:1.0:certificateholder:person:ssin"));
            //claimReq.Add(new ClaimTypeRequirement("{urn:be:fgov:certified-namespace:ehealth}urn:be:fgov:person:ssin:doctor:boolean"));
            requestedDefault = new Collection <ClaimTypeRequirement>(claimReq);
        }
예제 #3
0
        protected override object CreateBehavior()
        {
            X509Certificate2 session;

            if (SessionCertificate.SelfSigned)
            {
                session = CertGenerator.GenerateSelfSigned(new TimeSpan(1, 0, 0, 0).Add(new TimeSpan(1, 0, 0)));
            }
            else
            {
                X509Store store = new X509Store(SessionCertificate.StoreName, SessionCertificate.StoreLocation);
                store.Open(OpenFlags.IncludeArchived | OpenFlags.MaxAllowed);
                try
                {
                    X509Certificate2Collection found = store.Certificates.Find(SessionCertificate.X509FindType, SessionCertificate.FindValue, false);
                    if (found == null || found.Count != 1)
                    {
                        throw new ConfigurationErrorsException("The Session Certificate was not found");
                    }
                    session = found[0];
                }
                finally
                {
                    store.Close();
                }
            }
            TimeSpan duration = Duration;

            if (duration == TimeSpan.Zero)
            {
                duration = new TimeSpan(1, 0, 0, 0);
            }
            Type cacheType;

            try
            {
                cacheType = Type.GetType(Cache.Type);
            }
            catch (Exception e)
            {
                throw new ConfigurationErrorsException("Invalid cache type", e);
            }
            if (!(typeof(ISessionCache).IsAssignableFrom(cacheType)))
            {
                throw new ConfigurationErrorsException("The cache type must implement ISessionCache");
            }

            return(new SessionBehavior(session, duration, cacheType, Cache.Content));
        }