本文整理汇总了C#中System.ServiceModel.Security.SecurityProtocolCorrelationState类的典型用法代码示例。如果您正苦于以下问题:C# SecurityProtocolCorrelationState类的具体用法?C# SecurityProtocolCorrelationState怎么用?C# SecurityProtocolCorrelationState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SecurityProtocolCorrelationState类属于System.ServiceModel.Security命名空间,在下文中一共展示了SecurityProtocolCorrelationState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginSecureOutgoingMessage
public override IAsyncResult BeginSecureOutgoingMessage(Message message, TimeSpan timeout, SecurityProtocolCorrelationState correlationState, AsyncCallback callback, object state)
{
if (message == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message");
}
this.CommunicationObject.ThrowIfClosedOrNotOpen();
string actor = string.Empty; // message.Version.Envelope.UltimateDestinationActor;
try
{
if (this.SecurityProtocolFactory.ActAsInitiator)
{
return this.BeginSecureOutgoingMessageAtInitiatorCore(message, actor, timeout, callback, state);
}
else
{
SecureOutgoingMessageAtResponder(ref message, actor);
return new CompletedAsyncResult<Message>(message, callback, state);
}
}
catch (Exception exception)
{
// Always immediately rethrow fatal exceptions.
if (Fx.IsFatal(exception)) throw;
base.OnSecureOutgoingMessageFailure(message);
throw;
}
}
示例2: EndSecureOutgoingMessage
public override void EndSecureOutgoingMessage(IAsyncResult result, out Message message, out SecurityProtocolCorrelationState newCorrelationState)
{
if (result == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("result");
}
newCorrelationState = null;
try
{
if (result is CompletedAsyncResult<Message>)
{
message = CompletedAsyncResult<Message>.End(result);
}
else
{
message = this.EndSecureOutgoingMessageAtInitiatorCore(result);
}
base.OnOutgoingMessageSecured(message);
}
catch (Exception exception)
{
if (Fx.IsFatal(exception))
{
throw;
}
base.OnSecureOutgoingMessageFailure(null);
throw;
}
}
示例3: BeginSecureOutgoingMessage
public override IAsyncResult BeginSecureOutgoingMessage(Message message, TimeSpan timeout, SecurityProtocolCorrelationState correlationState, AsyncCallback callback, object state)
{
IAsyncResult result;
if (message == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message");
}
base.CommunicationObject.ThrowIfClosedOrNotOpen();
string actor = string.Empty;
try
{
if (base.SecurityProtocolFactory.ActAsInitiator)
{
return this.BeginSecureOutgoingMessageAtInitiatorCore(message, actor, timeout, callback, state);
}
this.SecureOutgoingMessageAtResponder(ref message, actor);
result = new CompletedAsyncResult<Message>(message, callback, state);
}
catch (Exception exception)
{
if (Fx.IsFatal(exception))
{
throw;
}
base.OnSecureOutgoingMessageFailure(message);
throw;
}
return result;
}
示例4: SecureOutgoingMessageCore
protected override SecurityProtocolCorrelationState SecureOutgoingMessageCore(ref Message message, TimeSpan timeout, SecurityProtocolCorrelationState correlationState)
{
SecurityToken token;
SecurityToken token2;
SecurityTokenParameters parameters;
this.GetTokensForOutgoingMessages(out token, out token2, out parameters);
this.SetUpDelayedSecurityExecution(ref message, token, token2, parameters, correlationState);
return null;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:AcceptorSessionSymmetricMessageSecurityProtocol.cs
示例5: BeginSecureOutgoingMessageCore
protected override IAsyncResult BeginSecureOutgoingMessageCore(Message message, TimeSpan timeout, SecurityProtocolCorrelationState correlationState, AsyncCallback callback, object state)
{
SecurityToken token;
SecurityToken token2;
SecurityTokenParameters parameters;
this.GetTokensForOutgoingMessages(out token, out token2, out parameters);
this.SetUpDelayedSecurityExecution(ref message, token, token2, parameters, correlationState);
return new CompletedAsyncResult<Message>(message, callback, state);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:AcceptorSessionSymmetricMessageSecurityProtocol.cs
示例6: EndSecureOutgoingMessageCore
protected override void EndSecureOutgoingMessageCore(IAsyncResult result, out Message message, out SecurityProtocolCorrelationState newCorrelationState)
{
if (result is CompletedAsyncResult<Message, SecurityProtocolCorrelationState>)
{
message = CompletedAsyncResult<Message, SecurityProtocolCorrelationState>.End(result, out newCorrelationState);
}
else
{
message = MessageSecurityProtocol.GetOneTokenAndSetUpSecurityAsyncResult.End(result, out newCorrelationState);
}
}
示例7: BeginSecureOutgoingMessageCore
protected override IAsyncResult BeginSecureOutgoingMessageCore(Message message, TimeSpan timeout, SecurityProtocolCorrelationState correlationState, AsyncCallback callback, object state)
{
SecurityToken token;
SecurityToken token2;
SecurityToken token3;
SecurityTokenParameters parameters;
IList<SupportingTokenSpecification> list;
this.GetTokensForOutgoingMessages(out token, out token2, out token3, out parameters);
TimeoutHelper helper = new TimeoutHelper(timeout);
if (base.TryGetSupportingTokens(this.Factory, base.Target, base.Via, message, helper.RemainingTime(), false, out list))
{
SecurityProtocolCorrelationState state2 = this.CreateCorrelationStateIfRequired();
this.SetUpDelayedSecurityExecution(ref message, token, token2, token3, parameters, list, state2);
return new CompletedAsyncResult<Message, SecurityProtocolCorrelationState>(message, state2, callback, state);
}
return new SecureOutgoingMessageAsyncResult(message, this, token, token2, token3, parameters, helper.RemainingTime(), callback, state);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:InitiatorSessionSymmetricMessageSecurityProtocol.cs
示例8: BeginSecureOutgoingMessageCore
protected override IAsyncResult BeginSecureOutgoingMessageCore(Message message, TimeSpan timeout, SecurityProtocolCorrelationState correlationState, AsyncCallback callback, object state)
{
SecurityToken token;
SecurityTokenParameters parameters;
IList<SupportingTokenSpecification> list;
SecurityToken token2;
SecurityProtocolCorrelationState state2;
TimeoutHelper helper = new TimeoutHelper(timeout);
if (this.TryGetTokenSynchronouslyForOutgoingSecurity(message, correlationState, false, helper.RemainingTime(), out token, out parameters, out token2, out list, out state2))
{
this.SetUpDelayedSecurityExecution(ref message, token2, token, parameters, list, base.GetSignatureConfirmationCorrelationState(correlationState, state2));
return new CompletedAsyncResult<Message, SecurityProtocolCorrelationState>(message, state2, callback, state);
}
if (!this.Factory.ActAsInitiator)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("ProtocolMustBeInitiator", new object[] { base.GetType().ToString() })));
}
return new SecureOutgoingMessageAsyncResult(message, this, this.GetTokenProvider(), this.Factory.ApplyConfidentiality, this.initiatorTokenAuthenticator, correlationState, helper.RemainingTime(), callback, state);
}
示例9: BeginSecureOutgoingMessage
public override IAsyncResult BeginSecureOutgoingMessage(Message message, TimeSpan timeout, SecurityProtocolCorrelationState correlationState, AsyncCallback callback, object state)
{
IAsyncResult result;
try
{
base.CommunicationObject.ThrowIfClosedOrNotOpen();
this.ValidateOutgoingState(message);
if (!this.RequiresOutgoingSecurityProcessing && (message.Properties.Security == null))
{
return new CompletedAsyncResult<Message>(message, callback, state);
}
result = this.BeginSecureOutgoingMessageCore(message, timeout, correlationState, callback, state);
}
catch (Exception exception)
{
if (Fx.IsFatal(exception))
{
throw;
}
base.OnSecureOutgoingMessageFailure(message);
throw;
}
return result;
}
示例10: End
internal static Message End(IAsyncResult result, out SecurityProtocolCorrelationState newCorrelationState)
{
GetTwoTokensAndSetUpSecurityAsyncResult self = AsyncResult.End<GetTwoTokensAndSetUpSecurityAsyncResult>(result);
newCorrelationState = self.newCorrelationState;
return self.message;
}
示例11: GetSignatureConfirmationCorrelationState
internal SecurityProtocolCorrelationState GetSignatureConfirmationCorrelationState(SecurityProtocolCorrelationState oldCorrelationState, SecurityProtocolCorrelationState newCorrelationState)
{
if (this.factory.ActAsInitiator)
{
return newCorrelationState;
}
else
{
return oldCorrelationState;
}
}
示例12: SecureOutgoingMessageCore
protected abstract SecurityProtocolCorrelationState SecureOutgoingMessageCore(ref Message message, TimeSpan timeout, SecurityProtocolCorrelationState correlationState);
示例13: CheckSignatureConfirmation
protected void CheckSignatureConfirmation(ReceiveSecurityHeader securityHeader, SecurityProtocolCorrelationState[] correlationStates)
{
SignatureConfirmations receivedConfirmations = securityHeader.GetSentSignatureConfirmations();
SignatureConfirmations sentSignatures = null;
if (correlationStates != null)
{
for (int i = 0; i < correlationStates.Length; ++i)
{
if (correlationStates[i].SignatureConfirmations != null)
{
sentSignatures = correlationStates[i].SignatureConfirmations;
break;
}
}
}
if (sentSignatures == null)
{
if (receivedConfirmations != null && receivedConfirmations.Count > 0)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(SR.GetString(SR.FoundUnexpectedSignatureConfirmations)));
}
return;
}
bool allSignaturesConfirmed = false;
if (receivedConfirmations != null && sentSignatures.Count == receivedConfirmations.Count)
{
bool[] matchingSigIndexes = new bool[sentSignatures.Count];
for (int i = 0; i < sentSignatures.Count; ++i)
{
byte[] sentSignature;
bool wasSentSigEncrypted;
sentSignatures.GetConfirmation(i, out sentSignature, out wasSentSigEncrypted);
for (int j = 0; j < receivedConfirmations.Count; ++j)
{
byte[] receivedSignature;
bool wasReceivedSigEncrypted;
if (matchingSigIndexes[j])
{
continue;
}
receivedConfirmations.GetConfirmation(j, out receivedSignature, out wasReceivedSigEncrypted);
if ((wasReceivedSigEncrypted == wasSentSigEncrypted) && CryptoHelper.IsEqual(receivedSignature, sentSignature))
{
matchingSigIndexes[j] = true;
break;
}
}
}
int k;
for (k = 0; k < matchingSigIndexes.Length; ++k)
{
if (!matchingSigIndexes[k])
{
break;
}
}
if (k == matchingSigIndexes.Length)
{
allSignaturesConfirmed = true;
}
}
if (!allSignaturesConfirmed)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(SR.GetString(SR.NotAllSignaturesConfirmed)));
}
}
示例14: ConfigureReceiveSecurityHeader
protected ReceiveSecurityHeader ConfigureReceiveSecurityHeader(Message message, string actor, SecurityProtocolCorrelationState[] correlationStates, SecurityStandardsManager standardsManager, out IList<SupportingTokenAuthenticatorSpecification> supportingAuthenticators)
{
MessageSecurityProtocolFactory factory = this.MessageSecurityProtocolFactory;
MessageDirection direction = factory.ActAsInitiator ? MessageDirection.Output : MessageDirection.Input;
ReceiveSecurityHeader securityHeader = CreateSecurityHeader(message, actor, direction, standardsManager);
string action = message.Headers.Action;
supportingAuthenticators = GetSupportingTokenAuthenticatorsAndSetExpectationFlags(this.factory, message, securityHeader);
if (factory.RequireIntegrity || securityHeader.ExpectSignedTokens)
{
securityHeader.RequiredSignatureParts = factory.GetIncomingSignatureParts(action);
}
if (factory.RequireConfidentiality || securityHeader.ExpectBasicTokens)
{
securityHeader.RequiredEncryptionParts = factory.GetIncomingEncryptionParts(action);
}
securityHeader.ExpectEncryption = factory.RequireConfidentiality || securityHeader.ExpectBasicTokens;
securityHeader.ExpectSignature = factory.RequireIntegrity || securityHeader.ExpectSignedTokens;
securityHeader.SetRequiredProtectionOrder(factory.MessageProtectionOrder);
// On the receiving side if protectTokens is enabled
// 1. If we are service, we make sure that the client always signs the primary token( can be any token type)else we throw.
// But currently the service can sign the primary token in reply only if the primary token is an issued token
// 2. If we are client, we do not care if the service signs the primary token or not. Otherwise it will be impossible to have a wcf client /service talk to each other unless we
// either use a symmetric binding with issued tokens or asymmetric bindings with both the intiator and recipient parameters being issued tokens( later one is rare).
securityHeader.RequireSignedPrimaryToken = !factory.ActAsInitiator && factory.SecurityBindingElement.ProtectTokens;
if (factory.ActAsInitiator && factory.DoRequestSignatureConfirmation && HasCorrelationState(correlationStates))
{
securityHeader.MaintainSignatureConfirmationState = true;
securityHeader.ExpectSignatureConfirmation = true;
}
else if (!factory.ActAsInitiator && factory.DoRequestSignatureConfirmation)
{
securityHeader.MaintainSignatureConfirmationState = true;
}
else
{
securityHeader.MaintainSignatureConfirmationState = false;
}
return securityHeader;
}
示例15: HasCorrelationState
bool HasCorrelationState(SecurityProtocolCorrelationState[] correlationState)
{
if (correlationState == null || correlationState.Length == 0)
{
return false;
}
else if (correlationState.Length == 1 && correlationState[0] == null)
{
return false;
}
else
{
return true;
}
}