コード例 #1
0
        internal static bool TryCreate(SecurityBindingElement sbe, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, UnifiedSecurityMode mode, HttpRelayTransportSecurity transportSecurity, out BasicHttpRelaySecurity security)
        {
            bool flag;

            security = null;
            BasicHttpRelayMessageSecurity basicHttpRelayMessageSecurity = null;

            if (sbe == null)
            {
                mode = mode & (UnifiedSecurityMode.None | UnifiedSecurityMode.Transport | UnifiedSecurityMode.Both);
            }
            else
            {
                mode = mode & (UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential);
                if (!BasicHttpRelayMessageSecurity.TryCreate(sbe, out basicHttpRelayMessageSecurity, out flag))
                {
                    return(false);
                }
            }
            EndToEndBasicHttpSecurityMode endToEndBasicHttpSecurityMode = EndToEndBasicHttpSecurityModeHelper.ToEndToEndBasicHttpSecurityMode(mode);
            bool        flag1            = EndToEndBasicHttpSecurityModeHelper.IsDefined(endToEndBasicHttpSecurityMode);
            CultureInfo invariantCulture = CultureInfo.InvariantCulture;

            object[] str = new object[] { endToEndBasicHttpSecurityMode.ToString() };
            DiagnosticUtility.DebugAssert(flag1, string.Format(invariantCulture, "Invalid BasicHttpSecurityMode value: {0}.", str));
            security = new BasicHttpRelaySecurity(endToEndBasicHttpSecurityMode, relayClientAuthenticationType, transportSecurity, basicHttpRelayMessageSecurity);
            if (sbe == null)
            {
                return(true);
            }
            Type type = typeof(SecurityElementBase);

            object[] objArray = new object[] { security.CreateMessageSecurity(), sbe };
            return((bool)InvokeHelper.InvokeStaticMethod(type, "AreBindingsMatching", objArray));
        }
コード例 #2
0
        internal static bool TryCreate(SecurityBindingElement sbe, out BasicHttpRelayMessageSecurity security, out bool isSecureTransportMode)
        {
            BasicHttpMessageCredentialType basicHttpMessageCredentialType;

            Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.DebugAssert(null != sbe, string.Empty);
            security = null;
            isSecureTransportMode = false;
            if (!(bool)InvokeHelper.InvokeInstanceGet(sbe.GetType(), sbe, "DoNotEmitTrust"))
            {
                return(false);
            }
            Type type = sbe.GetType();

            object[] objArray = new object[] { false };
            if (!(bool)InvokeHelper.InvokeInstanceMethod(type, sbe, "IsSetKeyDerivation", objArray))
            {
                return(false);
            }
            if (sbe.SecurityHeaderLayout != SecurityHeaderLayout.Lax)
            {
                return(false);
            }
            if (sbe.MessageSecurityVersion != MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10)
            {
                return(false);
            }
            if (SecurityUtil.SecurityBindingElement.IsMutualCertificateBinding(sbe, true))
            {
                basicHttpMessageCredentialType = BasicHttpMessageCredentialType.Certificate;
            }
            else
            {
                isSecureTransportMode = true;
                if (!SecurityUtil.SecurityBindingElement.IsCertificateOverTransportBinding(sbe))
                {
                    if (!SecurityUtil.SecurityBindingElement.IsUserNameOverTransportBinding(sbe))
                    {
                        return(false);
                    }
                    basicHttpMessageCredentialType = BasicHttpMessageCredentialType.UserName;
                }
                else
                {
                    basicHttpMessageCredentialType = BasicHttpMessageCredentialType.Certificate;
                }
            }
            security = new BasicHttpRelayMessageSecurity()
            {
                ClientCredentialType = basicHttpMessageCredentialType,
                AlgorithmSuite       = sbe.DefaultAlgorithmSuite
            };
            return(true);
        }
コード例 #3
0
        private BasicHttpRelaySecurity(EndToEndBasicHttpSecurityMode mode, Microsoft.ServiceBus.RelayClientAuthenticationType relayClientAuthenticationType, HttpRelayTransportSecurity transportSecurity, BasicHttpRelayMessageSecurity messageSecurity)
        {
            bool        flag             = EndToEndBasicHttpSecurityModeHelper.IsDefined(mode);
            CultureInfo invariantCulture = CultureInfo.InvariantCulture;

            object[] str = new object[] { mode.ToString() };
            DiagnosticUtility.DebugAssert(flag, string.Format(invariantCulture, "Invalid BasicHttpSecurityMode value: {0}.", str));
            this.Mode = mode;
            this.RelayClientAuthenticationType = relayClientAuthenticationType;
            this.transportSecurity             = (transportSecurity == null ? new HttpRelayTransportSecurity() : transportSecurity);
            this.messageSecurity = (messageSecurity == null ? new BasicHttpRelayMessageSecurity() : messageSecurity);
        }