mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
Adding reference source for System.Data System.Data.DataSetExtensions System.Data.Entity System.Data.Entity.Design System.Data.Linq System.Data.SqlXml System.ServiceModel System.ServiceModel.Activation System.ServiceModel.Activities System.ServiceModel.Channels System.ServiceModel.Discovery System.ServiceModel.Internals System.ServiceModel.Routing System.ServiceModel.WasHosting System.ServiceModel.Web System.Web System.Web.ApplicationServices System.Web.DynamicData System.Web.Entity System.Web.Entity.Design System.Web.Extensions System.Web.Mobile System.Web.Routing System.Web.Services System.Xml System.Xml.Linq
76 lines
2.5 KiB
C#
76 lines
2.5 KiB
C#
//-----------------------------------------------------------------------------
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
//-----------------------------------------------------------------------------
|
|
|
|
namespace System.ServiceModel.Security
|
|
{
|
|
using System.Security.Cryptography.X509Certificates;
|
|
using System.ServiceModel;
|
|
|
|
public sealed class X509CertificateInitiatorClientCredential
|
|
{
|
|
internal const StoreLocation DefaultStoreLocation = StoreLocation.CurrentUser;
|
|
internal const StoreName DefaultStoreName = StoreName.My;
|
|
internal const X509FindType DefaultFindType = X509FindType.FindBySubjectDistinguishedName;
|
|
|
|
X509Certificate2 certificate;
|
|
bool isReadOnly;
|
|
|
|
internal X509CertificateInitiatorClientCredential()
|
|
{
|
|
// empty
|
|
}
|
|
|
|
internal X509CertificateInitiatorClientCredential(X509CertificateInitiatorClientCredential other)
|
|
{
|
|
this.certificate = other.certificate;
|
|
this.isReadOnly = other.isReadOnly;
|
|
}
|
|
|
|
public X509Certificate2 Certificate
|
|
{
|
|
get
|
|
{
|
|
return this.certificate;
|
|
}
|
|
set
|
|
{
|
|
ThrowIfImmutable();
|
|
this.certificate = value;
|
|
}
|
|
}
|
|
|
|
public void SetCertificate(string subjectName, StoreLocation storeLocation, StoreName storeName)
|
|
{
|
|
if (subjectName == null)
|
|
{
|
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("subjectName");
|
|
}
|
|
SetCertificate(storeLocation, storeName, DefaultFindType, subjectName);
|
|
}
|
|
|
|
public void SetCertificate(StoreLocation storeLocation, StoreName storeName, X509FindType findType, object findValue)
|
|
{
|
|
if (findValue == null)
|
|
{
|
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("findValue");
|
|
}
|
|
ThrowIfImmutable();
|
|
this.certificate = SecurityUtils.GetCertificateFromStore(storeName, storeLocation, findType, findValue, null);
|
|
}
|
|
|
|
internal void MakeReadOnly()
|
|
{
|
|
this.isReadOnly = true;
|
|
}
|
|
|
|
void ThrowIfImmutable()
|
|
{
|
|
if (this.isReadOnly)
|
|
{
|
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ObjectIsReadOnly)));
|
|
}
|
|
}
|
|
}
|
|
}
|