Ejemplo n.º 1
0
        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);
        }
        private static bool TryCreateSecurity(SecurityBindingElement sbe, RelayClientAuthenticationType relayClientAuthenticationType, Microsoft.ServiceBus.UnifiedSecurityMode mode, out NetOnewayRelaySecurity security)
        {
            if (sbe == null)
            {
                mode = mode & (Microsoft.ServiceBus.UnifiedSecurityMode.None | Microsoft.ServiceBus.UnifiedSecurityMode.Transport | Microsoft.ServiceBus.UnifiedSecurityMode.TransportWithMessageCredential);
            }
            else
            {
                mode = mode & (Microsoft.ServiceBus.UnifiedSecurityMode.Message | Microsoft.ServiceBus.UnifiedSecurityMode.Both);
            }
            EndToEndSecurityMode relaySecurityMode = EndToEndSecurityModeHelper.ToRelaySecurityMode(mode);
            bool        flag             = EndToEndSecurityModeHelper.IsDefined(relaySecurityMode);
            CultureInfo invariantCulture = CultureInfo.InvariantCulture;

            object[] str = new object[] { relaySecurityMode.ToString() };
            Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.DebugAssert(flag, string.Format(invariantCulture, "Invalid RelaySecurityMode value: {0}.", str));
            if (NetOnewayRelaySecurity.TryCreate(sbe, relaySecurityMode, relayClientAuthenticationType, out security))
            {
                return(true);
            }
            return(false);
        }