Пример #1
0
 public static LdapConnection CreateLdapConnection(OcesEnvironment environment)
 {
     var ldapServerName = Properties.Get("ldap.server.danid." + environment);
     var ldapConnection = new LdapConnection(ldapServerName) { AuthType = AuthType.Anonymous };
     ldapConnection.SessionOptions.ProtocolVersion = 3;
     return ldapConnection;
 }
Пример #2
0
 private static bool MatchMocesPolicy(X509Certificate2 endUserCertificate, OcesEnvironment currentEnv)
 {
     if (OcesEnvironment.OcesIDanidEnvDevelopment.Equals(currentEnv) || OcesEnvironment.OcesIDanidEnvSystemtest.Equals(currentEnv) || OcesEnvironment.CampusIDanidEnvProd.Equals(currentEnv))
     {
         return(true); // we do not validate OCES1 dev and systemtest.
     }
     return(MatchPolicy(endUserCertificate, Properties.Get("moces.policies.prefix.danid." + currentEnv)));
 }
Пример #3
0
 /// <summary>
 /// Gets root certificate of the given <code>Environment</code>
 /// </summary>
 public static X509Certificate2 LookupCertificate(OcesEnvironment environment)
 {
     if (!TheRootCertificates.ContainsKey(environment))
     {
         throw new ArgumentException("No certificate for: " + environment);
     }
     return(TheRootCertificates[environment]);
 }
        public bool IsRevoked(Ca ca)
        {
            if (ca.IsRoot)
            {
                return(false);
            }
            OcesEnvironment environment = RootCertificates.GetEnvironment(ca.IssuingCa);

            return(DownloadCrl(ca, environment).IsRevoked(ca) || IsRevoked(ca.IssuingCa));
        }
Пример #5
0
        public Crl Download(OcesEnvironment environment, string ldapPath)
        {
            using (var connection = LdapFactory.CreateLdapConnection(environment))
            {
                var request  = new SearchRequest(ldapPath, (string)null, SearchScope.Base, new[] { LdapFactory.CertificateRevocationListBinary });
                var response = (SearchResponse)connection.SendRequest(request);
                var bytes    = (byte[])response.Entries[0].Attributes[LdapFactory.CertificateRevocationListBinary][0];

                return(new Crl(bytes));
            }
        }
Пример #6
0
        public static LdapConnection CreateLdapConnection(OcesEnvironment environment)
        {
            var ldapServerName = Properties.Get("ldap.server.danid." + environment);
            var ldapConnection = new LdapConnection(ldapServerName)
            {
                AuthType = AuthType.Anonymous
            };

            ldapConnection.SessionOptions.ProtocolVersion = 3;
            return(ldapConnection);
        }
Пример #7
0
        public Crl Download(OcesEnvironment environment, string ldapPath)
        {
            using (var connection = LdapFactory.CreateLdapConnection(environment))
            {
                var request = new SearchRequest(ldapPath, (string)null, SearchScope.Base, new[] { LdapFactory.CertificateRevocationListBinary});
                var response = (SearchResponse) connection.SendRequest(request);
                var bytes = (byte[])response.Entries[0].Attributes[LdapFactory.CertificateRevocationListBinary][0];

                return new Crl(bytes);
            }
        }
Пример #8
0
 private static bool MatchPocesPolicy(X509Certificate2 endUserCertificate, OcesEnvironment currentEnv)
 {
     if (OcesEnvironment.OcesIDanidEnvDevelopment.Equals(currentEnv) || OcesEnvironment.OcesIDanidEnvSystemtest.Equals(currentEnv))
     {
         return(true); // we do not validate OCES1 dev and systemtest.
     }
     if (OcesEnvironment.OcesIiDanidEnvPreprod.Equals(currentEnv))
     {
         return(true); // we do not validate OCES2 preprod as external partners might have older certificates not satisfying this.
     }
     return(MatchPolicy(endUserCertificate, Properties.Get("poces.policies.prefix.danid." + currentEnv)));
 }
        /// <summary>
        /// The partitioned CRL to check for revocation is retrieved using LDAP.
        /// </summary>
        public bool IsRevoked(IOcesCertificate certificate)
        {
            string          ldapPath    = certificate.PartitionedCrlDistributionPoint;
            OcesEnvironment environment = RootCertificates.GetEnvironment(certificate.IssuingCa);

            Crl crl = _crlDownloader.Download(environment, ldapPath);

            if (!crl.IsPartial())
            {
                throw new InvalidCrlException("Crl was downloaded successfully, but is not a partial CRL:" + ldapPath);
            }
            if (!crl.IsCorrectPartialCrl(ldapPath))
            {
                throw new InvalidCrlException("Crl was downloaded successfully, but is not the correct partitioned crl:" + ldapPath);
            }


            return(crl.IsRevoked(certificate) || IsRevoked(certificate.IssuingCa));
        }
Пример #10
0
 private static bool MatchVocesPolicy(X509Certificate2 endUserCertificate, OcesEnvironment currentEnv)
 {
     if (OcesEnvironment.OcesIDanidEnvDevelopment.Equals(currentEnv) || OcesEnvironment.OcesIDanidEnvSystemtest.Equals(currentEnv))
     {
         return true; // we do not validate OCES1 dev and systemtest.
     }
     return MatchPolicy(endUserCertificate, Properties.Get("voces.policies.prefix.danid." + currentEnv));
 }
Пример #11
0
 private static bool MatchPocesPolicy(X509Certificate2 endUserCertificate, OcesEnvironment currentEnv)
 {
     if (OcesEnvironment.OcesIDanidEnvDevelopment.Equals(currentEnv) || OcesEnvironment.OcesIDanidEnvSystemtest.Equals(currentEnv))
     {
         return true; // we do not validate OCES1 dev and systemtest.
     }
     if (OcesEnvironment.OcesIiDanidEnvPreprod.Equals(currentEnv))
     {
         return true; // we do not validate OCES2 preprod as external partners might have older certificates not satisfying this.
     }
     return MatchPolicy(endUserCertificate, Properties.Get("poces.policies.prefix.danid." + currentEnv));
 }
 /// <summary>
 /// Gets root certificate of the given <code>Environment</code>
 /// </summary>
 public static X509Certificate2 LookupCertificate(OcesEnvironment environment)
 {
     if (!TheRootCertificates.ContainsKey(environment))
     {
         throw new ArgumentException("No certificate for: " + environment);
     }
     return TheRootCertificates[environment];
 }
 public static bool HasCertificate(OcesEnvironment environment)
 {
     return TheRootCertificates.ContainsKey(environment);
 }
Пример #14
0
 public static bool HasCertificate(OcesEnvironment environment)
 {
     return(TheRootCertificates.ContainsKey(environment));
 }
 public LdapDownloadableJob(LdapCrlDownloader downloader, OcesEnvironment environment, String ldapPath)
 {
     _downloader = downloader;
     _environment = environment;
     _ldapPath = ldapPath;
 }
 public Crl Download(OcesEnvironment environment, String ldapPath)
 {
     return _crlCache.GetCrl(ldapPath, new LdapDownloadableJob(_downloader, environment, ldapPath));
 }
 Crl DownloadCrl(Ca ca, OcesEnvironment environment)
 {
     string crlDistributionPoint = CrlDistributionPointsExtractor.ExtractCrlDistributionPoints(ca.Certificate).PartitionedCrlDistributionPoint;
     return _crlDownloader.Download(environment, crlDistributionPoint);
 }
        Crl DownloadCrl(Ca ca, OcesEnvironment environment)
        {
            string crlDistributionPoint = CrlDistributionPointsExtractor.ExtractCrlDistributionPoints(ca.Certificate).PartitionedCrlDistributionPoint;

            return(_crlDownloader.Download(environment, crlDistributionPoint));
        }
Пример #19
0
 public Crl Download(OcesEnvironment environment, String ldapPath)
 {
     return(_crlCache.GetCrl(ldapPath, new LdapDownloadableJob(_downloader, environment, ldapPath)));
 }
Пример #20
0
 public LdapDownloadableJob(LdapCrlDownloader downloader, OcesEnvironment environment, String ldapPath)
 {
     _downloader  = downloader;
     _environment = environment;
     _ldapPath    = ldapPath;
 }