Example #1
0
 private SecurityBindingElement CreateMessageSecurity()
 {
     if (_security.Mode == SecurityMode.Message)
     {
         throw ExceptionHelper.PlatformNotSupported(nameof(SecurityMode.Message));
     }
     if (_security.Mode == SecurityMode.TransportWithMessageCredential)
     {
         return(_security.CreateMessageSecurity(ReliableSession.Enabled));
     }
     else
     {
         return(null);
     }
 }
Example #2
0
        internal static bool TryCreate(SecurityBindingElement wsSecurity, SecurityMode mode, bool isReliableSessionEnabled, BindingElement transportSecurity, TcpTransportSecurity tcpTransportSecurity, out NetTcpSecurity security)
        {
            security = null;
            MessageSecurityOverTcp messageSecurity = null;

            if (mode == SecurityMode.Message)
            {
                if (!MessageSecurityOverTcp.TryCreate(wsSecurity, isReliableSessionEnabled, null, out messageSecurity))
                {
                    return(false);
                }
            }
            else if ((mode == SecurityMode.TransportWithMessageCredential) && !MessageSecurityOverTcp.TryCreate(wsSecurity, isReliableSessionEnabled, transportSecurity, out messageSecurity))
            {
                return(false);
            }
            security = new NetTcpSecurity(mode, tcpTransportSecurity, messageSecurity);
            return(SecurityElementBase.AreBindingsMatching(security.CreateMessageSecurity(isReliableSessionEnabled), wsSecurity, false));
        }
 internal static bool TryCreate(SecurityBindingElement wsSecurity, SecurityMode mode, bool isReliableSessionEnabled, BindingElement transportSecurity, TcpTransportSecurity tcpTransportSecurity, out NetTcpSecurity security)
 {
     security = null;
     MessageSecurityOverTcp messageSecurity = null;
     if (mode == SecurityMode.Message)
     {
         if (!MessageSecurityOverTcp.TryCreate(wsSecurity, isReliableSessionEnabled, null, out messageSecurity))
             return false;
     }
     else if (mode == SecurityMode.TransportWithMessageCredential)
     {
         if (!MessageSecurityOverTcp.TryCreate(wsSecurity, isReliableSessionEnabled, transportSecurity, out messageSecurity))
             return false;
     }
     security = new NetTcpSecurity(mode, tcpTransportSecurity, messageSecurity);
     return SecurityElement.AreBindingsMatching(security.CreateMessageSecurity(isReliableSessionEnabled), wsSecurity, false);
 }