diff --git a/software/nbia-download-manager/buildDMC.xml b/software/nbia-download-manager/buildDMC.xml
index f384e856..a63dd6f1 100755
--- a/software/nbia-download-manager/buildDMC.xml
+++ b/software/nbia-download-manager/buildDMC.xml
@@ -6,7 +6,6 @@ ant -f buildDMC.xml
Create a executable jar for Standalond Download Manager with Ant build script
-
@@ -23,11 +22,11 @@ ant -f buildDMC.xml
-
-
+
+
-
+
@@ -218,8 +217,81 @@ ant -f buildDMC.xml
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -242,7 +313,6 @@ ant -f buildDMC.xml
-
@@ -252,6 +322,6 @@ ant -f buildDMC.xml
-
+ -->
diff --git a/software/nbia-download-manager/ivy.xml b/software/nbia-download-manager/ivy.xml
index 208649b6..4d4b17cd 100644
--- a/software/nbia-download-manager/ivy.xml
+++ b/software/nbia-download-manager/ivy.xml
@@ -23,6 +23,13 @@ L-->
+
+
+
+
+
+
+
diff --git a/software/nbia-download-manager/packageSrc/StandaloneDMLicense.txt b/software/nbia-download-manager/packageSrc/StandaloneDMLicense.txt
new file mode 100644
index 00000000..f6f88f41
--- /dev/null
+++ b/software/nbia-download-manager/packageSrc/StandaloneDMLicense.txt
@@ -0,0 +1,11 @@
+Copyright 2022 NCI, Leidos, Ellumen
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/software/nbia-download-manager/resources/Oauth2Client.config b/software/nbia-download-manager/resources/Oauth2Client.config
index 9a0502da..900fa4ef 100644
--- a/software/nbia-download-manager/resources/Oauth2Client.config
+++ b/software/nbia-download-manager/resources/Oauth2Client.config
@@ -1,7 +1,7 @@
#--------OAuth2.0 Client Configuration---------
-scope=
+scope=openid
grant_type=password
-client_id=
+client_id=nbia-stage
client_secret=
access_token=
#------------------------------------------------
diff --git a/software/nbia-download-manager/src/gov/nih/nci/nbia/StandaloneDMDispatcher.java b/software/nbia-download-manager/src/gov/nih/nci/nbia/StandaloneDMDispatcher.java
index 3c5179a4..a236c935 100644
--- a/software/nbia-download-manager/src/gov/nih/nci/nbia/StandaloneDMDispatcher.java
+++ b/software/nbia-download-manager/src/gov/nih/nci/nbia/StandaloneDMDispatcher.java
@@ -167,6 +167,9 @@ else if (os.toLowerCase().contains("linux"))
fileName = args[i + 1];
++i;
}
+ if (args[i].toLowerCase().equals("--agree-to-license")) {
+ dr.skipLicense = true;
+ }
if (args[i].equals("-u") || args[i].equals("-U")) {
userName = args[i + 1];
++i;
diff --git a/software/nbia-download-manager/src/gov/nih/nci/nbia/cli/DataRetrieverCLI.java b/software/nbia-download-manager/src/gov/nih/nci/nbia/cli/DataRetrieverCLI.java
index 00b853f4..20a0cae4 100644
--- a/software/nbia-download-manager/src/gov/nih/nci/nbia/cli/DataRetrieverCLI.java
+++ b/software/nbia-download-manager/src/gov/nih/nci/nbia/cli/DataRetrieverCLI.java
@@ -54,6 +54,9 @@
import java.util.logging.Handler;
import java.util.logging.Level;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import javax.swing.JOptionPane;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -115,6 +118,7 @@ public class DataRetrieverCLI {
public final java.util.logging.Logger logger = Logger.getGlobal();
private String setProperty;
private String duaText = null;
+ public boolean skipLicense = false;
/**
* @param args
*/
@@ -125,11 +129,14 @@ public static void main(String[] args) {
String downloadDir = null; // The directory that the user want to put the downloaded data
// BasicConfigurator.configure();
DataRetrieverCLI dr = new DataRetrieverCLI();
+ dr.skipLicense = false;
if (args != null && (args.length > 0)) {
for (int i = 0; i < args.length; ++i) {
if (args[i].equals("-c") || args[i].equals("-C") || args[i].equals("--cli") || args[i].equals("--CLI"))
fileName = args[i + 1];
+ if (args[i].toLowerCase().equals("--agree-to-license"))
+ dr.skipLicense = true;
if (args[i].equals("-u") || args[i].equals("-U"))
userName = args[i + 1];
if (args[i].equals("-p") || args[i].equals("-P"))
@@ -380,9 +387,11 @@ public void performDownload(String downloadDir, String fileName, String userName
// DataRetriever cmdDR = new DataRetriever();
loadManifestFile(fileName);
- String text = getUserAgreementTxt();
- if (text != null && !text.isEmpty()) {
- retrieveUsersAns(text);
+ if (!skipLicense) {
+ String text = getUserAgreementTxt();
+ if (text != null && !text.isEmpty()) {
+ retrieveUsersAns(text);
+ }
}
@@ -522,14 +531,19 @@ private String getAccessToken(String userName, String passWord) {
oauthDetails.setPassword(passWord);
oauthDetails.setAuthenticationServerUrl(
serverUrl.replaceFirst("nbia-download/servlet/DownloadServlet", "nbia-api/oauth/token"));
+
String accessToken = null;
if (oauthDetails.isAccessTokenRequest()) {
// Generate new Access token
// accessToken = OAuthUtils.getAccessToken(oauthDetails);
+//
+
+
Map map = oauthUtil.getAccessToken(oauthDetails);
refreshToken = map.get(OAuthConstants.REFRESH_TOKEN);
+
accessToken = map.get(OAuthConstants.ACCESS_TOKEN);
// System.out.println("accessToken=" + accessToken);
if (OAuthUtils.isValid(accessToken)) {
@@ -553,7 +567,7 @@ private String renewAccessToken() {
// Generate the OAuthDetails bean from the config properties file
OAuth2Details oauthDetails = oauthUtil.createOAuthDetails(config);
oauthDetails.setAuthenticationServerUrl(
- serverUrl.replaceFirst("nbia-download/servlet/DownloadServlet", "nbia-api/oauth/token"));
+ serverUrl.replaceFirst("nbia-download/servlet/DownloadServlet", "nbia-api/oauth/token/"));
newToken = oauthUtil.refreshAccessToken(oauthDetails, refreshToken);
logger.fine("get renewed access token =" + newToken);
return newToken;
@@ -668,7 +682,22 @@ else if(code == 204) {
output = br.readLine(); // data
if (output != null) {
- metaData = output.split(",");
+ List metaDataList = new ArrayList<>();
+ Pattern pattern = Pattern.compile("\"([^\"]*)\"|(?<=,|^)([^,]*)(?=,|$)");
+ Matcher matcher = pattern.matcher(output);
+
+ while (matcher.find()) {
+ if (matcher.group(1) != null) {
+ metaDataList.add(matcher.group(1));
+ } else {
+ metaDataList.add(matcher.group(2));
+ }
+ }
+
+ // Convert the List to a String array
+ metaData = metaDataList.toArray(new String[0]);
+
+ //metaData = output.split(",");
} else
logger.severe(
"Error in getting map for SOPClassName. Ask Admin to check if the server has the property file in place.");
diff --git a/software/nbia-download-manager/src/gov/nih/nci/nbia/cli/oauthClient/OAuthUtils.java b/software/nbia-download-manager/src/gov/nih/nci/nbia/cli/oauthClient/OAuthUtils.java
index 6a057807..5f52aab2 100644
--- a/software/nbia-download-manager/src/gov/nih/nci/nbia/cli/oauthClient/OAuthUtils.java
+++ b/software/nbia-download-manager/src/gov/nih/nci/nbia/cli/oauthClient/OAuthUtils.java
@@ -92,23 +92,35 @@ public Map getAccessToken(OAuth2Details oauthDetails) {
parametersBody.add(new BasicNameValuePair(OAuthConstants.CLIENT_SECRET, clientSecret));
+
if (isValid(scope)) {
parametersBody.add(new BasicNameValuePair(OAuthConstants.SCOPE, scope));
}
+ ArrayList parameters;
+
+ parameters = new ArrayList();
+ parameters.add(new BasicNameValuePair("grant_type", "password"));
+ parameters.add(new BasicNameValuePair("client_id", "clientId"));
+ parameters.add(new BasicNameValuePair("username", oauthDetails.getUsername()));
+ parameters.add(new BasicNameValuePair("password", oauthDetails.getPassword()));
+ parameters.add(new BasicNameValuePair("client_secret", clientSecret));
+ parameters.add(new BasicNameValuePair("scope", "openid"));
+
+
DefaultHttpClient client = new DefaultHttpClient();
HttpResponse response = null;
try {
post.addHeader("content-type", "application/x-www-form-urlencoded");
- StringEntity params = new StringEntity(
- "username=" + oauthDetails.getUsername() + "&password=" + oauthDetails.getPassword()
- + "&client_id=nbiaRestAPIClient&client_secret=ItsBetweenUAndMe&grant_type=password");
- post.setEntity(params);
+ //StringEntity params = new StringEntity(
+ // "username=" + oauthDetails.getUsername() + "&password=" + oauthDetails.getPassword()
+ // + "&client_id=nbiaRestAPIClient&client_secret=ItsBetweenUAndMe&grant_type=password");
+ //post.setEntity(params);
+ post.setEntity(new UrlEncodedFormEntity(parameters, "UTF-8"));
response = client.execute(post);
int code = response.getStatusLine().getStatusCode();
-// logger.fine("HTTP response code is " + code);
if (code == OAuthConstants.HTTP_UNAUTHORIZED) {
logger.fine("Authorization server expects Basic authentication. ");
// Add Basic Authorization header