Beispiel #1
0
        public Message SerializeRequest(MessageVersion messageVersion, object[] parameters)
        {
            object[] parts = null;

            if (messageVersion == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("messageVersion");
            }

            if (parameters == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameters");
            }
            if (_requestDescription.IsTypedMessage)
            {
                TypedMessageParts typedMessageParts = new TypedMessageParts(parameters[0], _requestDescription);

                // copy values from the actual field/properties
                parts = new object[typedMessageParts.Count];
                typedMessageParts.GetTypedMessageParts(parts);
            }
            else
            {
                parts = parameters;
            }
            Message msg = new OperationFormatterMessage(this, messageVersion,
                                                        _action == null ? null : ActionHeader.Create(_action, messageVersion.Addressing),
                                                        parts, null, true /*isRequest*/);

            AddPropertiesToMessage(msg, _requestDescription, parts);
            AddHeadersToMessage(msg, _requestDescription, parts, true /*isRequest*/);

            return(msg);
        }
Beispiel #2
0
        private Message GetNextOutgoingMessage(Message incomingMessage, T negotiationState)
        {
            BodyWriter        firstOutgoingMessageBody;
            MessageProperties properties = null;
            Message           message;

            if (incomingMessage == null)
            {
                firstOutgoingMessageBody = this.GetFirstOutgoingMessageBody(negotiationState, out properties);
            }
            else
            {
                firstOutgoingMessageBody = this.GetNextOutgoingMessageBody(incomingMessage, negotiationState);
            }
            if (firstOutgoingMessageBody == null)
            {
                return(null);
            }
            if (incomingMessage == null)
            {
                message = Message.CreateMessage(this.MessageVersion, ActionHeader.Create(this.RequestSecurityTokenAction, this.MessageVersion.Addressing), firstOutgoingMessageBody);
            }
            else
            {
                message = Message.CreateMessage(this.MessageVersion, ActionHeader.Create(this.RequestSecurityTokenResponseAction, this.MessageVersion.Addressing), firstOutgoingMessageBody);
            }
            if (properties != null)
            {
                message.Properties.CopyProperties(properties);
            }
            this.PrepareRequest(message, firstOutgoingMessageBody as RequestSecurityToken);
            return(message);
        }
Beispiel #3
0
 private static Message CreateReply(Message request, XmlDictionaryString action, BodyWriter body)
 {
     if (request.Headers.MessageId != null)
     {
         Message message = Message.CreateMessage(request.Version, ActionHeader.Create(action, request.Version.Addressing), body);
         message.InitializeReply(request);
         return(message);
     }
     return(Message.CreateMessage(request.Version, ActionHeader.Create(action, request.Version.Addressing), body));
 }
        protected virtual Message CreateIssueRequest(EndpointAddress target, out object requestState)
        {
            this.CommunicationObject.ThrowIfClosedOrNotOpen();
            RequestSecurityToken rst = CreateRst(target, out requestState);

            rst.RequestType = this.StandardsManager.TrustDriver.RequestTypeIssue;
            rst.MakeReadOnly();
            Message result = Message.CreateMessage(this.MessageVersion, ActionHeader.Create(this.IssueAction, this.MessageVersion.Addressing), rst);

            PrepareRequest(result);
            return(result);
        }
Beispiel #5
0
 static Message CreateReply(Message request, XmlDictionaryString action, BodyWriter body)
 {
     if (request.Headers.MessageId != null)
     {
         Message reply = Message.CreateMessage(request.Version, ActionHeader.Create(action, request.Version.Addressing), body);
         reply.InitializeReply(request);
         return(reply);
     }
     else
     {
         // the message id may not be present if MapToHttp is true
         return(Message.CreateMessage(request.Version, ActionHeader.Create(action, request.Version.Addressing), body));
     }
 }
        protected virtual Message CreateRenewRequest(EndpointAddress target, SecurityToken currentSessionToken, out object requestState)
        {
            this.CommunicationObject.ThrowIfClosedOrNotOpen();
            RequestSecurityToken rst = CreateRst(target, out requestState);

            rst.RequestType = this.StandardsManager.TrustDriver.RequestTypeRenew;
            rst.RenewTarget = this.IssuedSecurityTokenParameters.CreateKeyIdentifierClause(currentSessionToken, SecurityTokenReferenceStyle.External);
            rst.MakeReadOnly();
            Message result = Message.CreateMessage(this.MessageVersion, ActionHeader.Create(this.RenewAction, this.MessageVersion.Addressing), rst);
            SecurityMessageProperty supportingTokenProperty = new SecurityMessageProperty();

            supportingTokenProperty.OutgoingSupportingTokens.Add(new SupportingTokenSpecification(currentSessionToken, EmptyReadOnlyCollection <IAuthorizationPolicy> .Instance, SecurityTokenAttachmentMode.Endorsing, this.IssuedSecurityTokenParameters));
            result.Properties.Security = supportingTokenProperty;
            PrepareRequest(result);
            return(result);
        }
Beispiel #7
0
        protected virtual Message CreateRenewRequest(EndpointAddress target, SecurityToken currentSessionToken, out object requestState)
        {
            base.CommunicationObject.ThrowIfClosedOrNotOpen();
            RequestSecurityToken body = this.CreateRst(target, out requestState);

            body.RequestType = this.StandardsManager.TrustDriver.RequestTypeRenew;
            body.RenewTarget = this.IssuedSecurityTokenParameters.CreateKeyIdentifierClause(currentSessionToken, SecurityTokenReferenceStyle.External);
            body.MakeReadOnly();
            Message message = Message.CreateMessage(this.MessageVersion, ActionHeader.Create(this.RenewAction, this.MessageVersion.Addressing), body);
            SecurityMessageProperty property = new SecurityMessageProperty {
                OutgoingSupportingTokens = { new SupportingTokenSpecification(currentSessionToken, System.ServiceModel.Security.EmptyReadOnlyCollection <IAuthorizationPolicy> .Instance, SecurityTokenAttachmentMode.Endorsing, this.IssuedSecurityTokenParameters) }
            };

            message.Properties.Security = property;
            this.PrepareRequest(message);
            return(message);
        }
Beispiel #8
0
        public Message SerializeReply(MessageVersion messageVersion, object[] parameters, object result)
        {
            object[] parts      = null;
            object   resultPart = null;

            if (messageVersion == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(messageVersion));
            }

            if (parameters == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(parameters));
            }

            if (replyDescription.IsTypedMessage)
            {
                // If the response is a typed message then it must
                // me the response (as opposed to an out param).  We will
                // serialize the response in the exact same way that we
                // would serialize a bunch of outs (with no return value).

                TypedMessageParts typedMessageParts = new TypedMessageParts(result, replyDescription);

                // make a copy of the list so that we have the actual values of the field/properties
                parts = new object[typedMessageParts.Count];
                typedMessageParts.GetTypedMessageParts(parts);

                resultPart = null;
            }
            else
            {
                parts      = parameters;
                resultPart = result;
            }

            Message msg = new OperationFormatterMessage(this, messageVersion,
                                                        replyAction == null ? null : ActionHeader.Create(replyAction, messageVersion.Addressing),
                                                        parts, resultPart, false /*isRequest*/);

            AddPropertiesToMessage(msg, replyDescription, parts);
            AddHeadersToMessage(msg, replyDescription, parts, false /*isRequest*/);
            return(msg);
        }
        private Message GetNextOutgoingMessage(Message incomingMessage, T negotiationState)
        {
            BodyWriter        nextMessageBody;
            MessageProperties nextMessageProperties = null;

            if (incomingMessage == null)
            {
                nextMessageBody = GetFirstOutgoingMessageBody(negotiationState, out nextMessageProperties);
            }
            else
            {
                nextMessageBody = GetNextOutgoingMessageBody(incomingMessage, negotiationState);
            }

            if (nextMessageBody != null)
            {
                Message nextMessage;
                if (incomingMessage == null)
                {
                    nextMessage = Message.CreateMessage(MessageVersion, ActionHeader.Create(RequestSecurityTokenAction, MessageVersion.Addressing), nextMessageBody);
                }
                else
                {
                    nextMessage = Message.CreateMessage(MessageVersion, ActionHeader.Create(RequestSecurityTokenResponseAction, MessageVersion.Addressing), nextMessageBody);
                }

                if (nextMessageProperties != null)
                {
                    nextMessage.Properties.CopyProperties(nextMessageProperties);
                }

                PrepareRequest(nextMessage, nextMessageBody as RequestSecurityToken);
                return(nextMessage);
            }
            else
            {
                return(null);
            }
        }
Beispiel #10
0
        public Message SerializeRequest(MessageVersion messageVersion, object[] parameters)
        {
            object[] values = null;
            if (messageVersion == null)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("messageVersion");
            }
            if (parameters == null)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameters");
            }
            if (this.requestDescription.IsTypedMessage)
            {
                TypedMessageParts parts = new TypedMessageParts(parameters[0], this.requestDescription);
                values = new object[parts.Count];
                parts.GetTypedMessageParts(values);
            }
            else
            {
                values = parameters;
            }
            Message message = new OperationFormatterMessage(this, messageVersion, (this.action == null) ? null : ActionHeader.Create(this.action, messageVersion.Addressing), values, null, true);

            this.AddPropertiesToMessage(message, this.requestDescription, values);
            this.AddHeadersToMessage(message, this.requestDescription, values, true);
            return(message);
        }