Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ class PreDist extends DefaultTask {

String pluginLibraries = ''
project.fileTree(dir: "build/generated-dist/plugins/${groupName}", include: '**/*.jar').each { file ->
pluginLibraries += '\t\t<library name=\"' + file.absolutePath.replaceAll(~/.*build\/generated-dist\/plugins\/${groupName}\//, '') + '\"/>' + System.lineSeparator()
}
pluginLibraries += '\t\t<library name=\"' + file.absolutePath.replace(File.separator, '/').replaceAll(~/.*build\/generated-dist\/plugins\/${groupName}\//, '') + '\"/>' + System.lineSeparator()
}
project.copy {
from 'src/main/dist/template/plugins/${group}/plugin.xml'
filter { String line -> line.replace('<!-- START AUTO-GENERATED -->', '<!-- START AUTO-GENERATED -->' + System.lineSeparator() + System.lineSeparator() + pluginLibraries) }
Expand All @@ -284,7 +284,7 @@ class PreDist extends DefaultTask {

String descriptorFiles = ''
project.fileTree(dir: 'build/generated-dist').each { file ->
String relativePath = file.absolutePath.replaceAll(/.*build\/generated-dist\//, '')
String relativePath = file.absolutePath.replaceAll('\\\\', '/').replaceAll(/.*build\/generated-dist\//, '')
descriptorFiles += '\t\t<file from=\"' + relativePath + '\" to=\"' + relativePath + '\"/>' + System.lineSeparator()
}
project.copy {
Expand Down
170 changes: 170 additions & 0 deletions credchange.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/mms/MMSUtils.java b/src/main/java/gov/nasa/jpl/mbee/mdk/mms/MMSUtils.java
index d5be33fb..ed390d6d 100644
--- a/src/main/java/gov/nasa/jpl/mbee/mdk/mms/MMSUtils.java
+++ b/src/main/java/gov/nasa/jpl/mbee/mdk/mms/MMSUtils.java
@@ -35,17 +35,26 @@ import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.client.entity.EntityBuilder;
import org.apache.http.client.methods.*;
import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.FileEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
+import org.apache.http.ssl.SSLContexts;

+import javax.net.ssl.SSLContext;
import javax.swing.*;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -58,10 +67,11 @@ import java.util.concurrent.atomic.AtomicReference;

public class MMSUtils {

+ public static String serverTrustMethod = "DEFAULT"; //DEFAULT or WINDOWS
private static final int CHECK_CANCEL_DELAY = 100;
private static final AtomicReference<Exception> LAST_EXCEPTION = new AtomicReference<>();
private static final Cache<Project, String> PROFILE_SERVER_CACHE = CacheBuilder.newBuilder().weakKeys().maximumSize(100).expireAfterAccess(10, TimeUnit.MINUTES).build();
-
+
public enum HttpRequestType {
GET, POST, PUT, DELETE
}
@@ -350,6 +360,23 @@ public class MMSUtils {

return requestFile;
}
+
+ public static CloseableHttpClient createWindowsHttpClient() throws NoSuchAlgorithmException, CertificateException, IOException, KeyManagementException, UnrecoverableKeyException, KeyStoreException {
+ KeyStore keystoreWinRoot = KeyStore.getInstance("Windows-ROOT");
+ KeyStore keystoreWinMy = KeyStore.getInstance("Windows-MY");
+ keystoreWinRoot.load(null,null);
+ keystoreWinMy.load(null,null);
+ SSLContext sslcontext = SSLContexts.custom()
+ .loadKeyMaterial(keystoreWinMy,null)
+ .loadTrustMaterial(keystoreWinRoot,null)
+ .build();
+ SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext);
+ CloseableHttpClient httpclient = HttpClients.custom()
+ .setSSLSocketFactory(sslsf)
+ .build();
+ return httpclient;
+ }
+

/**
* General purpose method for sending a constructed http request via http client. For streaming reasons, defaults to writing to a file.
@@ -376,19 +403,39 @@ public class MMSUtils {
// create client, execute request, parse response, store in thread safe buffer to return as string later
// client, response, and reader are all auto closed after block
if (progressStatus == null) {
- try (CloseableHttpClient httpclient = HttpClients.createDefault();
- CloseableHttpResponse response = httpclient.execute(request);
- InputStream inputStream = response.getEntity().getContent()) {
- responseCode.set(response.getStatusLine().getStatusCode());
- String responseSummary = "[INFO] MMS Response [" + request.getMethod() + "]: " + responseCode.get() + " " + request.getURI().toString();
- System.out.println(responseSummary);
- if (MDUtils.isDeveloperMode()) {
- Application.getInstance().getGUILog().log(responseSummary);
- }
- if (inputStream != null) {
- responseBody.set(generateMmsOutput(inputStream, responseFile));
- }
- }
+ if(serverTrustMethod.equals("WINDOWS")) {
+ try (CloseableHttpClient httpclient = createWindowsHttpClient();
+ CloseableHttpResponse response = httpclient.execute(request);
+ InputStream inputStream = response.getEntity().getContent()) {
+ responseCode.set(response.getStatusLine().getStatusCode());
+ String responseSummary = "[INFO] MMS Response [" + request.getMethod() + "]: " + responseCode.get() + " " + request.getURI().toString();
+ System.out.println(responseSummary);
+ if (MDUtils.isDeveloperMode()) {
+ Application.getInstance().getGUILog().log(responseSummary);
+ }
+ if (inputStream != null) {
+ responseBody.set(generateMmsOutput(inputStream, responseFile));
+ }
+ } catch (KeyManagementException | UnrecoverableKeyException | NoSuchAlgorithmException
+ | CertificateException | KeyStoreException e) {
+ e.printStackTrace();
+ }
+ }
+ else {
+ try (CloseableHttpClient httpclient = HttpClients.createDefault();
+ CloseableHttpResponse response = httpclient.execute(request);
+ InputStream inputStream = response.getEntity().getContent()) {
+ responseCode.set(response.getStatusLine().getStatusCode());
+ String responseSummary = "[INFO] MMS Response [" + request.getMethod() + "]: " + responseCode.get() + " " + request.getURI().toString();
+ System.out.println(responseSummary);
+ if (MDUtils.isDeveloperMode()) {
+ Application.getInstance().getGUILog().log(responseSummary);
+ }
+ if (inputStream != null) {
+ responseBody.set(generateMmsOutput(inputStream, responseFile));
+ }
+ }
+ }
}
else {
LAST_EXCEPTION.set(null);
diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/util/TicketUtils.java b/src/main/java/gov/nasa/jpl/mbee/mdk/util/TicketUtils.java
index da58dadb..70a0925d 100644
--- a/src/main/java/gov/nasa/jpl/mbee/mdk/util/TicketUtils.java
+++ b/src/main/java/gov/nasa/jpl/mbee/mdk/util/TicketUtils.java
@@ -108,19 +108,30 @@ public class TicketUtils {
*/
private static String getUserCredentialsDialog() {
JPanel userPanel = new JPanel();
- userPanel.setLayout(new GridLayout(2, 2));
+ userPanel.setLayout(new GridLayout(3, 2));

JLabel usernameLbl = new JLabel("Username:");
JLabel passwordLbl = new JLabel("Password:");

JTextField usernameFld = new JTextField();
JPasswordField passwordFld = new JPasswordField();
+
+ JRadioButton useDefault = new JRadioButton("Use Default Apache HttpClient Configuration");
+ JRadioButton useWindowsCredentials = new JRadioButton("Use Windows Credentials");
+ //TODO might want to add an option for the JRadio group to create a folder for the certificates
+
+ ButtonGroup credGroup = new ButtonGroup();
+ credGroup.add(useDefault);
+ credGroup.add(useWindowsCredentials);

userPanel.add(usernameLbl);
userPanel.add(usernameFld);
userPanel.add(passwordLbl);
userPanel.add(passwordFld);

+ userPanel.add(useDefault);
+ userPanel.add(useWindowsCredentials);
+
if (username != null) {
usernameFld.setText(username);
usernameFld.requestFocus();
@@ -132,6 +143,12 @@ public class TicketUtils {
"MMS Credentials", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
// isDisplayed = false;
if (response == JOptionPane.OK_OPTION) {
+ if(useWindowsCredentials.isSelected()) {
+ MMSUtils.serverTrustMethod = "WINDOWS";
+ }
+ else {
+ MMSUtils.serverTrustMethod = "DEFAULT";
+ }
username = usernameFld.getText();
String pass = new String(passwordFld.getPassword());
return pass;
Loading