public AuthServiceTracker(BundleContext context) throws InvalidSyntaxException { super(context, getAuthFilter(), null); // TODO: Filters are case sensitive, we should be too if (NoneAuthenticationService.AUTH_TYPE.equalsIgnoreCase(getAuthName())) { Dictionary<String, String> properties = new Hashtable<String, String>(); properties.put(ServerConstants.CONFIG_AUTH_NAME, getAuthName()); // TODO: shouldn't we always register the none-auth service? context.registerService( IAuthenticationService.class, new NoneAuthenticationService(), properties); } }
@SuppressWarnings({"rawtypes", "unchecked"}) @Override public IAuthenticationService addingService( ServiceReference<IAuthenticationService> reference) { if ("true".equals(reference.getProperty(PROP_CONFIGURED))) // $NON-NLS-1$ return null; IAuthenticationService authService = super.addingService(reference); // TODO need to read auth properties from InstanceScope preferences authService.configure(new Properties()); Dictionary dictionary = new Properties(); dictionary.put(PROP_CONFIGURED, "true"); // $NON-NLS-1$ if (getService() != null) { getService().setRegistered(false); } authService.setRegistered(true); context.registerService(IAuthenticationService.class.getName(), authService, dictionary); return authService; }
public void start(BundleContext context) throws Exception { singleton = this; bundleContext = context; packageAdminTracker = new ServiceTracker<PackageAdmin, PackageAdmin>(context, PackageAdmin.class.getName(), null); packageAdminTracker.open(); authServiceTracker = new AuthServiceTracker(context); authServiceTracker.open(); IEclipsePreferences preferences = DefaultScope.INSTANCE.getNode(ServerConstants.PREFERENCE_SCOPE); Boolean httpsEnabled = new Boolean(preferences.get(ConfigurationFormat.HTTPS_ENABLED, "false")); // $NON-NLS-1$ Dictionary<String, Object> properties = new Hashtable<String, Object>(); properties.put( JettyConstants.CONTEXT_SESSIONINACTIVEINTERVAL, new Integer(4 * 60 * 60)); // 4 hours // properties.put(JettyConstants.CONTEXT_PATH, "/cc"); if (httpsEnabled) { LogHelper.log( new Status(IStatus.INFO, PI_CONFIGURATOR, "Https is enabled", null)); // $NON-NLS-1$ properties.put(JettyConstants.HTTPS_ENABLED, true); properties.put( JettyConstants.HTTPS_PORT, new Integer( preferences.get( HTTPS_PORT, System.getProperty( "org.eclipse.equinox.http.jetty.https.port", "8443")))); //$NON-NLS-1$//$NON-NLS-2$ properties.put( JettyConstants.SSL_KEYSTORE, preferences.get(SSL_KEYSTORE, "keystore")); // $NON-NLS-1$ LogHelper.log( new Status( IStatus.INFO, PI_CONFIGURATOR, "Keystore absolute path is " + preferences.get(SSL_KEYSTORE, "keystore"))); // $NON-NLS-1$ //$NON-NLS-2$ properties.put( JettyConstants.SSL_PASSWORD, preferences.get(SSL_PASSWORD, "password")); // $NON-NLS-1$ properties.put( JettyConstants.SSL_KEYPASSWORD, preferences.get(SSL_KEYPASSWORD, "password")); // $NON-NLS-1$ properties.put( JettyConstants.SSL_PROTOCOL, preferences.get(SSL_PROTOCOL, "SSLv3")); // $NON-NLS-1$ String httpsHost = System.getProperty("org.eclipse.equinox.http.jetty.https.host"); // $NON-NLS-1$ if (httpsHost != null) { properties.put(JettyConstants.HTTPS_HOST, httpsHost); } } String port = null; if (!httpsEnabled) { properties.put(JettyConstants.HTTP_ENABLED, true); port = preferences.get( HTTP_PORT, System.getProperty( "org.eclipse.equinox.http.jetty.http.port", "8080")); // $NON-NLS-1$ //$NON-NLS-2$ properties.put(JettyConstants.HTTP_PORT, new Integer(port)); String httpHost = System.getProperty("org.eclipse.equinox.http.jetty.http.host"); // $NON-NLS-1$ if (httpHost != null) { properties.put(JettyConstants.HTTP_HOST, httpHost); } } // properties to help us filter orion content properties.put("other.info", "org.eclipse.orion"); // $NON-NLS-1$ //$NON-NLS-2$ try { JettyConfigurator.startServer("MasterJetty", properties); // $NON-NLS-1$ } catch (Exception e) { throw new Exception("Error starting Jetty on port: " + port, e); } }