Skip to content

Commit

Permalink
-RMI SSL
Browse files Browse the repository at this point in the history
-Fixed ontology category tree bug
  • Loading branch information
jsmethie committed Jul 23, 2015
1 parent 9376b38 commit bc1b0ba
Show file tree
Hide file tree
Showing 11 changed files with 485 additions and 457 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

import com.runwaysdk.geodashboard.oda.driver.ui.ssl.SecureKeystoreManager;

public class GeodashboardPlugin extends AbstractUIPlugin
{
// The plug-in ID
Expand All @@ -47,21 +49,30 @@ public GeodashboardPlugin()

try
{
resourceBundle = ResourceBundle.getBundle("com.runwaysdk.geodashboard.oda.driver.ui.nls.GeodashboardPluginResources");
resourceBundle = ResourceBundle.getBundle("com.runwaysdk.geodashboard.oda.driver.ui.nls.GeodashboardPluginResources"); //$NON-NLS-1$
}
catch (MissingResourceException x)
{
resourceBundle = null;
}
}

@Override
public void start(BundleContext context) throws Exception
{
super.start(context);

/*
* Before a connection can be attempted we must ensure that the SSLContext has been configured
*/
SecureKeystoreManager.getInstance().configureSSLContext();
}

/**
* This method is called when the plug-in is stopped
*/
public void stop(BundleContext context) throws Exception
{
// ConnectionMetaDataManager.getInstance().clearCache();

super.stop(context);
}

Expand All @@ -82,8 +93,7 @@ public static GeodashboardPlugin getDefault()
}

/**
* Returns the string from the plugin's resource bundle, or 'key' if not
* found.
* Returns the string from the plugin's resource bundle, or 'key' if not found.
*/
public static String getResourceString(String key)
{
Expand All @@ -100,8 +110,7 @@ public static String getResourceString(String key)
}

/**
* Returns the string from the Resource bundle, formatted according to the
* arguments specified
* Returns the string from the Resource bundle, formatted according to the arguments specified
*/
public static String getFormattedString(String key, Object[] arguments)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import org.eclipse.datatools.connectivity.internal.ui.dialogs.ExceptionHandler;
import org.eclipse.datatools.connectivity.oda.IConnection;
import org.eclipse.datatools.connectivity.oda.IDriver;
import org.eclipse.datatools.connectivity.oda.IParameterMetaData;
import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
import org.eclipse.datatools.connectivity.oda.OdaException;
Expand Down Expand Up @@ -50,12 +49,12 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import com.runwaysdk.geodashboard.oda.driver.Driver;
import com.runwaysdk.geodashboard.oda.driver.ui.GeodashboardPlugin;
import com.runwaysdk.geodashboard.oda.driver.ui.provider.ConnectionException;
import com.runwaysdk.geodashboard.oda.driver.ui.provider.GeodashboardMetaDataProvider;
import com.runwaysdk.geodashboard.oda.driver.ui.provider.LabelValuePair;
import com.runwaysdk.geodashboard.oda.driver.ui.provider.QueryFacadeUtil;
import com.runwaysdk.geodashboard.oda.driver.ui.util.DriverLoader;

/**
* The Geodashborad DatasetEditor page which enable user to browse the catalog of the selected data source. The page
Expand Down Expand Up @@ -139,6 +138,10 @@ private void initializeControl(DataSetDesign dataSetDesign)
@Override
protected boolean canLeave()
{
/*
* Page might not be initialized if the user is looking at a different page of the dataset editor. In this case just
* assume the user can leave the page.
*/
if (this.initialized)
{
if (this.aggregationCombo.getControl().getEnabled())
Expand All @@ -149,7 +152,7 @@ protected boolean canLeave()
return ( this.getQueryId() != null && this.getDefaultGeoId() != null );
}

return false;
return true;
}

/**
Expand Down Expand Up @@ -354,13 +357,11 @@ private void savePage(DataSetDesign dataSetDesign)

try
{
// instantiate your custom ODA runtime driver class
IDriver driver = new Driver();

// obtain and open a live connection
Properties props = DesignSessionUtil.getEffectiveDataSourceProperties(getInitializationDesign().getDataSourceDesign());
connection = driver.getConnection(null);
connection.open(props);

// instantiate your custom ODA runtime driver class
connection = DriverLoader.getConnection(props);

// update the data set design with the
// query's current runtime metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ public Composite createCustomControl(Composite parent)

createPropertiesComposite(content);

sshButton = new Button(content, SWT.PUSH);
sshButton.setText(GeodashboardPlugin.getResourceString("wizard.label.configureSSH"));//$NON-NLS-1$
sshButton.setLayoutData(new GridData(GridData.CENTER));

testButton = new Button(content, SWT.PUSH);
testButton.setText(GeodashboardPlugin.getResourceString("wizard.label.testConnection"));//$NON-NLS-1$
testButton.setLayoutData(new GridData(GridData.END));
testButton.setLayoutData(new GridData(GridData.CENTER));

// sshButton = new Button(content, SWT.PUSH);
// sshButton.setText(GeodashboardPlugin.getResourceString("wizard.label.configureSSH"));//$NON-NLS-1$
// sshButton.setLayoutData(new GridData(GridData.END));
// sshButton.setVisible(false);

Point size = content.computeSize(SWT.DEFAULT, SWT.DEFAULT);
content.setSize(size.x, size.y);
Expand Down Expand Up @@ -358,14 +359,14 @@ public void widgetSelected(SelectionEvent evt)

});

sshButton.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent evt)
{
handleSSHButtonSelection();
}

});
// sshButton.addSelectionListener(new SelectionAdapter()
// {
// public void widgetSelected(SelectionEvent evt)
// {
// handleSSHButtonSelection();
// }
//
// });
}

private Properties collectSpecifiedProperties()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@
import java.util.logging.Logger;

import org.eclipse.datatools.connectivity.oda.IConnection;
import org.eclipse.datatools.connectivity.oda.IDriver;
import org.eclipse.datatools.connectivity.oda.IQuery;
import org.eclipse.datatools.connectivity.oda.IResultSet;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.datatools.connectivity.oda.design.DataSetDesign;
import org.eclipse.datatools.connectivity.oda.design.ui.designsession.DesignSessionUtil;

import com.runwaysdk.geodashboard.oda.driver.Driver;
import com.runwaysdk.geodashboard.oda.driver.ui.util.DriverLoader;

public class GeodashboardMetaDataProvider
{
Expand Down Expand Up @@ -127,13 +126,10 @@ private synchronized IConnection getConnection() throws OdaException
{
if (this.connection == null)
{
IDriver driver = new Driver();

// obtain and open a live connection
Properties props = DesignSessionUtil.getEffectiveDataSourceProperties(this.design.getDataSourceDesign());

this.connection = driver.getConnection(null);
this.connection.open(props);
this.connection = DriverLoader.getConnection(props);
}

return this.connection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.Map;

import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.security.storage.ISecurePreferences;
Expand Down Expand Up @@ -78,13 +80,33 @@ public synchronized void configureSSLContext()
{
try
{
KeyStore ts = this.getKeystore();
TrustManager trm = new X509TrustManager()
{
public X509Certificate[] getAcceptedIssuers()
{
return null;
}

TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(ts);
public void checkClientTrusted(X509Certificate[] certs, String authType)
{

}

public void checkServerTrusted(X509Certificate[] certs, String authType)
{
}
};

// KeyStore ts = this.getKeystore();
//
// TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
// tmf.init(ts);

// SSLContext context = SSLContext.getInstance("SSL");
// context.init(new KeyManager[] {}, tmf.getTrustManagers(), new SecureRandom());

SSLContext context = SSLContext.getInstance("SSL");
context.init(new KeyManager[] {}, tmf.getTrustManagers(), new SecureRandom());
context.init(new KeyManager[] {}, new TrustManager[] { trm }, new SecureRandom());

SSLContextConfiguration.configure(context);

Expand All @@ -94,10 +116,10 @@ public synchronized void configureSSLContext()
{
throw new SSLContextException(e);
}
catch (KeyStoreException e)
{
throw new SSLContextException(e);
}
// catch (KeyStoreException e)
// {
// throw new SSLContextException(e);
// }
catch (KeyManagementException e)
{
throw new SSLContextException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.eclipse.datatools.connectivity.oda.OdaException;

import com.runwaysdk.geodashboard.oda.driver.Connection;
import com.runwaysdk.geodashboard.oda.driver.ui.ssl.SecureKeystoreManager;

public class DriverLoader
{
Expand All @@ -34,11 +33,6 @@ private DriverLoader()

public static Connection getConnection(Properties props) throws OdaException
{
/*
* Before a connection can be attempted we must ensure that the SSLContext has been configured
*/
SecureKeystoreManager.getInstance().configureSSLContext();

Connection connection = new Connection();
connection.open(props);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
import java.util.Locale;
import java.util.Map;

import javax.net.SocketFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;

import com.runwaysdk.ClientSession;
import com.runwaysdk.configuration.CommonsConfigurationResolver;
import com.runwaysdk.request.ClientRequestManager;
Expand Down
Loading

0 comments on commit bc1b0ba

Please sign in to comment.