本文整理汇总了C#中System.ServiceModel.Security.MessagePartSpecification类的典型用法代码示例。如果您正苦于以下问题:C# MessagePartSpecification类的具体用法?C# MessagePartSpecification怎么用?C# MessagePartSpecification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MessagePartSpecification类属于System.ServiceModel.Security命名空间,在下文中一共展示了MessagePartSpecification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddBindingParameters
/**
* The execution of this behavior comes rather late.
* Anyone that inspects the service description in the meantime,
* such as for metadata generation, won't see the protection level that we want to use.
*
* One way of doing it is at when create HostFactory
*
* ServiceEndpoint endpoint = host.Description.Endpoints.Find(typeof(IService));
* OperationDescription operation = endpoint.Contract.Operations.Find("Action");
* MessageDescription message = operation.Messages.Find("http://tempuri.org/IService/ActionResponse");
* MessageHeaderDescription header = message.Headers[new XmlQualifiedName("aheader", "http://tempuri.org/")];
* header.ProtectionLevel = ProtectionLevel.Sign;
*
* **/
public void AddBindingParameters(ContractDescription contractDescription, ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
{
ChannelProtectionRequirements requirements = bindingParameters.Find<ChannelProtectionRequirements>();
XmlQualifiedName qName = new XmlQualifiedName(header, ns);
MessagePartSpecification part = new MessagePartSpecification(qName);
requirements.OutgoingSignatureParts.AddParts(part, action);
}
示例2: AddParts
private void AddParts(ref MessagePartSpecification parts1, MessagePartSpecification parts2)
{
if (parts1 == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("parts1"));
}
if (parts2 == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("parts2"));
}
if (!parts2.IsEmpty())
{
if (parts1.IsReadOnly)
{
MessagePartSpecification specification = new MessagePartSpecification();
specification.Union(parts1);
specification.Union(parts2);
parts1 = specification;
}
else
{
parts1.Union(parts2);
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:SecurityBindingElementImporter.cs
示例3: AddParts
internal void AddParts(MessagePartSpecification parts, XmlDictionaryString action)
{
if (action == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("action"));
}
this.AddParts(parts, action.Value);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:ScopedMessagePartSpecification.cs
示例4: TryGetParts
public bool TryGetParts(string action, out MessagePartSpecification parts)
{
Contract.Ensures(Contract.Result<bool>() == (Contract.ValueAtReturn(out parts) != null));
parts = default(MessagePartSpecification);
return default(bool);
}
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:8,代码来源:System.ServiceModel.Security.ScopedMessagePartSpecification.cs
示例5: AddParts
public void AddParts (MessagePartSpecification parts)
{
if (parts == null)
throw new ArgumentNullException ("parts");
if (IsReadOnly)
throw new InvalidOperationException ("This ScopedMessagePartSpecification is read-only.");
ChannelParts.Union (parts);
}
示例6: UnionReadOnlyPart
public void UnionReadOnlyPart ()
{
MessagePartSpecification s =
new MessagePartSpecification ();
s.MakeReadOnly ();
Assert.AreEqual (true, s.IsReadOnly, "#1");
s.Union (new MessagePartSpecification ());
}
示例7: ScopedMessagePartSpecification
public ScopedMessagePartSpecification (
ScopedMessagePartSpecification other)
{
XmlQualifiedName [] array = new XmlQualifiedName [other.parts.HeaderTypes.Count];
other.parts.HeaderTypes.CopyTo (array, 0);
parts = new MessagePartSpecification (
other.parts.IsBodyIncluded, array);
table = new Dictionary<string,MessagePartSpecification> (other.table);
}
示例8: AddParts
public void AddParts(MessagePartSpecification parts)
{
if (parts == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("parts"));
ThrowIfReadOnly();
_channelParts.Union(parts);
}
示例9: DefaultValues
public void DefaultValues ()
{
MessagePartSpecification s =
new MessagePartSpecification ();
Assert.IsFalse (s.IsBodyIncluded, "#1");
Assert.AreEqual (0, s.HeaderTypes.Count, "#2");
s = new MessagePartSpecification (new XmlQualifiedName [] {new XmlQualifiedName ("foo", "urn:foo")});
Assert.IsFalse (s.IsBodyIncluded, "#3");
Assert.AreEqual (1, s.HeaderTypes.Count, "#4");
}
示例10: ScopedMessagePartSpecification
public ScopedMessagePartSpecification(ScopedMessagePartSpecification other)
: this()
{
if (other == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("other"));
_channelParts.Union(other._channelParts);
if (other._actionParts != null)
{
foreach (string action in other._actionParts.Keys)
{
MessagePartSpecification p = new MessagePartSpecification();
p.Union(other._actionParts[action]);
_actionParts[action] = p;
}
}
}
示例11: ScopedMessagePartSpecification
public ScopedMessagePartSpecification(ScopedMessagePartSpecification other) : this()
{
if (other == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("other"));
}
this.channelParts.Union(other.channelParts);
if (other.actionParts != null)
{
foreach (string str in other.actionParts.Keys)
{
MessagePartSpecification specification = new MessagePartSpecification();
specification.Union(other.actionParts[str]);
this.actionParts[str] = specification;
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:ScopedMessagePartSpecification.cs
示例12: Union
public void Union ()
{
XmlQualifiedName q1, q2, q3;
q1 = new XmlQualifiedName ("foo");
q2 = new XmlQualifiedName ("bar");
q3 = new XmlQualifiedName ("baz");
MessagePartSpecification p1 =
new MessagePartSpecification (false, new XmlQualifiedName [] {q1, q2});
MessagePartSpecification p2 =
new MessagePartSpecification (true, new XmlQualifiedName [] {q3, q2});
p1.Union (p2);
Assert.IsTrue (p1.IsBodyIncluded, "#1");
// Sigh. It does not exclude duplicates.
Assert.AreEqual (4, p1.HeaderTypes.Count, "#1-2");
Assert.IsTrue (p1.HeaderTypes.Contains (q1), "#2");
Assert.IsTrue (p1.HeaderTypes.Contains (q2), "#3");
Assert.IsTrue (p1.HeaderTypes.Contains (q3), "#4");
}
示例13: AddressingVersion
private AddressingVersion(string ns, XmlDictionaryString dictionaryNs, string toStringFormat, MessagePartSpecification signedMessageParts, string anonymous, XmlDictionaryString dictionaryAnonymous, string none, string faultAction, string defaultFaultAction)
{
this.ns = ns;
this.dictionaryNs = dictionaryNs;
this.toStringFormat = toStringFormat;
this.signedMessageParts = signedMessageParts;
this.anonymous = anonymous;
this.dictionaryAnonymous = dictionaryAnonymous;
if (anonymous != null)
{
this.anonymousUri = new Uri(anonymous);
}
if (none != null)
{
this.noneUri = new Uri(none);
}
this.faultAction = faultAction;
this.defaultFaultAction = defaultFaultAction;
}
示例14: AddBindingParameters
public void AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
{
var proReq =
bindingParameters.Remove<ChannelProtectionRequirements>();
proReq = new ChannelProtectionRequirements();
MessagePartSpecification unProtectedSpec = new MessagePartSpecification();
MessagePartSpecification protectedSpec = new MessagePartSpecification(true);
// I'm setting same protection level for all the actions.
// You could specify different protection level per action, if required.
// Also note, I haven't implemented any support for custom SOAP headers.
// However that can easily be added using the same mechansim.
switch (level)
{
case ProtectionLevel.None:
proReq.OutgoingSignatureParts.AddParts(unProtectedSpec, "*");
proReq.IncomingSignatureParts.AddParts(unProtectedSpec, "*");
proReq.OutgoingEncryptionParts.AddParts(unProtectedSpec, "*");
proReq.IncomingEncryptionParts.AddParts(unProtectedSpec, "*");
break;
case ProtectionLevel.Sign:
proReq.OutgoingSignatureParts.AddParts(protectedSpec, "*");
proReq.IncomingSignatureParts.AddParts(protectedSpec, "*");
proReq.OutgoingEncryptionParts.AddParts(unProtectedSpec, "*");
proReq.IncomingEncryptionParts.AddParts(unProtectedSpec, "*");
break;
case ProtectionLevel.EncryptAndSign:
proReq.OutgoingSignatureParts.AddParts(protectedSpec, "*");
proReq.IncomingSignatureParts.AddParts(protectedSpec, "*");
proReq.OutgoingEncryptionParts.AddParts(protectedSpec, "*");
proReq.IncomingEncryptionParts.AddParts(protectedSpec, "*");
break;
}
// Add our protection requirement for this endpoint into the binding params.
bindingParameters.Add(proReq);
}
示例15: GetChannelProtectionRequirements
internal static ChannelProtectionRequirements GetChannelProtectionRequirements(ProtectionLevel protectionLevel)
{
ChannelProtectionRequirements result;
if (protectionLevel == ProtectionLevel.EncryptAndSign)
{
if (encryptAndSignChannelProtectionRequirements == null)
{
MessagePartSpecification header = new MessagePartSpecification();
header.HeaderTypes.Add(new XmlQualifiedName(CallbackContextHeaderName, CallbackContextHeaderNamespace));
ChannelProtectionRequirements requirements = new ChannelProtectionRequirements();
requirements.IncomingSignatureParts.AddParts(header);
requirements.IncomingEncryptionParts.AddParts(header);
requirements.OutgoingSignatureParts.AddParts(header);
requirements.OutgoingEncryptionParts.AddParts(header);
requirements.MakeReadOnly();
encryptAndSignChannelProtectionRequirements = requirements;
}
result = encryptAndSignChannelProtectionRequirements;
}
else if (protectionLevel == ProtectionLevel.Sign)
{
if (signChannelProtectionRequirements == null)
{
MessagePartSpecification header = new MessagePartSpecification();
header.HeaderTypes.Add(new XmlQualifiedName(CallbackContextHeaderName, CallbackContextHeaderNamespace));
ChannelProtectionRequirements requirements = new ChannelProtectionRequirements();
requirements.IncomingSignatureParts.AddParts(header);
requirements.OutgoingSignatureParts.AddParts(header);
requirements.MakeReadOnly();
signChannelProtectionRequirements = requirements;
}
result = signChannelProtectionRequirements;
}
else
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("protectionLevel"));
}
return result;
}