Esempio n. 1
0
        protected override bool ProcessRequest(MessageProcessingContext mrc)
        {
            DispatchRuntime dispatch_runtime = mrc.OperationContext.EndpointDispatcher.DispatchRuntime;

            // FIXME: I doubt this should be done at this "handler"
            // layer, especially considering about non-ServiceHost
            // use of SecurityBindingElement + listener.
            //
            // For example there is no way to handle it in duplex
            // dispatch callbacks.
            if (dispatch_runtime.ChannelDispatcher == null)
            {
                return(false);
            }

            Message negoResponce = null;
            // process WS-Trust based negotiation
            MessageSecurityBindingSupport support =
                dispatch_runtime.ChannelDispatcher.Listener.GetProperty <MessageSecurityBindingSupport> ();

            if (support != null && mrc.IncomingMessage.Headers.FindHeader("Security", Constants.WssNamespace) < 0)
            {
                CommunicationSecurityTokenAuthenticator nego =
                    support.TokenAuthenticator as CommunicationSecurityTokenAuthenticator;
                if (nego != null)
                {
                    negoResponce = nego.Communication.ProcessNegotiation(mrc.IncomingMessage);
                }
            }

            if (negoResponce == null)
            {
                return(false);
            }

            ReplyNegoResponse(mrc, negoResponce);
            return(true);
        }
		public MessageSecurityGenerator (Message msg, 
			MessageSecurityBindingSupport security)
		{
			this.msg = msg;
			this.security = security;
		}
		protected SecureMessageDecryptor (
			Message source, MessageSecurityBindingSupport security)
		{
			source_message = source;
			this.security = security;

			// FIXME: use proper max buffer
			buf = source.CreateBufferedCopy (int.MaxValue);

			doc = new XmlDocument ();
			doc.PreserveWhitespace = true;

			nsmgr = new XmlNamespaceManager (doc.NameTable);
			nsmgr.AddNamespace ("s", "http://www.w3.org/2003/05/soap-envelope");
			nsmgr.AddNamespace ("c", Constants.WsscNamespace);
			nsmgr.AddNamespace ("o", Constants.WssNamespace);
			nsmgr.AddNamespace ("e", EncryptedXml.XmlEncNamespaceUrl);
			nsmgr.AddNamespace ("u", Constants.WsuNamespace);
			nsmgr.AddNamespace ("dsig", SignedXml.XmlDsigNamespaceUrl);

		}