コード例 #1
0
ファイル: SecurityProtocol.cs プロジェクト: sq2907/CoreWCF
        protected void AddSupportingTokens(SendSecurityHeader securityHeader, IList <SupportingTokenSpecification> supportingTokens)
        {
            if (supportingTokens != null)
            {
                for (int i = 0; i < supportingTokens.Count; ++i)
                {
                    SecurityToken           token           = supportingTokens[i].SecurityToken;
                    SecurityTokenParameters tokenParameters = supportingTokens[i].SecurityTokenParameters;
                    switch (supportingTokens[i].SecurityTokenAttachmentMode)
                    {
                    case SecurityTokenAttachmentMode.Signed:
                        securityHeader.AddSignedSupportingToken(token, tokenParameters);
                        break;

                    case SecurityTokenAttachmentMode.Endorsing:
                        securityHeader.AddEndorsingSupportingToken(token, tokenParameters);
                        break;

                    case SecurityTokenAttachmentMode.SignedEncrypted:
                        securityHeader.AddBasicSupportingToken(token, tokenParameters);
                        break;

                    case SecurityTokenAttachmentMode.SignedEndorsing:
                        securityHeader.AddSignedEndorsingSupportingToken(token, tokenParameters);
                        break;

                    default:
                        Fx.Assert("Unknown token attachment mode " + supportingTokens[i].SecurityTokenAttachmentMode.ToString());
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.UnknownTokenAttachmentMode, supportingTokens[i].SecurityTokenAttachmentMode.ToString())));
                    }
                }
            }
        }
コード例 #2
0
 protected virtual Message SecureOutgoingMessageAtResponder(Message message, string actor)
 {
     if (SecurityProtocolFactory.AddTimestamp && !SecurityProtocolFactory.SecurityBindingElement.EnableUnsecuredResponse)
     {
         SendSecurityHeader securityHeader = CreateSendSecurityHeaderForTransportProtocol(message, actor, SecurityProtocolFactory);
         message = securityHeader.SetupExecution();
     }
     return(message);
 }
コード例 #3
0
ファイル: SecurityProtocol.cs プロジェクト: sq2907/CoreWCF
        //public virtual async Task OnCloseAsync(CancellationToken token)
        //{
        //    if (SecurityProtocolFactory.ActAsInitiator)
        //    {
        //        /*
        //        TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);
        //        foreach (SupportingTokenProviderSpecification spec in ChannelSupportingTokenProviderSpecification)
        //        {
        //            await SecurityUtils.CloseTokenProviderIfRequiredAsync(spec.TokenProvider, timeoutHelper.RemainingTime());
        //        }

        //        foreach (string action in ScopedSupportingTokenProviderSpecification.Keys)
        //        {
        //            ICollection<SupportingTokenProviderSpecification> supportingProviders = ScopedSupportingTokenProviderSpecification[action];
        //            foreach (SupportingTokenProviderSpecification spec in supportingProviders)
        //            {
        //                await SecurityUtils.CloseTokenProviderIfRequiredAsync(spec.TokenProvider, timeoutHelper.RemainingTime());
        //            }
        //        }*/
        //    }
        //}

        private static void SetSecurityHeaderId(SendSecurityHeader securityHeader, Message message)
        {
            SecurityMessageProperty messageProperty = message.Properties.Security;

            if (messageProperty != null)
            {
                securityHeader.IdPrefix = messageProperty.SenderIdPrefix;
            }
        }
コード例 #4
0
ファイル: SecurityProtocol.cs プロジェクト: sq2907/CoreWCF
        private SendSecurityHeader CreateSendSecurityHeader(Message message, string actor, SecurityProtocolFactory factory, bool requireMessageProtection)
        {
            MessageDirection   transferDirection  = factory.ActAsInitiator ? MessageDirection.Input : MessageDirection.Output;
            SendSecurityHeader sendSecurityHeader = factory.StandardsManager.CreateSendSecurityHeader(
                message,
                actor, true, false,
                factory.OutgoingAlgorithmSuite, transferDirection);

            sendSecurityHeader.Layout = factory.SecurityHeaderLayout;
            sendSecurityHeader.RequireMessageProtection = requireMessageProtection;
            SetSecurityHeaderId(sendSecurityHeader, message);
            if (factory.AddTimestamp)
            {
                sendSecurityHeader.AddTimestamp(factory.TimestampValidityDuration);
            }

            sendSecurityHeader.StreamBufferManager = factory.StreamBufferManager;
            return(sendSecurityHeader);
        }