internal static bool TryCreate(SecurityBindingElement sbe, out MessageSecurityOverRelayOneway messageSecurity) { MessageCredentialType messageCredentialType; IssuedSecurityTokenParameters issuedSecurityTokenParameter; messageSecurity = null; if (sbe == null) { return(false); } SymmetricSecurityBindingElement symmetricSecurityBindingElement = sbe as SymmetricSecurityBindingElement; if (symmetricSecurityBindingElement == null) { return(false); } if (sbe.MessageSecurityVersion != MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10 && sbe.MessageSecurityVersion != MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11) { return(false); } if (symmetricSecurityBindingElement.IncludeTimestamp) { return(false); } if (SecurityUtil.SecurityBindingElement.IsAnonymousForCertificateBinding(sbe)) { messageCredentialType = MessageCredentialType.None; } else if (SecurityUtil.SecurityBindingElement.IsUserNameForCertificateBinding(sbe)) { messageCredentialType = MessageCredentialType.UserName; } else if (!SecurityUtil.SecurityBindingElement.IsMutualCertificateBinding(sbe)) { if (!SecurityUtil.SecurityBindingElement.IsIssuedTokenForCertificateBinding(sbe, out issuedSecurityTokenParameter)) { return(false); } if (!SecurityUtil.IssuedSecurityTokenParameters.IsInfoCardParameters(issuedSecurityTokenParameter)) { return(false); } messageCredentialType = MessageCredentialType.IssuedToken; } else { messageCredentialType = MessageCredentialType.Certificate; } messageSecurity = new MessageSecurityOverRelayOneway() { ClientCredentialType = messageCredentialType }; if (messageCredentialType != MessageCredentialType.IssuedToken) { messageSecurity.AlgorithmSuite = symmetricSecurityBindingElement.DefaultAlgorithmSuite; } return(true); }
private NetOnewayRelaySecurity(EndToEndSecurityMode mode, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, RelayedOnewayTransportSecurity transportSecurity, MessageSecurityOverRelayOneway messageSecurity) { bool flag = EndToEndSecurityModeHelper.IsDefined(mode); CultureInfo invariantCulture = CultureInfo.InvariantCulture; object[] str = new object[] { mode.ToString() }; DiagnosticUtility.DebugAssert(flag, string.Format(invariantCulture, "Invalid RelaySecurityMode value: {0}.", str)); this.mode = mode; this.relayClientAuthenticationType = relayClientAuthenticationType; this.transportSecurity = (transportSecurity == null ? new RelayedOnewayTransportSecurity() : transportSecurity); this.messageSecurity = (messageSecurity == null ? new MessageSecurityOverRelayOneway() : messageSecurity); }
internal static bool TryCreate(SecurityBindingElement sbe, EndToEndSecurityMode mode, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, out NetOnewayRelaySecurity security) { MessageSecurityOverRelayOneway messageSecurityOverRelayOneway; security = null; if (!MessageSecurityOverRelayOneway.TryCreate(sbe, out messageSecurityOverRelayOneway)) { messageSecurityOverRelayOneway = null; } security = new NetOnewayRelaySecurity(mode, relayClientAuthenticationType, null, messageSecurityOverRelayOneway); if (sbe == null) { return(true); } Type type = typeof(SecurityElementBase); object[] objArray = new object[] { security.CreateMessageSecurity(), sbe, false }; return((bool)InvokeHelper.InvokeStaticMethod(type, "AreBindingsMatching", objArray)); }