protected override Action Start(ClientAuthenticationValidator validator, EndpointAddress serviceAddress)
        {
            ServiceHost host = new ConnectorServiceHost(validator, serviceAddress.Uri);

            CustomBinding binding = new CustomBinding();
            binding.Elements.Add(new ByteStreamMessageEncodingBindingElement());

            HttpTransportBindingElement transport = new HttpTransportBindingElement
            {
                WebSocketSettings =
                {
                    TransportUsage = WebSocketTransportUsage.Always,
                    CreateNotificationOnConnection = true,
                    SubProtocol = "v1.openicf.forgerock.org"
                },
                Realm = "openicf",
                AuthenticationScheme = AuthenticationSchemes.Basic,
            };

            binding.Elements.Add(transport);
            host.AddServiceEndpoint(typeof (IWebSocketService), binding, "");

            host.Open();

            return () => { host.Close(); };
        }
        protected override void OnStart(string[] args)
        {
            try
            {
                ConnectorFramework connectorFramework = new ConnectorFramework();
                InitializeConnectors(connectorFramework.LocalManager);

                NameValueCollection settings = ConfigurationManager.AppSettings;

                String keyHash = settings.Get(PropKey);
                if (keyHash == null)
                {
                    throw new Org.IdentityConnectors.Framework.Common.Exceptions.ConfigurationException(
                        "Missing required configuration property: " + PropKey);
                }

                ClientAuthenticationValidator validator = new ClientAuthenticationValidator();
                validator.Add(new SingleTenantPrincipal(connectorFramework), keyHash);

                String facadeLifeTimeStr = settings.Get(PropFacadeLifetime);
                if (facadeLifeTimeStr != null)
                {
                    // _server.MaxFacadeLifeTime = Int32.Parse(facedeLifeTimeStr);
                }

                String disableWcf = settings.Get("disableWcf");
                OperatingSystem os = Environment.OSVersion;
                if (disableWcf == null && (os.Platform == PlatformID.Win32NT) &&
                    ((os.Version.Major > 6) || ((os.Version.Major == 6) && (os.Version.Minor >= 2))))
                {
                    ServiceHost host = new ConnectorServiceHost(validator);
                    host.Open();

                    _closeAction = () => host.Close();
                    Trace.TraceInformation("Started WCF connector server");
                }
                else
                {
                    Uri[] endpointUri = ExtractEndPoint();
                    if (endpointUri == null)
                    {
                        throw new Org.IdentityConnectors.Framework.Common.Exceptions.ConfigurationException(
                            "Missing required baseAddress");
                    }
                    VtortConnectorServiceHost host = new VtortConnectorServiceHost(validator, endpointUri);
                    host.Open();

                    _closeAction = () => host.Close();
                    Trace.TraceInformation("Started WebSocketListener connector server");
                }
            }
            catch (Exception e)
            {
                TraceUtil.TraceException("Exception occured starting connector server", e);
                throw;
            }
        }