1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/manager/ssl/src/nsCertificatePrincipal.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsCertificatePrincipal.h" 1.10 + 1.11 +NS_IMPL_ISUPPORTS(nsCertificatePrincipal, nsICertificatePrincipal) 1.12 + 1.13 +NS_IMETHODIMP 1.14 +nsCertificatePrincipal::GetFingerprint(nsACString& aFingerprint) 1.15 +{ 1.16 + aFingerprint = mFingerprint; 1.17 + return NS_OK; 1.18 +} 1.19 + 1.20 +NS_IMETHODIMP 1.21 +nsCertificatePrincipal::GetSubjectName(nsACString& aSubjectName) 1.22 +{ 1.23 + aSubjectName = mSubjectName; 1.24 + return NS_OK; 1.25 +} 1.26 + 1.27 +NS_IMETHODIMP 1.28 +nsCertificatePrincipal::GetPrettyName(nsACString& aPrettyName) 1.29 +{ 1.30 + aPrettyName = mPrettyName; 1.31 + return NS_OK; 1.32 +} 1.33 + 1.34 +NS_IMETHODIMP 1.35 +nsCertificatePrincipal::GetCertificate(nsISupports** aCert) 1.36 +{ 1.37 + nsCOMPtr<nsISupports> cert = mCert; 1.38 + cert.forget(aCert); 1.39 + return NS_OK; 1.40 +} 1.41 + 1.42 +NS_IMETHODIMP 1.43 +nsCertificatePrincipal::GetHasCertificate(bool* rv) 1.44 +{ 1.45 + *rv = true; 1.46 + return NS_OK; 1.47 +} 1.48 + 1.49 +NS_IMETHODIMP 1.50 +nsCertificatePrincipal::Equals(nsICertificatePrincipal* aOther, bool* rv) 1.51 +{ 1.52 + nsAutoCString str; 1.53 + aOther->GetFingerprint(str); 1.54 + if (!str.Equals(mFingerprint)) { 1.55 + *rv = false; 1.56 + return NS_OK; 1.57 + } 1.58 + 1.59 + // If either subject name is empty, just let the result stand, but if they're 1.60 + // both non-empty, only claim equality if they're equal. 1.61 + if (!mSubjectName.IsEmpty()) { 1.62 + // Check the other principal's subject name 1.63 + aOther->GetSubjectName(str); 1.64 + *rv = str.Equals(mSubjectName) || str.IsEmpty(); 1.65 + return NS_OK; 1.66 + } 1.67 + 1.68 + *rv = true; 1.69 + return NS_OK; 1.70 +}