Example #1
0
        private void AddSignatureReference(SendSecurityHeaderElement[] elements)
        {
            if (elements != null)
            {
                for (int i = 0; i < elements.Length; ++i)
                {
                    SecurityKeyIdentifierClause keyIdentifierClause = null;
                    TokenElement signedEncryptedTokenElement        = elements[i].Item as TokenElement;

                    // signedEncryptedTokenElement can either be a TokenElement ( in SignThenEncrypt case) or EncryptedData ( in !SignThenEncryptCase)
                    // STR-Transform does not make sense in !SignThenEncrypt case .
                    // note: signedEncryptedTokenElement can also be SignatureConfirmation but we do not care about it here.
                    bool useStrTransform = signedEncryptedTokenElement != null &&
                                           SignThenEncrypt &&
                                           ShouldUseStrTransformForToken(signedEncryptedTokenElement.Token,
                                                                         i,
                                                                         SecurityTokenAttachmentMode.SignedEncrypted,
                                                                         out keyIdentifierClause);

                    if (!useStrTransform && elements[i].Id == null)
                    {
                        throw TraceUtility.ThrowHelperError(new MessageSecurityException(SR.ElementToSignMustHaveId), Message);
                    }

                    MemoryStream        stream     = new MemoryStream();
                    XmlDictionaryWriter utf8Writer = TakeUtf8Writer();
                    utf8Writer.StartCanonicalization(stream, false, null);
                    elements[i].Item.WriteTo(utf8Writer, ServiceModelDictionaryManager.Instance);
                    utf8Writer.EndCanonicalization();
                    stream.Position = 0;
                    if (useStrTransform)
                    {
                        throw new PlatformNotSupportedException("StrTransform not supported yet");
                    }
                    else
                    {
                        AddReference("#" + elements[i].Id, stream);
                    }
                }
            }
        }
Example #2
0
        public override bool Equals(object item)
        {
            TokenElement element = item as TokenElement;

            return(element != null && this.token == element.token && this.standardsManager == element.standardsManager);
        }