/// <summary> /// Start this service. /// </summary> protected override void OnStart(string[] args) { try { initializeCurrentDirectory(); Trace.TraceInformation("Starting connector server: "+Environment.CurrentDirectory); NameValueCollection settings = GetApplicationSettings(); String portStr = settings.Get(PROP_PORT); if ( portStr == null ) { throw new Org.IdentityConnectors.Framework.Common.Exceptions.ConfigurationException("Missing required configuration property: "+PROP_PORT); } String keyHash = settings.Get(PROP_KEY); if ( keyHash == null ) { throw new Org.IdentityConnectors.Framework.Common.Exceptions.ConfigurationException("Missing required configuration property: "+PROP_KEY); } int port = Int32.Parse(portStr); bool useSSL = Boolean.Parse(settings.Get(PROP_SSL)??"false"); _server = ConnectorServer.NewInstance(); _server.Port = port; _server.UseSSL = useSSL; _server.KeyHash = keyHash; if (useSSL) { _server.ServerCertificate = GetCertificate(); } String ifaddress = settings.Get(PROP_IFADDRESS); if ( ifaddress != null ) { _server.IfAddress = IOUtil.GetIPAddress(ifaddress); } _server.Start(); Trace.TraceInformation("Started connector server"); } catch (Exception e) { TraceUtil.TraceException("Exception occured starting connector server", e); throw; } }
protected override ConnectorInfoManager GetConnectorInfoManager() { TestUtil.InitializeLogging(); GuardedString str = new GuardedString(); str.AppendChar('c'); str.AppendChar('h'); str.AppendChar('a'); str.AppendChar('n'); str.AppendChar('g'); str.AppendChar('e'); str.AppendChar('i'); str.AppendChar('t'); #if DEBUG const int PORT = 58762; #else const int PORT = 58761; #endif /*X509Store store = new X509Store("TestCertificateStore", StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly|OpenFlags.OpenExistingOnly); X509Certificate certificate = store.Certificates[0]; store.Close();*/ X509Certificate2 certificate = new X509Certificate2(CERT_PATH, "changeit"); //Trace.TraceInformation("certificate: "+certificate); _server = ConnectorServer.NewInstance(); _server.Port = PORT; _server.KeyHash = str.GetBase64SHA1Hash(); _server.IfAddress = (IOUtil.GetIPAddress("localhost")); _server.UseSSL = true; _server.ServerCertificate = certificate; _server.Start(); //while ( true ) { // Thread.Sleep(1000); //} ConnectorInfoManagerFactory fact = ConnectorInfoManagerFactory.GetInstance(); MyCertificateValidationCallback callback = new MyCertificateValidationCallback(); RemoteFrameworkConnectionInfo connInfo = new RemoteFrameworkConnectionInfo("localhost", PORT, str, true, callback.Validate, 60000); ConnectorInfoManager manager = fact.GetRemoteManager(connInfo); return manager; }
protected override void ShutdownConnnectorInfoManager() { if (_server != null) { _server.Stop(); _server = null; } }
protected override ConnectorInfoManager GetConnectorInfoManager() { TestUtil.InitializeLogging(); GuardedString str = new GuardedString(); str.AppendChar('c'); str.AppendChar('h'); str.AppendChar('a'); str.AppendChar('n'); str.AppendChar('g'); str.AppendChar('e'); str.AppendChar('i'); str.AppendChar('t'); #if DEBUG const int PORT = 58758; #else const int PORT = 58759; #endif _server = ConnectorServer.NewInstance(); _server.Port = PORT; _server.IfAddress = (IOUtil.GetIPAddress("127.0.0.1")); _server.KeyHash = str.GetBase64SHA1Hash(); _server.Start(); //while ( true ) { // Thread.Sleep(1000); //} ConnectorInfoManagerFactory fact = ConnectorInfoManagerFactory.GetInstance(); RemoteFrameworkConnectionInfo connInfo = new RemoteFrameworkConnectionInfo("127.0.0.1", PORT, str); ConnectorInfoManager manager = fact.GetRemoteManager(connInfo); return manager; }