public static void AddSupportingToken(Message message, RequestSecurityTokenResponse rstr)
 {
     GenericXmlSecurityToken token = rstr.GetIssuedToken(null, null, SecurityKeyEntropyMode.ServerEntropy, null, null, null);
     SecurityMessageProperty property = new SecurityMessageProperty();
     SupportingTokenSpecification item = new SupportingTokenSpecification(token, new List<IAuthorizationPolicy>().AsReadOnly(), SecurityTokenAttachmentMode.Endorsing, SecurityContextSecurityTokenParameters);
     property.OutgoingSupportingTokens.Add(item);
     message.Properties.Security = property;
     if (DebugTrace.Verbose)
     {
         DebugTrace.Trace(TraceLevel.Verbose, "Attached supporting token {0} to register message", rstr.Context);
     }
 }
        internal void AddMessageSupportingTokens(Message message, ref IList <SupportingTokenSpecification> supportingTokens)
        {
            SecurityMessageProperty security = message.Properties.Security;

            if ((security != null) && security.HasOutgoingSupportingTokens)
            {
                if (supportingTokens == null)
                {
                    supportingTokens = new Collection <SupportingTokenSpecification>();
                }
                for (int i = 0; i < security.OutgoingSupportingTokens.Count; i++)
                {
                    SupportingTokenSpecification item = security.OutgoingSupportingTokens[i];
                    if (item.SecurityTokenParameters == null)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(System.ServiceModel.SR.GetString("SenderSideSupportingTokensMustSpecifySecurityTokenParameters")));
                    }
                    supportingTokens.Add(item);
                }
            }
        }
Esempio n. 3
0
        internal void AddMessageSupportingTokens(Message message, ref IList <SupportingTokenSpecification> supportingTokens)
        {
            SecurityMessageProperty supportingTokensProperty = message.Properties.Security;

            if (supportingTokensProperty != null && supportingTokensProperty.HasOutgoingSupportingTokens)
            {
                if (supportingTokens == null)
                {
                    supportingTokens = new Collection <SupportingTokenSpecification>();
                }
                for (int i = 0; i < supportingTokensProperty.OutgoingSupportingTokens.Count; ++i)
                {
                    SupportingTokenSpecification spec = supportingTokensProperty.OutgoingSupportingTokens[i];
                    if (spec.SecurityTokenParameters == null)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(SR.GetString(SR.SenderSideSupportingTokensMustSpecifySecurityTokenParameters)));
                    }
                    supportingTokens.Add(spec);
                }
            }
        }