diff --git a/vcell-admin/src/test/java/cbit/vcell/util/TestMissingSimData.java b/vcell-admin/src/test/java/cbit/vcell/util/TestMissingSimData.java index de21978d28..bb5cb2f431 100644 --- a/vcell-admin/src/test/java/cbit/vcell/util/TestMissingSimData.java +++ b/vcell-admin/src/test/java/cbit/vcell/util/TestMissingSimData.java @@ -478,7 +478,7 @@ private static Hashtable doQuery(String connectURL,Stri } String userkey = rset.getString("userkey"); if(userLoginInfo == null || !userLoginInfo.getUserName().equals(userid)){ - userLoginInfo = new UserLoginInfo(userid,DigestedPassword.createAlreadyDigested(rset.getString("digestpw"))); + userLoginInfo = new UserLoginInfo(userid); userLoginInfo.setUser(new User(userid, new KeyValue(userkey))); } VCSimulationIdentifier vcSimulationIdentifier = new VCSimulationIdentifier(simJobSimRef, userLoginInfo.getUser()); @@ -1005,7 +1005,7 @@ private static void runSim(SimIDAndJobID simIDAndJobID) throws Exception{ return; } VCSimulationIdentifier vcSimulationIdentifier = new VCSimulationIdentifier(simIDAndJobID.simID, simIDAndJobID.user); - UserLoginInfo userLoginInfo = new UserLoginInfo(simIDAndJobID.user.getName(), new DigestedPassword("xoxoxox")); + UserLoginInfo userLoginInfo = new UserLoginInfo(simIDAndJobID.user.getName()); //getVcellClient().getClientServerManager().getConnectionStatus() VCellConnection vcellConnection = userConnections.get(simIDAndJobID.user); try{ diff --git a/vcell-api/src/main/java/org/vcell/rest/VCellApiMain.java b/vcell-api/src/main/java/org/vcell/rest/VCellApiMain.java index fd87ba7909..7e7e431378 100644 --- a/vcell-api/src/main/java/org/vcell/rest/VCellApiMain.java +++ b/vcell-api/src/main/java/org/vcell/rest/VCellApiMain.java @@ -229,7 +229,7 @@ public void onException(Exception e) { String pathPrefixV0 = PropertyLoader.getRequiredProperty(PropertyLoader.vcellServerPrefixV0); HealthService healthService = new HealthService(restEventService, "localhost", port, pathPrefixV0, bIgnoreCertProblemsForHealthService, bIgnoreHostMismatchForHealthService, - testUserInfo.userid, testUserInfo.digestedPassword0); + testUserInfo); AdminService adminService = new AdminService(adminDbTopLevel, databaseServerImpl); RpcService rpcService = new RpcService(vcMessagingService_int); WadlApplication app = new VCellApiApplication(restDatabaseService, userService, rpcService, restEventService, adminService, templateConfiguration, healthService, javascriptDir); diff --git a/vcell-api/src/main/java/org/vcell/rest/health/HealthService.java b/vcell-api/src/main/java/org/vcell/rest/health/HealthService.java index a5ecaca710..a62bba2f39 100644 --- a/vcell-api/src/main/java/org/vcell/rest/health/HealthService.java +++ b/vcell-api/src/main/java/org/vcell/rest/health/HealthService.java @@ -11,10 +11,8 @@ import org.apache.logging.log4j.Logger; import org.vcell.rest.events.RestEventService; import org.vcell.util.BigString; -import org.vcell.util.document.KeyValue; -import org.vcell.util.document.UserLoginInfo; +import org.vcell.util.document.*; import org.vcell.util.document.UserLoginInfo.DigestedPassword; -import org.vcell.util.document.VCInfoContainer; import cbit.rmi.event.MessageEvent; import cbit.rmi.event.SimulationJobStatusEvent; @@ -109,20 +107,18 @@ static NagiosStatus Unknown(Long elapsedTime_MS, String message) { final String pathPrefixV0; final boolean bIgnoreCertProblems; final boolean bIgnoreHostMismatch; - final String testUserid; - final DigestedPassword testPassword; + final UserInfo testUserinfo; public HealthService(RestEventService eventService, String host, int port, String pathPrefixV0, boolean bIgnoreCertProblems, boolean bIgnoreHostMismatch, - String testUserid, DigestedPassword testPassword) { + UserInfo testUserinfo) { this.eventService = eventService; this.host = host; this.port = port; this.pathPrefixV0 = pathPrefixV0; this.bIgnoreCertProblems = bIgnoreCertProblems; this.bIgnoreHostMismatch = bIgnoreHostMismatch; - this.testUserid = testUserid; - this.testPassword = testPassword; + this.testUserinfo = testUserinfo; } private long simStartEvent() { @@ -208,9 +204,10 @@ private void loginLoop() { while (true) { long id = loginStartEvent(); try { - UserLoginInfo userLoginInfo = new UserLoginInfo(testUserid, testPassword); + UserLoginInfo userLoginInfo = new UserLoginInfo(testUserinfo.getApiUserInfo().userid); + userLoginInfo.setUser(new User(testUserinfo.userid, testUserinfo.id)); RemoteProxyVCellConnectionFactory vcellConnectionFactory = new RemoteProxyVCellConnectionFactory(host, port, pathPrefixV0); - VCellConnection vcellConnection = vcellConnectionFactory.createDepricatedVCellConnection(userLoginInfo); + VCellConnection vcellConnection = vcellConnectionFactory.createVCellConnection(userLoginInfo); VCInfoContainer vcInfoContainer = vcellConnection.getUserMetaDbServer().getVCInfoContainer(); loginSuccess(id); }catch (Throwable e) { @@ -229,14 +226,15 @@ private void runsimLoop() { Thread.sleep(SIMULATION_LOOP_START_DELAY); } catch (InterruptedException e1) { } - UserLoginInfo userLoginInfo = new UserLoginInfo(testUserid, testPassword); + UserLoginInfo userLoginInfo = new UserLoginInfo(testUserinfo.userid); + userLoginInfo.setUser(new User(testUserinfo.userid, testUserinfo.id)); while (true) { long id = simStartEvent(); KeyValue savedBioModelKey = null; VCSimulationIdentifier runningSimId = null; try { RemoteProxyVCellConnectionFactory vcellConnectionFactory = new RemoteProxyVCellConnectionFactory(host, port, pathPrefixV0); - VCellConnection vcellConnection = vcellConnectionFactory.createDepricatedVCellConnection(userLoginInfo); + VCellConnection vcellConnection = vcellConnectionFactory.createVCellConnection(userLoginInfo); String vcmlString = IOUtils.toString(getClass().getResourceAsStream("/TestTemplate.vcml")); @@ -311,7 +309,7 @@ public void setMessage(String message) { } // cleanup try { RemoteProxyVCellConnectionFactory vcellConnectionFactory = new RemoteProxyVCellConnectionFactory(host, port, pathPrefixV0); - VCellConnection vcellConnection = vcellConnectionFactory.createDepricatedVCellConnection(userLoginInfo); + VCellConnection vcellConnection = vcellConnectionFactory.createVCellConnection(userLoginInfo); if (runningSimId!=null) { try { vcellConnection.getSimulationController().stopSimulation(runningSimId); diff --git a/vcell-api/src/main/java/org/vcell/rest/rpc/RpcRestlet.java b/vcell-api/src/main/java/org/vcell/rest/rpc/RpcRestlet.java index 4da19efdd7..5af44184ba 100644 --- a/vcell-api/src/main/java/org/vcell/rest/rpc/RpcRestlet.java +++ b/vcell-api/src/main/java/org/vcell/rest/rpc/RpcRestlet.java @@ -172,7 +172,7 @@ public void handle(Request req, Response response) { VCellApiApplication vcellApiApplication = (VCellApiApplication)getApplication(); RpcService rpcService = vcellApiApplication.getRpcService(); serializableResultObject = rpcService.sendRpcMessage( - queue, vcRpcRequest, new Boolean(rpcBody.returnedRequired), specialProperties, specialValues, new UserLoginInfo(username,null)); + queue, vcRpcRequest, rpcBody.returnedRequired, specialProperties, specialValues, new UserLoginInfo(username)); } byte[] serializedResultObject = VCellApiClient.toCompressedSerialized(serializableResultObject); response.setStatus(Status.SUCCESS_OK, "rpc method="+method+" succeeded"); diff --git a/vcell-api/src/main/java/org/vcell/rest/server/RestDatabaseService.java b/vcell-api/src/main/java/org/vcell/rest/server/RestDatabaseService.java index 7ab89db569..42e1b24439 100644 --- a/vcell-api/src/main/java/org/vcell/rest/server/RestDatabaseService.java +++ b/vcell-api/src/main/java/org/vcell/rest/server/RestDatabaseService.java @@ -185,7 +185,7 @@ public SimulationRep startSimulation(BiomodelSimulationStartServerResource resou } VCMessageSession rpcSession = vcMessagingService.createProducerSession(); try { - UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName(),null); + UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName()); try { userLoginInfo.setUser(vcellUser); } catch (Exception e) { @@ -214,7 +214,7 @@ public SimulationRep stopSimulation(BiomodelSimulationStopServerResource resourc } VCMessageSession rpcSession = vcMessagingService.createProducerSession(); try { - UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName(),null); + UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName()); try { userLoginInfo.setUser(vcellUser); } catch (Exception e) { @@ -234,7 +234,7 @@ public DataSetMetadata getDataSetMetadata(SimDataServerResource resource, User v if (vcellUser==null){ vcellUser = VCellApiApplication.DUMMY_USER; } - UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName(),null); + UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName()); String simId = resource.getAttribute(VCellApiApplication.SIMDATAID); // resource.getRequestAttributes().get(VCellApiApplication.SIMDATAID); KeyValue simKey = new KeyValue(simId); SimulationRep simRep = getSimulationRep(simKey); @@ -259,7 +259,7 @@ public DataSetTimeSeries getDataSetTimeSeries(SimDataValuesServerResource resour if (vcellUser==null){ vcellUser = VCellApiApplication.DUMMY_USER; } - UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName(),null); + UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName()); String simId = resource.getAttribute(VCellApiApplication.SIMDATAID); // resource.getRequestAttributes().get(VCellApiApplication.SIMDATAID); String jobIndexString = resource.getAttribute(VCellApiApplication.JOBINDEX); // resource.getRequestAttributes().get(VCellApiApplication.SIMDATAID); KeyValue simKey = new KeyValue(simId); @@ -748,7 +748,7 @@ public SimpleJobStatus[] query(SimulationTasksServerResource resource, User vcel } VCMessageSession rpcSession = vcMessagingService.createProducerSession(); try { - UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName(),null); + UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName()); try { userLoginInfo.setUser(vcellUser); } catch (Exception e) { @@ -813,7 +813,7 @@ public SimulationStatusRepresentation[] query(SimulationStatusServerResource res // VCMessageSession rpcSession = vcMessagingService.createProducerSession(); try { - UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName(),null); + UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName()); try { userLoginInfo.setUser(vcellUser); } catch (Exception e) { diff --git a/vcell-apiclient/src/main/java/org/vcell/api/client/VCellApiClient.java b/vcell-apiclient/src/main/java/org/vcell/api/client/VCellApiClient.java index 3b04b57184..394b44fa70 100644 --- a/vcell-apiclient/src/main/java/org/vcell/api/client/VCellApiClient.java +++ b/vcell-apiclient/src/main/java/org/vcell/api/client/VCellApiClient.java @@ -466,45 +466,6 @@ public SimulationTaskRepresentation[] stopSimulation(String bmId, String simKey) return simulationTaskRepresentations; } - public AccessTokenRepresentation deprecatedAuthenticate(String userid, String password, boolean alreadyDigested) throws ClientProtocolException, IOException { - // hash the password - String digestedPassword = (alreadyDigested)?(password):createdDigestPassword(password); - - HttpGet httpget = new HttpGet(getApiUrlPrefix()+"/access_token?user_id="+userid+"&user_password="+digestedPassword+"&client_id="+clientID); - - if (lg.isInfoEnabled()) { - lg.info("Executing request to retrieve access_token " + httpget.getRequestLine()); - } - - String responseBody = httpclient.execute(httpget, new VCellStringResponseHandler("authenticate()", httpget)); - String accessTokenJson = responseBody; - if (lg.isInfoEnabled()) { - lg.info("returned: "+accessTokenJson); - } - - Gson gson = new Gson(); - AccessTokenRepresentation accessTokenRep = gson.fromJson(accessTokenJson,AccessTokenRepresentation.class); - - BasicCredentialsProvider basicCredsProvider = new BasicCredentialsProvider(); - basicCredsProvider.setCredentials( - new AuthScope(httpHost.getHostName(),httpHost.getPort()), - new UsernamePasswordCredentials("access_token", accessTokenRep.getToken())); - - // Create AuthCache instance - AuthCache authCache = new BasicAuthCache(); - // Generate BASIC scheme object and add it to the local auth cache - BasicScheme basicAuth = new BasicScheme(); - authCache.put(httpHost, basicAuth); - - // Add AuthCache to the execution context - httpClientContext = HttpClientContext.create(); -// httpClientContext.setCredentialsProvider(basicCredsProvider); -// httpClientContext.setAuthCache(authCache); - httpClientContext.setUserToken(accessTokenRep.token); - - return accessTokenRep; - } - public void createDefaultQuarkusClient(boolean bIgnoreCertProblems){ apiClient = new ApiClient(){{ if (bIgnoreCertProblems){setHttpClientBuilder(CustomApiClientCode.createInsecureHttpClientBuilder());}; diff --git a/vcell-apiclient/src/main/java/org/vcell/api/client/examples/VCellApiClientTest.java b/vcell-apiclient/src/main/java/org/vcell/api/client/examples/VCellApiClientTest.java index 4e2d556552..8091b4981b 100644 --- a/vcell-apiclient/src/main/java/org/vcell/api/client/examples/VCellApiClientTest.java +++ b/vcell-apiclient/src/main/java/org/vcell/api/client/examples/VCellApiClientTest.java @@ -29,8 +29,7 @@ public static void main(String[] args) { String password = args[3]; vcellApiClient = new VCellApiClient(host,port,pathPrefix_v0); - - vcellApiClient.deprecatedAuthenticate(username,password,false); + vcellApiClient.authenticate(false); // test /biomodel[? query string] BiomodelRepresentation[] biomodelReps = vcellApiClient.getBioModels(new BioModelsQuerySpec()); diff --git a/vcell-core/src/main/java/cbit/vcell/client/server/ClientServerInfo.java b/vcell-core/src/main/java/cbit/vcell/client/server/ClientServerInfo.java index d93b082977..db351d8577 100644 --- a/vcell-core/src/main/java/cbit/vcell/client/server/ClientServerInfo.java +++ b/vcell-core/src/main/java/cbit/vcell/client/server/ClientServerInfo.java @@ -53,7 +53,7 @@ public static ClientServerInfo createFileBasedServerInfo() { public static ClientServerInfo createLocalServerInfo(String userName) { ClientServerInfo csi = new ClientServerInfo(ServerType.SERVER_LOCAL, ClientServerInfo.apiHost, ClientServerInfo.isHTTP ? 80 : 443, - ClientServerInfo.v0PathPrefix, new UserLoginInfo(userName, null)); + ClientServerInfo.v0PathPrefix, new UserLoginInfo(userName)); return csi; } @@ -64,7 +64,7 @@ public UserLoginInfo getUserLoginInfo(){ } public static ClientServerInfo createRemoteServerInfo(String apihost, Integer apiport, String pathPrefix_v0, String userName) { - ClientServerInfo csi = new ClientServerInfo(ServerType.SERVER_REMOTE,apihost,apiport,pathPrefix_v0,new UserLoginInfo(userName, null)); + ClientServerInfo csi = new ClientServerInfo(ServerType.SERVER_REMOTE,apihost,apiport,pathPrefix_v0,new UserLoginInfo(userName)); return csi; } diff --git a/vcell-core/src/main/java/cbit/vcell/message/server/bootstrap/client/RemoteProxyVCellConnectionFactory.java b/vcell-core/src/main/java/cbit/vcell/message/server/bootstrap/client/RemoteProxyVCellConnectionFactory.java index 70f502a472..d18ee6bd9a 100644 --- a/vcell-core/src/main/java/cbit/vcell/message/server/bootstrap/client/RemoteProxyVCellConnectionFactory.java +++ b/vcell-core/src/main/java/cbit/vcell/message/server/bootstrap/client/RemoteProxyVCellConnectionFactory.java @@ -197,16 +197,6 @@ public RemoteProxyVCellConnectionFactory( } } -public VCellConnection createDepricatedVCellConnection(UserLoginInfo userLoginInfo) throws ConnectionException { - try { - AccessTokenRepresentation accessTokenRep = this.vcellApiClient.deprecatedAuthenticate(userLoginInfo.getUserName(), userLoginInfo.getDigestedPassword().getString(),true); - userLoginInfo.setUser(new User(accessTokenRep.userId, new KeyValue(accessTokenRep.getUserKey()))); - return new LocalVCellConnectionMessaging(userLoginInfo,rpcSender); - } catch (IOException e) { - throw new ConnectionException("failed to connect: "+e.getMessage(), e); - } -} - @Override public VCellConnection createVCellConnection(UserLoginInfo userLoginInfo) { try { diff --git a/vcell-core/src/main/java/cbit/vcell/server/VCellConnectionFactory.java b/vcell-core/src/main/java/cbit/vcell/server/VCellConnectionFactory.java index f6916f7a45..07b1ce18c1 100644 --- a/vcell-core/src/main/java/cbit/vcell/server/VCellConnectionFactory.java +++ b/vcell-core/src/main/java/cbit/vcell/server/VCellConnectionFactory.java @@ -16,7 +16,6 @@ import java.io.IOException; public interface VCellConnectionFactory { - VCellConnection createDepricatedVCellConnection(UserLoginInfo userLoginInfo) throws ConnectionException, AuthenticationException, IOException; VCellConnection createVCellConnection(UserLoginInfo userLoginInfo) throws ConnectionException; Auth0ConnectionUtils getAuth0ConnectionUtils(); } diff --git a/vcell-core/src/main/java/cbit/vcell/solver/test/HybridSolverTester.java b/vcell-core/src/main/java/cbit/vcell/solver/test/HybridSolverTester.java index e8d602fc73..8be72417ca 100644 --- a/vcell-core/src/main/java/cbit/vcell/solver/test/HybridSolverTester.java +++ b/vcell-core/src/main/java/cbit/vcell/solver/test/HybridSolverTester.java @@ -600,127 +600,127 @@ public static int getMaxTaskID(SimulationStatusPersistent simulationStatus){ return maxTaskID; } } - public static void main(java.lang.String[] args) { - VCMongoMessage.enabled = false; - boolean bAlternate = false; - if(args.length == 12){ - bAlternate = true; - }else if(args.length != 5){ - System.out.println("usage: HybridSolverTest userid SimID times(delimited by :) dataIndexes(delimited by :) varNames(delimited by :) numRuns outputFileDirectory bCalclOnly dbPassword useridKey rmiServer rmiPort"); - System.out.println("usage: HybridSolverTest userid SimID all postproc varNames(delimited by :) numRuns outputFileDirectory bCalclOnly dbPassword useridKey rmiServer rmiPort"); - System.out.println("usage: HybridSolverTest mathVCMLFileName startingTrialNo numTrials varNames(delimited by :) bPrintTime vcellSite(rel,beta,...)"); - System.exit(1); - } - - FileWriter fw = null; - try{ - if(bAlternate){ - AltArgsHelper altArgsHelper = new AltArgsHelper(args[0], args[1], args[2], args[3], args[4], Integer.parseInt(args[5]), - new File(args[6]), Boolean.parseBoolean(args[7]), args[8], args[9], args[10], args[11]); -// final String user = args[0]; -// final String simID = args[1]; -// final int numRuns = Integer.parseInt(args[5]); -// -// final String simPrefix = "SimID_"+simID+"_"; -// File userSimDataDir = new File("\\\\cfs02\\raid\\vcell\\users\\"+user); -// File outputDir = new File(args[6]); -// boolean bCalcOnly = Boolean.parseBoolean(args[7]); -// String dbPassword = args[8]; -// String useridKey = args[9]; -// String rmiServer = args[10]; -// String rmiPort = args[11]; - - VCSimulationIdentifier vcSimulationIdentifier = new VCSimulationIdentifier(new KeyValue(altArgsHelper.simID),altArgsHelper.user); - UserLoginInfo userLoginInfo = new UserLoginInfo(altArgsHelper.user.getName(), new DigestedPassword(altArgsHelper.dbPassword)); - - File[] trialList = null; - VCellConnectionHelper vCellConnectionHelper = null; - File emptyFile = File.createTempFile("hstempty",null); - try{ - if(!altArgsHelper.bCalcOnly){ -// String rmiUrl = "//" + "rmi-alpha.cam.uchc.edu" + ":" + "40106" + "/"+"VCellBootstrapServer"; -// String rmiUrl = "//" + "rmi-alpha.cam.uchc.edu" + ":" + "40112" + "/"+"VCellBootstrapServer"; - String rmiUrl = "//" + altArgsHelper.rmiServer+".cam.uchc.edu" + ":" + altArgsHelper.rmiPort + "/"+"VCellBootstrapServer"; - - vCellConnectionHelper = new VCellConnectionHelper(userLoginInfo, rmiUrl); - - for (int runIndex = 0; runIndex < altArgsHelper.numRuns; runIndex++) { - System.out.println("----- Starting run "+(runIndex+1)+" of "+altArgsHelper.numRuns); - runSim(userLoginInfo,vcSimulationIdentifier,vCellConnectionHelper); - if(trialList == null){ - System.out.println("Sim ran, getting trial list for "+altArgsHelper.simPrefix+" please wait..."); - trialList = altArgsHelper.userSimDataDir.listFiles(new FileFilter() { - @Override - public boolean accept(File pathname) { -// if(pathname.getName().startsWith(altArgsHelper.simPrefix)){ -// System.out.println(pathname); +// public static void main(java.lang.String[] args) { +// VCMongoMessage.enabled = false; +// boolean bAlternate = false; +// if(args.length == 12){ +// bAlternate = true; +// }else if(args.length != 5){ +// System.out.println("usage: HybridSolverTest userid SimID times(delimited by :) dataIndexes(delimited by :) varNames(delimited by :) numRuns outputFileDirectory bCalclOnly dbPassword useridKey rmiServer rmiPort"); +// System.out.println("usage: HybridSolverTest userid SimID all postproc varNames(delimited by :) numRuns outputFileDirectory bCalclOnly dbPassword useridKey rmiServer rmiPort"); +// System.out.println("usage: HybridSolverTest mathVCMLFileName startingTrialNo numTrials varNames(delimited by :) bPrintTime vcellSite(rel,beta,...)"); +// System.exit(1); +// } +// +// FileWriter fw = null; +// try{ +// if(bAlternate){ +// AltArgsHelper altArgsHelper = new AltArgsHelper(args[0], args[1], args[2], args[3], args[4], Integer.parseInt(args[5]), +// new File(args[6]), Boolean.parseBoolean(args[7]), args[8], args[9], args[10], args[11]); +//// final String user = args[0]; +//// final String simID = args[1]; +//// final int numRuns = Integer.parseInt(args[5]); +//// +//// final String simPrefix = "SimID_"+simID+"_"; +//// File userSimDataDir = new File("\\\\cfs02\\raid\\vcell\\users\\"+user); +//// File outputDir = new File(args[6]); +//// boolean bCalcOnly = Boolean.parseBoolean(args[7]); +//// String dbPassword = args[8]; +//// String useridKey = args[9]; +//// String rmiServer = args[10]; +//// String rmiPort = args[11]; +// +// VCSimulationIdentifier vcSimulationIdentifier = new VCSimulationIdentifier(new KeyValue(altArgsHelper.simID),altArgsHelper.user); +// UserLoginInfo userLoginInfo = new UserLoginInfo(altArgsHelper.user.getName())); +// +// File[] trialList = null; +// VCellConnectionHelper vCellConnectionHelper = null; +// File emptyFile = File.createTempFile("hstempty",null); +// try{ +// if(!altArgsHelper.bCalcOnly){ +//// String rmiUrl = "//" + "rmi-alpha.cam.uchc.edu" + ":" + "40106" + "/"+"VCellBootstrapServer"; +//// String rmiUrl = "//" + "rmi-alpha.cam.uchc.edu" + ":" + "40112" + "/"+"VCellBootstrapServer"; +// String rmiUrl = "//" + altArgsHelper.rmiServer+".cam.uchc.edu" + ":" + altArgsHelper.rmiPort + "/"+"VCellBootstrapServer"; +// +// vCellConnectionHelper = new VCellConnectionHelper(userLoginInfo, rmiUrl); +// +// for (int runIndex = 0; runIndex < altArgsHelper.numRuns; runIndex++) { +// System.out.println("----- Starting run "+(runIndex+1)+" of "+altArgsHelper.numRuns); +// runSim(userLoginInfo,vcSimulationIdentifier,vCellConnectionHelper); +// if(trialList == null){ +// System.out.println("Sim ran, getting trial list for "+altArgsHelper.simPrefix+" please wait..."); +// trialList = altArgsHelper.userSimDataDir.listFiles(new FileFilter() { +// @Override +// public boolean accept(File pathname) { +//// if(pathname.getName().startsWith(altArgsHelper.simPrefix)){ +//// System.out.println(pathname); +//// } +// return pathname.getName().startsWith(altArgsHelper.simPrefix) && !pathname.getName().endsWith(".simtask.xml"); +// } +// }); +// } +// System.out.println("----- Copying run "+(runIndex+1)+" of "+altArgsHelper.numRuns); +// File outputRunDir = makeOutputRunDir(altArgsHelper.outputDir,runIndex); +// for (int j = 0; j < trialList.length; j++) { +// File localCopyFile = new File(outputRunDir,trialList[j].getName()); +// try{ +// FileUtils.copyFile(trialList[j],localCopyFile);//copy remote sim data file to local +// trialList[j].delete();//delete remote +// }catch(Exception e){ +// System.out.println("failed to copy '"+trialList[j].getAbsolutePath()+"', error="+e.getMessage()+". Putting empty file as placeholder"); +// try{ +// FileUtils.copyFile(emptyFile,localCopyFile);//copy empty file to local in place of problematic remote sim data file, later analysis will skip it +// }catch(Exception e2){ +// System.out.println("Faild to copy file and failed to copy empty, "+e2.getMessage()); // } - return pathname.getName().startsWith(altArgsHelper.simPrefix) && !pathname.getName().endsWith(".simtask.xml"); - } - }); - } - System.out.println("----- Copying run "+(runIndex+1)+" of "+altArgsHelper.numRuns); - File outputRunDir = makeOutputRunDir(altArgsHelper.outputDir,runIndex); - for (int j = 0; j < trialList.length; j++) { - File localCopyFile = new File(outputRunDir,trialList[j].getName()); - try{ - FileUtils.copyFile(trialList[j],localCopyFile);//copy remote sim data file to local - trialList[j].delete();//delete remote - }catch(Exception e){ - System.out.println("failed to copy '"+trialList[j].getAbsolutePath()+"', error="+e.getMessage()+". Putting empty file as placeholder"); - try{ - FileUtils.copyFile(emptyFile,localCopyFile);//copy empty file to local in place of problematic remote sim data file, later analysis will skip it - }catch(Exception e2){ - System.out.println("Faild to copy file and failed to copy empty, "+e2.getMessage()); - } - } - } - } - } - - //calc stats - String dateStr= dateFormat.format(new Date()); - String outPrefix = altArgsHelper.simID+"_"+dateStr+"_0"; - File outputFile = new File(altArgsHelper.outputDir,outPrefix+".csv"); - while(outputFile.exists()){ - outPrefix = TokenMangler.getNextEnumeratedToken(outPrefix); - outputFile = new File(altArgsHelper.outputDir,outPrefix+".csv"); - } - fw = new FileWriter(outputFile); - fw.write("\""+altArgsHelper.toString()+"\"\n"); - for (int runIndex = 0; runIndex < altArgsHelper.numRuns; runIndex++) { - makeAltCSV(altArgsHelper,fw,runIndex,makeOutputRunDir(altArgsHelper.outputDir,runIndex)); - } - fw.close(); - }finally{ - if(!altArgsHelper.bCalcOnly){ - File[] straglers = altArgsHelper.userSimDataDir.listFiles(new FileFilter() { - @Override - public boolean accept(File pathname) { - return pathname.getName().startsWith(altArgsHelper.simPrefix); - } - }); - if(straglers != null){ - for (int i = 0; i < straglers.length; i++) { - straglers[i].delete(); - } - } - } - } - - - }else{ - String site = args[5]; - HybridSolverTester hst = new HybridSolverTester(args[0], Integer.parseInt(args[1]), Integer.parseInt(args[2]), args[3], Boolean.parseBoolean(args[4])); - hst.runHybridTest(site); - } - }catch(Exception e){ - lg.error(e.getMessage(), e); - System.exit(1); - }finally{ - if(fw !=null){try{fw.close();}catch(Exception e){lg.error(e.getMessage(), e);}} - } - } +// } +// } +// } +// } +// +// //calc stats +// String dateStr= dateFormat.format(new Date()); +// String outPrefix = altArgsHelper.simID+"_"+dateStr+"_0"; +// File outputFile = new File(altArgsHelper.outputDir,outPrefix+".csv"); +// while(outputFile.exists()){ +// outPrefix = TokenMangler.getNextEnumeratedToken(outPrefix); +// outputFile = new File(altArgsHelper.outputDir,outPrefix+".csv"); +// } +// fw = new FileWriter(outputFile); +// fw.write("\""+altArgsHelper.toString()+"\"\n"); +// for (int runIndex = 0; runIndex < altArgsHelper.numRuns; runIndex++) { +// makeAltCSV(altArgsHelper,fw,runIndex,makeOutputRunDir(altArgsHelper.outputDir,runIndex)); +// } +// fw.close(); +// }finally{ +// if(!altArgsHelper.bCalcOnly){ +// File[] straglers = altArgsHelper.userSimDataDir.listFiles(new FileFilter() { +// @Override +// public boolean accept(File pathname) { +// return pathname.getName().startsWith(altArgsHelper.simPrefix); +// } +// }); +// if(straglers != null){ +// for (int i = 0; i < straglers.length; i++) { +// straglers[i].delete(); +// } +// } +// } +// } +// +// +// }else{ +// String site = args[5]; +// HybridSolverTester hst = new HybridSolverTester(args[0], Integer.parseInt(args[1]), Integer.parseInt(args[2]), args[3], Boolean.parseBoolean(args[4])); +// hst.runHybridTest(site); +// } +// }catch(Exception e){ +// lg.error(e.getMessage(), e); +// System.exit(1); +// }finally{ +// if(fw !=null){try{fw.close();}catch(Exception e){lg.error(e.getMessage(), e);}} +// } +// } private static File makeOutputRunDir(File baseOutputDir,int runIndex){ File outputRunDir = new File(baseOutputDir,"run"+runIndex); diff --git a/vcell-core/src/main/java/org/vcell/optimization/CopasiOptimizationSolver.java b/vcell-core/src/main/java/org/vcell/optimization/CopasiOptimizationSolver.java index 44b6c34644..1b13e1475d 100644 --- a/vcell-core/src/main/java/org/vcell/optimization/CopasiOptimizationSolver.java +++ b/vcell-core/src/main/java/org/vcell/optimization/CopasiOptimizationSolver.java @@ -63,10 +63,9 @@ public static OptimizationResultSet solveRemoteApi( String host = clientServerInfo.getApihost(); int port = clientServerInfo.getApiport(); String pathPrefixV0 = clientServerInfo.getPathPrefix_v0(); - UserLoginInfo userLoginInfo = clientServerInfo.getUserLoginInfo(); // e.g. vcell.serverhost=vcellapi.cam.uchc.edu:443 VCellApiClient apiClient = new VCellApiClient(host, port, pathPrefixV0, bIgnoreCertProblems, bIgnoreHostMismatch); - apiClient.deprecatedAuthenticate(userLoginInfo.getUser().getName(), userLoginInfo.getDigestedPassword().getString(), true); + apiClient.authenticate(bIgnoreCertProblems); OptProblem optProblem = CopasiUtils.paramTaskToOptProblem(parameterEstimationTask); diff --git a/vcell-core/src/main/java/org/vcell/util/document/UserLoginInfo.java b/vcell-core/src/main/java/org/vcell/util/document/UserLoginInfo.java index d45798b3df..50b8bb83d8 100644 --- a/vcell-core/src/main/java/org/vcell/util/document/UserLoginInfo.java +++ b/vcell-core/src/main/java/org/vcell/util/document/UserLoginInfo.java @@ -23,24 +23,20 @@ public class UserLoginInfo implements Serializable { private final static Logger lg = LogManager.getLogger(UserLoginInfo.class); - private String userName; - private DigestedPassword digestedPassword;// obfuscate password - private transient String password; // clear text password - private AccessTokenRepresentation access_token; - private String os_name;// os.name Operating system name - private String os_arch;// os.arch Operating system architecture - private String os_version;// os.version Operating system version - private String java_version;// java.version JRE version number - private String vcellSoftwareVersion;// VCell client logging in from + private final String userName; + private final String os_name;// os.name Operating system name + private final String os_arch;// os.arch Operating system architecture + private final String os_version;// os.version Operating system version + private final String java_version;// java.version JRE version number + private final String vcellSoftwareVersion;// VCell client logging in from private User user; // clientId to indentify machine so that // same user can login at the same time. private final long clientId = System.currentTimeMillis(); - public UserLoginInfo(String userName, DigestedPassword digestedPassword) { + public UserLoginInfo(String userName) { super(); this.userName = userName; - this.digestedPassword = digestedPassword; os_name = System.getProperty("os.name"); os_arch = getArchitecture(os_name); os_version = System.getProperty("os.version"); @@ -196,10 +192,6 @@ public String getUserName() { return userName; } - public DigestedPassword getDigestedPassword() { - return digestedPassword; - } - public String getVCellSoftwareVersion() { return vcellSoftwareVersion; } diff --git a/vcell-core/src/test/java/cbit/vcell/message/server/bootstrap/client/RemoteProxyVCellConnectionFactoryTest.java b/vcell-core/src/test/java/cbit/vcell/message/server/bootstrap/client/RemoteProxyVCellConnectionFactoryTest.java index ea47e301c6..629c931f6d 100644 --- a/vcell-core/src/test/java/cbit/vcell/message/server/bootstrap/client/RemoteProxyVCellConnectionFactoryTest.java +++ b/vcell-core/src/test/java/cbit/vcell/message/server/bootstrap/client/RemoteProxyVCellConnectionFactoryTest.java @@ -26,10 +26,10 @@ public class RemoteProxyVCellConnectionFactoryTest { @BeforeEach public void setUp() throws Exception { - UserLoginInfo userLoginInfo = new UserLoginInfo("schaff",new DigestedPassword("xxxxxxx")); + UserLoginInfo userLoginInfo = new UserLoginInfo("schaff"); factory = new RemoteProxyVCellConnectionFactory("localhost", 8099, ""); apiClient = factory.getVCellApiClient(); - vcConn = factory.createDepricatedVCellConnection(userLoginInfo); + vcConn = factory.createVCellConnection(userLoginInfo); } @AfterEach diff --git a/vcell-server/src/main/java/cbit/vcell/message/server/bootstrap/LocalVCellConnectionFactory.java b/vcell-server/src/main/java/cbit/vcell/message/server/bootstrap/LocalVCellConnectionFactory.java index ba1c112b62..136e05fe62 100644 --- a/vcell-server/src/main/java/cbit/vcell/message/server/bootstrap/LocalVCellConnectionFactory.java +++ b/vcell-server/src/main/java/cbit/vcell/message/server/bootstrap/LocalVCellConnectionFactory.java @@ -68,40 +68,6 @@ public LocalVCellConnectionFactory() { } -@Override -public VCellConnection createDepricatedVCellConnection(UserLoginInfo userLoginInfo) throws AuthenticationException, ConnectionException { - try { - if (connectionFactory == null) { - connectionFactory = DatabaseService.getInstance().createConnectionFactory(); - } - KeyFactory keyFactory = connectionFactory.getKeyFactory(); - LocalVCellConnection.setDatabaseResources(connectionFactory, keyFactory); - AdminDBTopLevel adminDbTopLevel = new AdminDBTopLevel(connectionFactory); - boolean bEnableRetry = false; - boolean isLocal = true; - User user = adminDbTopLevel.getUser(userLoginInfo.getUserName(), userLoginInfo.getDigestedPassword(), bEnableRetry, isLocal); - if (user!=null) { - userLoginInfo.setUser(user); - }else { - throw new AuthenticationException("failed to authenticate as user "+userLoginInfo.getUserName()); - } - DatabaseServerImpl databaseServerImpl = new DatabaseServerImpl(connectionFactory,keyFactory); - boolean bCache = false; - Cachetable cacheTable = null; - DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(cacheTable, - new File(PropertyLoader.getRequiredProperty(PropertyLoader.primarySimDataDirInternalProperty)), - new File(PropertyLoader.getRequiredProperty(PropertyLoader.secondarySimDataDirInternalProperty))); - SimulationDatabaseDirect simulationDatabase = new SimulationDatabaseDirect(adminDbTopLevel, databaseServerImpl, bCache); - ExportServiceImpl exportServiceImpl = new ExportServiceImpl(); - LocalVCellConnection vcConn = new LocalVCellConnection(userLoginInfo, simulationDatabase, dataSetControllerImpl, exportServiceImpl); - NativeLib.HDF5.load(); - return vcConn; - } catch (Throwable exc) { - lg.error(exc.getMessage(), exc); - throw new ConnectionException(exc.getMessage()); - } -} - @Override public VCellConnection createVCellConnection(UserLoginInfo userLoginInfo) throws ConnectionException { try {