本文整理汇总了C#中System.Security.Authentication.ExtendedProtection.ChannelBinding类的典型用法代码示例。如果您正苦于以下问题:C# ChannelBinding类的具体用法?C# ChannelBinding怎么用?C# ChannelBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChannelBinding类属于System.Security.Authentication.ExtendedProtection命名空间,在下文中一共展示了ChannelBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Authenticate
public Authorization Authenticate(string challenge, NetworkCredential credential, object sessionCookie, string spn, ChannelBinding channelBindingToken)
{
lock (this.sessions)
{
NTAuthentication clientContext = this.sessions[sessionCookie] as NTAuthentication;
if (clientContext == null)
{
if (credential == null){
return null;
}
//
this.sessions[sessionCookie] = clientContext = new NTAuthentication(false, "WDigest", credential, spn, ContextFlags.Connection, channelBindingToken);
}
string resp = clientContext.GetOutgoingBlob(challenge);
if (!clientContext.IsCompleted)
{
return new Authorization(resp, false);
}
else
{
this.sessions.Remove(sessionCookie);
return new Authorization(resp, true);
}
}
}
示例2: Initialize
private void Initialize(bool isServer, string package, NetworkCredential credential, string spn, ContextFlagsPal requestedContextFlags, ChannelBinding channelBinding)
{
if (NetEventSource.IsEnabled) NetEventSource.Enter(this, package, spn, requestedContextFlags);
_tokenSize = NegotiateStreamPal.QueryMaxTokenSize(package);
_isServer = isServer;
_spn = spn;
_securityContext = null;
_requestedContextFlags = requestedContextFlags;
_package = package;
_channelBinding = channelBinding;
if (NetEventSource.IsEnabled) NetEventSource.Info(this, $"Peer SPN-> '{_spn}'");
//
// Check if we're using DefaultCredentials.
//
Debug.Assert(CredentialCache.DefaultCredentials == CredentialCache.DefaultNetworkCredentials);
if (credential == CredentialCache.DefaultCredentials)
{
if (NetEventSource.IsEnabled) NetEventSource.Info(this, "using DefaultCredentials");
_credentialsHandle = NegotiateStreamPal.AcquireDefaultCredential(package, _isServer);
}
else
{
_credentialsHandle = NegotiateStreamPal.AcquireCredentialsHandle(package, _isServer, credential);
}
}
示例3: OnAcceptUpgrade
protected override Stream OnAcceptUpgrade(Stream stream, out SecurityMessageProperty remoteSecurity)
{
SslStream stream2 = new SslStream(stream, false, new RemoteCertificateValidationCallback(this.ValidateRemoteCertificate));
try
{
stream2.AuthenticateAsServer(this.parent.ServerCertificate, this.parent.RequireClientCertificate, SslProtocols.Default, false);
}
catch (AuthenticationException exception)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityNegotiationException(exception.Message, exception));
}
catch (IOException exception2)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityNegotiationException(System.ServiceModel.SR.GetString("NegotiationFailedIO", new object[] { exception2.Message }), exception2));
}
if (System.ServiceModel.Security.SecurityUtils.ShouldValidateSslCipherStrength())
{
System.ServiceModel.Security.SecurityUtils.ValidateSslCipherStrength(stream2.CipherStrength);
}
remoteSecurity = this.clientSecurity;
if (this.IsChannelBindingSupportEnabled)
{
this.channelBindingToken = ChannelBindingUtility.GetToken(stream2);
}
return stream2;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:SslStreamSecurityUpgradeAcceptor.cs
示例4: ServerSingletonConnectionReader
public ServerSingletonConnectionReader(ServerSingletonPreambleConnectionReader preambleReader, IConnection upgradedConnection, ConnectionDemuxer connectionDemuxer) : base(upgradedConnection, preambleReader.BufferOffset, preambleReader.BufferSize, preambleReader.Security, preambleReader.TransportSettings, preambleReader.Via)
{
this.decoder = preambleReader.Decoder;
this.contentType = this.decoder.ContentType;
this.connectionDemuxer = connectionDemuxer;
this.rawConnection = preambleReader.RawConnection;
this.channelBindingToken = preambleReader.ChannelBinding;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:ServerSingletonConnectionReader.cs
示例5: DuplicateToken
public static ChannelBinding DuplicateToken(ChannelBinding source)
{
if (source == null)
{
return null;
}
return DuplicatedChannelBinding.CreateCopy(source);
}
示例6: TryAddToMessage
public static void TryAddToMessage(ChannelBinding channelBindingToken, Message message, bool messagePropertyOwnsCleanup)
{
if (channelBindingToken != null)
{
ChannelBindingMessageProperty property = new ChannelBindingMessageProperty(channelBindingToken, messagePropertyOwnsCleanup);
property.AddTo(message);
property.Dispose(); //message.Properties.Add() creates a copy...
}
}
示例7: Dispose
public static void Dispose(ref ChannelBinding channelBinding)
{
// Explicitly cast to IDisposable to avoid the SecurityException.
IDisposable disposable = (IDisposable)channelBinding;
channelBinding = null;
if (disposable != null)
{
disposable.Dispose();
}
}
示例8: Authenticate
public Authorization Authenticate(string challenge, NetworkCredential credential, object sessionCookie, string spn, ChannelBinding channelBindingToken)
{
Authorization authorization;
if (Logging.On)
{
Logging.Enter(Logging.Web, this, "Authenticate", (string) null);
}
try
{
lock (this.sessions)
{
NTAuthentication clientContext = this.sessions[sessionCookie] as NTAuthentication;
if (clientContext == null)
{
if (credential == null)
{
return null;
}
this.sessions[sessionCookie] = clientContext = new NTAuthentication(false, "Negotiate", credential, spn, ContextFlags.AcceptStream | ContextFlags.Connection, channelBindingToken);
}
string token = null;
if (!clientContext.IsCompleted)
{
SecurityStatus status;
byte[] incomingBlob = null;
if (challenge != null)
{
incomingBlob = Convert.FromBase64String(challenge);
}
byte[] inArray = clientContext.GetOutgoingBlob(incomingBlob, false, out status);
if (clientContext.IsCompleted && (inArray == null))
{
token = "\r\n";
}
if (inArray != null)
{
token = Convert.ToBase64String(inArray);
}
}
else
{
token = this.GetSecurityLayerOutgoingBlob(challenge, clientContext);
}
authorization = new Authorization(token, clientContext.IsCompleted);
}
}
finally
{
if (Logging.On)
{
Logging.Exit(Logging.Web, this, "Authenticate", (string) null);
}
}
return authorization;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:55,代码来源:SmtpNegotiateAuthenticationModule.cs
示例9: ChannelBindingMessageProperty
public ChannelBindingMessageProperty(System.Security.Authentication.ExtendedProtection.ChannelBinding channelBinding, bool ownsCleanup)
{
if (channelBinding == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelBinding");
}
this.refCount = 1;
this.thisLock = new object();
this.channelBinding = channelBinding;
this.ownsCleanup = ownsCleanup;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:ChannelBindingMessageProperty.cs
示例10: CheckChannelBinding
public void CheckChannelBinding(ChannelBinding channelBinding)
{
if (channelBinding != null)
{
Assert.True(!channelBinding.IsInvalid, "Channel binding token should be marked as a valid SafeHandle.");
Assert.True(channelBinding.Size > 0, "Number of bytes in a valid channel binding token should be greater than zero.");
var bytes = new byte[channelBinding.Size];
Marshal.Copy(channelBinding.DangerousGetHandle(), bytes, 0, channelBinding.Size);
Assert.Equal(channelBinding.Size, bytes.Length);
}
}
示例11: ValidateCreateContext
internal void ValidateCreateContext(
string package,
bool isServer,
NetworkCredential credential,
string servicePrincipalName,
ChannelBinding channelBinding,
ProtectionLevel protectionLevel,
TokenImpersonationLevel impersonationLevel
)
{
throw new PlatformNotSupportedException();
}
示例12: ChannelBindingMessageProperty
public ChannelBindingMessageProperty(ChannelBinding channelBinding, bool ownsCleanup)
{
if (channelBinding == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("channelBinding");
}
_refCount = 1;
_thisLock = new object();
_channelBinding = channelBinding;
_ownsCleanup = ownsCleanup;
}
示例13: ExtendedProtectionPolicy
public ExtendedProtectionPolicy(PolicyEnforcement policyEnforcement,
ChannelBinding customChannelBinding)
{
if (policyEnforcement == PolicyEnforcement.Never)
{
throw new ArgumentException(SR.GetString(SR.security_ExtendedProtectionPolicy_UseDifferentConstructorForNever), "policyEnforcement");
}
if (customChannelBinding == null)
{
throw new ArgumentNullException("customChannelBinding");
}
this.policyEnforcement = policyEnforcement;
this.protectionScenario = ProtectionScenario.TransportSelected;
this.customChannelBinding = customChannelBinding;
}
示例14: ExtendedProtectionPolicyHelper
public ExtendedProtectionPolicyHelper(System.Security.Authentication.ExtendedProtection.ChannelBinding channelBinding, ExtendedProtectionPolicy extendedProtectionPolicy)
{
this._channelBinding = channelBinding;
this._serviceNameCollection = null;
this._checkServiceBinding = true;
if (extendedProtectionPolicy != null)
{
this._policyEnforcement = extendedProtectionPolicy.PolicyEnforcement;
this._protectionScenario = extendedProtectionPolicy.ProtectionScenario;
this._serviceNameCollection = extendedProtectionPolicy.CustomServiceNames;
}
if (this._policyEnforcement == System.Security.Authentication.ExtendedProtection.PolicyEnforcement.Never)
{
this._checkServiceBinding = false;
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:16,代码来源:ExtendedProtectionPolicyHelper.cs
示例15: ExtendedProtectionPolicy
public ExtendedProtectionPolicy(PolicyEnforcement policyEnforcement,
ChannelBinding customChannelBinding)
{
if (policyEnforcement == PolicyEnforcement.Never)
{
throw new ArgumentException(SR.security_ExtendedProtectionPolicy_UseDifferentConstructorForNever, nameof(policyEnforcement));
}
if (customChannelBinding == null)
{
throw new ArgumentNullException(nameof(customChannelBinding));
}
_policyEnforcement = policyEnforcement;
_protectionScenario = ProtectionScenario.TransportSelected;
_customChannelBinding = customChannelBinding;
}