/// <summary> /// Adds CA certificate to NTAuth entry in Active Directory. /// </summary> /// <param name="cert">CA certificate to add.</param> /// <exception cref="UninitializedObjectException"> /// <strong>cert</strong> parameter is not valid X.509 certificate object. /// </exception> /// <exception cref="ArgumentNullException"> /// <strong>cert</strong> parameter is null. /// </exception> /// <inheritdoc cref="DsPkiCertContainer.AddCertificateEntry" section="returns|remarks/*"/> public Boolean AddCertificate(X509Certificate2 cert) { if (cert == null) { throw new ArgumentNullException(nameof(cert)); } if (cert.RawData == null) { throw new UninitializedObjectException(); } var entry = new DsCertificateEntry("NTAuth", cert, DsCertificateType.CACertificate); return(AddCertificateEntry(entry)); }
/// <summary> /// Adds CA certificate to RootCA entry in Active Directory. /// </summary> /// <param name="cert">Root CA certificate to add.</param> /// <exception cref="UninitializedObjectException"> /// <strong>cert</strong> parameter is not valid X.509 certificate object. /// </exception> /// <exception cref="ArgumentNullException"> /// <strong>cert</strong> parameter is null. /// </exception> /// <inheritdoc cref="DsPkiCertContainer.AddCertificateEntry" section="returns|remarks/*"/> public Boolean AddCertificate(X509Certificate2 cert) { if (cert == null) { throw new ArgumentNullException(nameof(cert)); } if (cert.RawData == null) { throw new UninitializedObjectException(); } String containerName = GetContainerName(cert); var entry = new DsCertificateEntry(containerName, cert, DsCertificateType.CACertificate); return(AddCertificateEntry(entry)); }
/// <summary> /// Removes certificate from internal list. /// </summary> /// <param name="entry">Certificate entry to remove.</param> /// <exception cref="ArgumentNullException"> /// <strong>entry</strong> parameter is null. /// </exception> /// <returns> /// <strong>True</strong> if specified certificate entry was found, otherwise <strong>False</strong>. /// </returns> protected Boolean RemoveCertificateEntry(DsCertificateEntry entry) { if (entry == null) { throw new ArgumentNullException(nameof(entry)); } if (!_list.Contains(entry)) { return(false); } // mutually exclusive. entry cannot be added and removed at the same time. _toBeRemoved.Add(entry.Name); _toBeAdded.Remove(entry.Name); _list.Remove(entry); DsList[entry.Name].Remove(entry); return(IsModified = true); }
/// <summary> /// Adds CA certificate to AIA entry as CA certificate or cross-certificate. The type is determined by <strong>type</strong> /// parameter. /// <para> /// <strong>Note:</strong> 'userCertificate' type is not supported by this method. /// </para> /// </summary> /// <param name="cert">CA certificate to add.</param> /// <param name="type">Certificate type. Can be either 'CACertificate' or 'CrossCertificate'.</param> /// <exception cref="ArgumentException"> /// specified certificate type is not valid. /// </exception> /// <exception cref="UninitializedObjectException"> /// <strong>cert</strong> parameter is not valid X.509 certificate object. /// </exception> /// <exception cref="ArgumentNullException"> /// <strong>cert</strong> parameter is null. /// </exception> /// <inheritdoc cref="DsPkiCertContainer.AddCertificateEntry" section="returns|remarks/*"/> public Boolean AddCertificate(X509Certificate2 cert, DsCertificateType type) { if (cert == null) { throw new ArgumentNullException(nameof(cert)); } if (cert.RawData == null) { throw new UninitializedObjectException(); } if (type == DsCertificateType.UserCertificate) { throw new ArgumentException("Specified type is not supported."); } String containerName = GetContainerName(cert); var entry = new DsCertificateEntry(containerName, cert, type); return(AddCertificateEntry(entry)); }
/// <summary> /// Removes KRA certificate from the current KRA container. /// </summary> /// <param name="entry">CA certificate to remove</param> /// <inheritdoc cref="DsPkiCertContainer.RemoveCertificateEntry" section="exception|returns|remarks/*"/> public Boolean RemoveCertificate(DsCertificateEntry entry) { return(RemoveCertificateEntry(entry)); }
Boolean Equals(DsCertificateEntry other) { return(String.Equals(Name, other.Name, StringComparison.OrdinalIgnoreCase) && Certificate.Equals(other.Certificate) && CertificateType == other.CertificateType); }