| OLD | NEW |
| 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/base/x509_cert_types.h" | 5 #include "net/base/x509_cert_types.h" |
| 6 | 6 |
| 7 #include <ostream> | 7 #include <ostream> |
| 8 | 8 |
| 9 #include "net/base/x509_certificate.h" | 9 #include "net/base/x509_certificate.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 for (i2 = 0; i2 < rdn2.size(); ++i2) { | 29 for (i2 = 0; i2 < rdn2.size(); ++i2) { |
| 30 if (match(rdn1[i1], rdn2[i2])) | 30 if (match(rdn1[i1], rdn2[i2])) |
| 31 break; | 31 break; |
| 32 } | 32 } |
| 33 if (i2 == rdn2.size()) | 33 if (i2 == rdn2.size()) |
| 34 return false; | 34 return false; |
| 35 } | 35 } |
| 36 return true; | 36 return true; |
| 37 } | 37 } |
| 38 | 38 |
| 39 CertPrincipal::CertPrincipal() { |
| 40 } |
| 41 |
| 42 CertPrincipal::CertPrincipal(const std::string& name) : common_name(name) {} |
| 43 |
| 44 CertPrincipal::~CertPrincipal() { |
| 45 } |
| 39 | 46 |
| 40 bool CertPrincipal::Matches(const CertPrincipal& against) const { | 47 bool CertPrincipal::Matches(const CertPrincipal& against) const { |
| 41 return match(common_name, against.common_name) && | 48 return match(common_name, against.common_name) && |
| 42 match(common_name, against.common_name) && | 49 match(common_name, against.common_name) && |
| 43 match(locality_name, against.locality_name) && | 50 match(locality_name, against.locality_name) && |
| 44 match(state_or_province_name, against.state_or_province_name) && | 51 match(state_or_province_name, against.state_or_province_name) && |
| 45 match(country_name, against.country_name) && | 52 match(country_name, against.country_name) && |
| 46 match(street_addresses, against.street_addresses) && | 53 match(street_addresses, against.street_addresses) && |
| 47 match(organization_names, against.organization_names) && | 54 match(organization_names, against.organization_names) && |
| 48 match(organization_unit_names, against.organization_unit_names) && | 55 match(organization_unit_names, against.organization_unit_names) && |
| (...skipping 25 matching lines...) Expand all Loading... |
| 74 s << "ou=\"" << p.organization_unit_names[i] << "\" "; | 81 s << "ou=\"" << p.organization_unit_names[i] << "\" "; |
| 75 if (!p.state_or_province_name.empty()) | 82 if (!p.state_or_province_name.empty()) |
| 76 s << "st=\"" << p.state_or_province_name << "\" "; | 83 s << "st=\"" << p.state_or_province_name << "\" "; |
| 77 if (!p.country_name.empty()) | 84 if (!p.country_name.empty()) |
| 78 s << "c=\"" << p.country_name << "\" "; | 85 s << "c=\"" << p.country_name << "\" "; |
| 79 for (unsigned i = 0; i < p.domain_components.size(); ++i) | 86 for (unsigned i = 0; i < p.domain_components.size(); ++i) |
| 80 s << "dc=\"" << p.domain_components[i] << "\" "; | 87 s << "dc=\"" << p.domain_components[i] << "\" "; |
| 81 return s << "]"; | 88 return s << "]"; |
| 82 } | 89 } |
| 83 | 90 |
| 91 CertPolicy::CertPolicy() { |
| 92 } |
| 93 |
| 94 CertPolicy::~CertPolicy() { |
| 95 } |
| 96 |
| 84 CertPolicy::Judgment CertPolicy::Check( | 97 CertPolicy::Judgment CertPolicy::Check( |
| 85 X509Certificate* cert) const { | 98 X509Certificate* cert) const { |
| 86 // It shouldn't matter which set we check first, but we check denied first | 99 // It shouldn't matter which set we check first, but we check denied first |
| 87 // in case something strange has happened. | 100 // in case something strange has happened. |
| 88 | 101 |
| 89 if (denied_.find(cert->fingerprint()) != denied_.end()) { | 102 if (denied_.find(cert->fingerprint()) != denied_.end()) { |
| 90 // DCHECK that the order didn't matter. | 103 // DCHECK that the order didn't matter. |
| 91 DCHECK(allowed_.find(cert->fingerprint()) == allowed_.end()); | 104 DCHECK(allowed_.find(cert->fingerprint()) == allowed_.end()); |
| 92 return DENIED; | 105 return DENIED; |
| 93 } | 106 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 116 | 129 |
| 117 bool CertPolicy::HasAllowedCert() const { | 130 bool CertPolicy::HasAllowedCert() const { |
| 118 return !allowed_.empty(); | 131 return !allowed_.empty(); |
| 119 } | 132 } |
| 120 | 133 |
| 121 bool CertPolicy::HasDeniedCert() const { | 134 bool CertPolicy::HasDeniedCert() const { |
| 122 return !denied_.empty(); | 135 return !denied_.empty(); |
| 123 } | 136 } |
| 124 | 137 |
| 125 } // namespace net | 138 } // namespace net |
| OLD | NEW |