Repository: airavata
Updated Branches:
  refs/heads/develop 64ea7eebd -> bd526ade0


AIRAVATA-2402 changes needed to be able to run MigrationManager


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/c076a56b
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/c076a56b
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/c076a56b

Branch: refs/heads/develop
Commit: c076a56bb9b06e72489244d58fa39bf35c9b3201
Parents: 64ea7ee
Author: Marcus Christie <[email protected]>
Authored: Wed May 31 15:56:50 2017 -0400
Committer: Marcus Christie <[email protected]>
Committed: Wed May 31 15:56:50 2017 -0400

----------------------------------------------------------------------
 .../org/apache/airavata/MigrationManager.java   |  4 ++-
 .../UserProfileAiravataThriftClient.java        |  8 ++---
 .../airavata/Wso2IdentityServerClient.java      | 38 ++++++++++++++++----
 3 files changed, 36 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/c076a56b/modules/user-profile-migration/src/main/java/org/apache/airavata/MigrationManager.java
----------------------------------------------------------------------
diff --git 
a/modules/user-profile-migration/src/main/java/org/apache/airavata/MigrationManager.java
 
b/modules/user-profile-migration/src/main/java/org/apache/airavata/MigrationManager.java
index ba52de4..85353ce 100644
--- 
a/modules/user-profile-migration/src/main/java/org/apache/airavata/MigrationManager.java
+++ 
b/modules/user-profile-migration/src/main/java/org/apache/airavata/MigrationManager.java
@@ -36,6 +36,8 @@ public class MigrationManager {
 
     private ArrayList<Wso2ISLoginCredentialsDAO> adminCredentials = new 
ArrayList<Wso2ISLoginCredentialsDAO>();
     private static AuthzToken authzToken = new AuthzToken("empy_token");
+    private String profileServiceServerHost = "localhost";
+    private int profileServiceServerPort = 8962;
     /*Add the credentials for all the tenants from which the profile should be 
migrated to Airavata DB*/
 
     public void setISLoginCredentials(){
@@ -107,7 +109,7 @@ public class MigrationManager {
     private boolean migrateUserProfilesToAiravata(List<UserProfileDAO> 
ISProfileList) throws TException, ApplicationSettingsException {
         System.out.println("Initiating migration to Airavata internal DB ...");
         UserProfileAiravataThriftClient objFactory = new 
UserProfileAiravataThriftClient();
-        UserProfileService.Client client = 
objFactory.getUserProfileServiceClient();
+        UserProfileService.Client client = 
objFactory.getUserProfileServiceClient(profileServiceServerHost, 
profileServiceServerPort);
         UserProfile airavataUserProfile = new UserProfile();
         // Here are the data associations...
         for(UserProfileDAO ISProfile : ISProfileList){

http://git-wip-us.apache.org/repos/asf/airavata/blob/c076a56b/modules/user-profile-migration/src/main/java/org/apache/airavata/UserProfileAiravataThriftClient.java
----------------------------------------------------------------------
diff --git 
a/modules/user-profile-migration/src/main/java/org/apache/airavata/UserProfileAiravataThriftClient.java
 
b/modules/user-profile-migration/src/main/java/org/apache/airavata/UserProfileAiravataThriftClient.java
index 56f2235..3bea905 100644
--- 
a/modules/user-profile-migration/src/main/java/org/apache/airavata/UserProfileAiravataThriftClient.java
+++ 
b/modules/user-profile-migration/src/main/java/org/apache/airavata/UserProfileAiravataThriftClient.java
@@ -20,7 +20,6 @@
 package org.apache.airavata;
 
 import org.apache.airavata.common.exception.ApplicationSettingsException;
-import org.apache.airavata.common.utils.ServerSettings;
 import org.apache.airavata.service.profile.client.ProfileServiceClientFactory;
 import org.apache.airavata.service.profile.user.cpi.UserProfileService;
 import 
org.apache.airavata.service.profile.user.cpi.exception.UserProfileServiceException;
@@ -28,14 +27,11 @@ import org.apache.thrift.TException;
 
 public class UserProfileAiravataThriftClient {
 
-    public UserProfileService.Client getUserProfileServiceClient() throws 
TException, ApplicationSettingsException {
-        // Check the server ports before running migration
-        final int serverPort = 
Integer.parseInt(ServerSettings.getUserProfileServerPort());
-        final String serverHost = ServerSettings.getUserProfileServerHost();
+    public UserProfileService.Client getUserProfileServiceClient(String 
serverHost, int serverPort) throws TException, ApplicationSettingsException {
         try {
             return 
ProfileServiceClientFactory.createUserProfileServiceClient(serverHost, 
serverPort);
         } catch (UserProfileServiceException e) {
-            throw new TException("Unable to create registry client...", e);
+            throw new TException("Unable to create user profile service 
client...", e);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/c076a56b/modules/user-profile-migration/src/main/java/org/apache/airavata/Wso2IdentityServerClient.java
----------------------------------------------------------------------
diff --git 
a/modules/user-profile-migration/src/main/java/org/apache/airavata/Wso2IdentityServerClient.java
 
b/modules/user-profile-migration/src/main/java/org/apache/airavata/Wso2IdentityServerClient.java
index 48a6857..138b816 100644
--- 
a/modules/user-profile-migration/src/main/java/org/apache/airavata/Wso2IdentityServerClient.java
+++ 
b/modules/user-profile-migration/src/main/java/org/apache/airavata/Wso2IdentityServerClient.java
@@ -27,7 +27,13 @@ import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.axis2.transport.http.HttpTransportProperties;
 import org.wso2.carbon.um.ws.api.stub.RemoteUserStoreManagerServiceStub;
 
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
 import java.io.File;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
 
 /*
  *
@@ -68,11 +74,11 @@ public class Wso2IdentityServerClient {
          * because the private key and certificate file are not committed to 
GitHub,
          * which are needed to run the client */
 
-        String trustStore = System.getProperty("user.dir") + File.separator +
-                "modules" + File.separator + "user-profile-migration" + 
File.separator +
-                "src" + File.separator + "main" + File.separator +
-                "resources" + File.separator + "wso2carbon.jks";
-        System.out.println("file path : " + trustStore);
+//        String trustStore = System.getProperty("user.dir") + File.separator +
+//                "modules" + File.separator + "user-profile-migration" + 
File.separator +
+//                "src" + File.separator + "main" + File.separator +
+//                "resources" + File.separator + "wso2carbon.jks";
+//        System.out.println("file path : " + trustStore);
 
         /**
          * Call to https://localhost:9443/services/   uses HTTPS protocol.
@@ -81,10 +87,28 @@ public class Wso2IdentityServerClient {
          * Following code sets what trust-store to look for and its JKs 
password.
          */
 
-        System.setProperty("javax.net.ssl.trustStore",  trustStore );
+//        System.setProperty("javax.net.ssl.trustStore",  trustStore );
 
-        System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
+//        System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
 
+        // idp.scigap.org:9443 certificate has expired, so the following 
disables checking the certificate
+        TrustManager[] trustAllCerts = new TrustManager[]{
+                new X509TrustManager() {
+                    public java.security.cert.X509Certificate[] 
getAcceptedIssuers() {return null;}
+                    public void 
checkClientTrusted(java.security.cert.X509Certificate[] certs, String 
authType){}
+                    public void 
checkServerTrusted(java.security.cert.X509Certificate[] certs, String 
authType){}
+                }
+        };
+
+        try {
+            SSLContext sc = SSLContext.getInstance("SSL");
+            sc.init(null, trustAllCerts, new java.security.SecureRandom());
+            SSLContext.setDefault(sc);
+        } catch (KeyManagementException e) {
+            throw new RuntimeException(e);
+        } catch (NoSuchAlgorithmException e) {
+            throw new RuntimeException(e);
+        }
         /**
          * Axis2 configuration context
          */

Reply via email to