use of org.vcell.db.KeyFactory in project vcell by virtualcell.
the class ServerManageConsole method main.
/**
* main entrypoint - starts the part when it is run as an application
* @param args java.lang.String[]
*/
public static void main(java.lang.String[] args) {
try {
if (args.length == 2 && args[0].equals("-password")) {
ServerManageConsole.commandLineAdminPassword = args[1];
}
PropertyLoader.loadProperties();
javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
ConnectionFactory conFactory = DatabaseService.getInstance().createConnectionFactory();
KeyFactory keyFactory = conFactory.getKeyFactory();
DatabaseServerImpl databaseServerImpl = new DatabaseServerImpl(conFactory, keyFactory);
AdminDBTopLevel adminDbTopLevel = new AdminDBTopLevel(conFactory);
ServerManageConsole aServerManageConsole = new ServerManageConsole(adminDbTopLevel, databaseServerImpl);
aServerManageConsole.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
java.awt.Insets insets = aServerManageConsole.getInsets();
aServerManageConsole.setSize(aServerManageConsole.getWidth() + insets.left + insets.right, aServerManageConsole.getHeight() + insets.top + insets.bottom);
aServerManageConsole.setLocation(200, 200);
aServerManageConsole.setVisible(true);
} catch (Throwable exception) {
System.err.println("Exception occurred in main() of javax.swing.JFrame");
exception.printStackTrace(System.out);
}
}
use of org.vcell.db.KeyFactory in project vcell by virtualcell.
the class VCellApiMain method main.
/**
* @param args
*/
public static void main(String[] args) {
try {
if (args.length != 2) {
System.out.println("usage: VCellApiMain javascriptDir port");
System.exit(1);
}
File javascriptDir = new File(args[0]);
if (!javascriptDir.isDirectory()) {
throw new RuntimeException("javascriptDir '" + args[0] + "' is not a directory");
}
// don't validate
PropertyLoader.loadProperties();
lg.debug("properties loaded");
String portString = args[1];
// was hard-coded at 8080
Integer port = null;
try {
port = Integer.parseInt(portString);
} catch (NumberFormatException e) {
e.printStackTrace();
throw new RuntimeException("failed to parse port argument '" + portString + "'", e);
}
lg.trace("connecting to database");
lg.trace("oracle factory (next)");
ConnectionFactory conFactory = DatabaseService.getInstance().createConnectionFactory();
KeyFactory keyFactory = conFactory.getKeyFactory();
lg.trace("database impl (next)");
DatabaseServerImpl databaseServerImpl = new DatabaseServerImpl(conFactory, keyFactory);
lg.trace("local db server (next)");
LocalAdminDbServer localAdminDbServer = new LocalAdminDbServer(conFactory, keyFactory);
lg.trace("admin db server (next)");
AdminDBTopLevel adminDbTopLevel = new AdminDBTopLevel(conFactory);
lg.trace("messaging service (next)");
VCMessagingService vcMessagingService = VCellServiceHelper.getInstance().loadService(VCMessagingService.class);
vcMessagingService.setDelegate(new VCMessagingDelegate() {
@Override
public void onTraceEvent(String string) {
System.out.println("Trace: " + string);
}
@Override
public void onRpcRequestSent(VCRpcRequest vcRpcRequest, UserLoginInfo userLoginInfo, VCMessage vcRpcRequestMessage) {
System.out.println("request sent:");
}
@Override
public void onRpcRequestProcessed(VCRpcRequest vcRpcRequest, VCMessage rpcVCMessage) {
System.out.println("request processed:");
}
@Override
public void onMessageSent(VCMessage message, VCDestination desintation) {
System.out.println("message sent:");
}
@Override
public void onMessageReceived(VCMessage vcMessage, VCDestination vcDestination) {
System.out.println("message received");
}
@Override
public void onException(Exception e) {
System.out.println("Exception: " + e.getMessage());
e.printStackTrace();
}
});
lg.trace("rest database service (next)");
RestDatabaseService restDatabaseService = new RestDatabaseService(databaseServerImpl, localAdminDbServer, vcMessagingService);
lg.trace("rest event service (next)");
RestEventService restEventService = new RestEventService(vcMessagingService);
lg.trace("use verifier (next)");
UserVerifier userVerifier = new UserVerifier(adminDbTopLevel);
lg.trace("mongo (next)");
VCMongoMessage.enabled = true;
VCMongoMessage.serviceStartup(ServiceName.unknown, port, args);
System.out.println("setting up server configuration");
lg.trace("register engine (next)");
Engine.register(true);
WadlComponent component = new WadlComponent();
// Server httpServer = component.getServers().add(Protocol.HTTP, 80);
// Server httpsServer = component.getServers().add(Protocol.HTTPS, 443);
// Client httpsClient = component.getClients().add(Protocol.HTTPS);
// Client httpClient = component.getClients().add(Protocol.HTTP);
lg.trace("adding FILE protcol");
@SuppressWarnings("unused") Client httpClient = component.getClients().add(Protocol.FILE);
lg.trace("adding CLAP protcol");
@SuppressWarnings("unused") Client clapClient = component.getClients().add(Protocol.CLAP);
lg.trace("adding CLAP https");
File keystorePath = new File(PropertyLoader.getRequiredProperty(PropertyLoader.vcellapiKeystoreFile));
String keystorePassword = PropertyLoader.getSecretValue(PropertyLoader.vcellapiKeystorePswd, PropertyLoader.vcellapiKeystorePswdFile);
try {
//
// keystorePassword may be encrypted with dbPassword, if it is decypt it.
//
String dbPassword = PropertyLoader.getSecretValue(PropertyLoader.dbPasswordValue, PropertyLoader.dbPasswordFile);
SecretKeyFactory kf = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
SecretKey key = kf.generateSecret(new PBEKeySpec(dbPassword.toCharArray()));
Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");
pbeCipher.init(Cipher.DECRYPT_MODE, key, new PBEParameterSpec(new byte[] { 32, 11, 55, 121, 01, 42, 89, 11 }, 20));
keystorePassword = new String(pbeCipher.doFinal(DatatypeConverter.parseBase64Binary(keystorePassword)));
} catch (Exception e) {
System.out.println("password unhashing didn't work - trying clear text password");
e.printStackTrace();
}
Server httpsServer = component.getServers().add(Protocol.HTTPS, port);
Series<Parameter> parameters = httpsServer.getContext().getParameters();
parameters.add("keystorePath", keystorePath.toString());
parameters.add("keystorePassword", keystorePassword);
parameters.add("keystoreType", "JKS");
parameters.add("keyPassword", keystorePassword);
parameters.add("disabledCipherSuites", "SSL_RSA_WITH_3DES_EDE_CBC_SHA " + "SSL_DHE_RSA_WITH_DES_CBC_SHA " + "SSL_DHE_DSS_WITH_DES_CBC_SHA");
parameters.add("enabledCipherSuites", "TLS_DHE_DSS_WITH_AES_128_CBC_SHA " + "TLS_DHE_RSA_WITH_AES_128_CBC_SHA " + "TLS_RSA_WITH_AES_128_CBC_SHA " + "TLS_DHE_DSS_WITH_AES_256_CBC_SHA " + "TLS_DHE_RSA_WITH_AES_256_CBC_SHA " + "TLS_RSA_WITH_AES_256_CBC_SHA");
lg.trace("create config");
Configuration templateConfiguration = new Configuration();
templateConfiguration.setObjectWrapper(new DefaultObjectWrapper());
lg.trace("verify python installation");
PythonSupport.verifyInstallation(new PythonPackage[] { PythonPackage.COPASI, PythonPackage.LIBSBML, PythonPackage.THRIFT });
lg.trace("start Optimization Service");
OptServerImpl optServerImpl = new OptServerImpl();
optServerImpl.start();
lg.trace("create app");
boolean bIgnoreHostProblems = true;
boolean bIgnoreCertProblems = true;
User testUser = localAdminDbServer.getUser(TEST_USER);
// lookup hashed auth credentials in database.
UserInfo testUserInfo = localAdminDbServer.getUserInfo(testUser.getID());
HealthService healthService = new HealthService(restEventService, "localhost", port, bIgnoreCertProblems, bIgnoreHostProblems, testUserInfo.userid, testUserInfo.digestedPassword0);
AdminService adminService = new AdminService(adminDbTopLevel, databaseServerImpl);
RpcService rpcService = new RpcService(vcMessagingService);
WadlApplication app = new VCellApiApplication(restDatabaseService, userVerifier, optServerImpl, rpcService, restEventService, adminService, templateConfiguration, healthService, javascriptDir);
lg.trace("attach app");
component.getDefaultHost().attach(app);
System.out.println("component start()");
lg.trace("start component");
component.start();
System.out.println("component ended.");
lg.trace("component started");
lg.trace("start VCell Health Monitoring service");
healthService.start();
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
use of org.vcell.db.KeyFactory in project vcell by virtualcell.
the class LocalVCellConnectionFactory method createVCellConnection.
/**
* This method was created in VisualAge.
* @return cbit.vcell.server.VCellConnection
*/
public VCellConnection createVCellConnection() 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);
linkHDFLib();
return vcConn;
} catch (Throwable exc) {
lg.error(exc.getMessage(), exc);
throw new ConnectionException(exc.getMessage());
}
}
use of org.vcell.db.KeyFactory in project vcell by virtualcell.
the class ResultSetCrawler method main.
public static void main(String[] args) {
ConnectionFactory conFactory = null;
try {
boolean SCAN_ONLY = true;
String singleUsername = null;
String startingUsername = null;
String outputDirName = ".";
String ampliCredName = null;
String ampliCredPassword = null;
int count = 0;
while (count < args.length) {
if (args[count].equals("-h")) {
printUsage();
System.exit(0);
} else if (args[count].equals("-u")) {
count++;
singleUsername = args[count];
} else if (args[count].equals("-c")) {
count++;
startingUsername = args[count];
} else if (args[count].equals("-o")) {
count++;
outputDirName = args[count];
} else if (args[count].equals("-d")) {
SCAN_ONLY = false;
} else if (args[count].equals("-s")) {
SCAN_ONLY = true;
} else if (args[count].equals("-y")) {
count++;
ampliCredName = args[count];
} else if (args[count].equals("-z")) {
count++;
ampliCredPassword = args[count];
} else {
System.out.println("Wrong arguments, see usage below.");
printUsage();
System.exit(1);
}
count++;
}
File outputDir = null;
if (outputDirName == null) {
outputDir = new File(".");
} else {
outputDir = new File(outputDirName);
if (!outputDir.exists()) {
throw new RuntimeException("Outuput directory doesn't exist!");
}
}
PropertyLoader.loadProperties();
File primaryDataRootDir = new File(PropertyLoader.getRequiredProperty(PropertyLoader.primarySimDataDirInternalProperty));
File secondaryDataRootDir = new File(PropertyLoader.getRequiredProperty(PropertyLoader.secondarySimDataDirInternalProperty));
if (primaryDataRootDir.equals(secondaryDataRootDir)) {
secondaryDataRootDir = null;
}
// initialize database
conFactory = DatabaseService.getInstance().createConnectionFactory();
KeyFactory keyFactory = conFactory.getKeyFactory();
AdminDBTopLevel adminDbTopLevel = new AdminDBTopLevel(conFactory);
DatabaseServerImpl dbServerImpl = new DatabaseServerImpl(conFactory, keyFactory);
//
// determine the list of users to scan
//
UserInfo[] allUserInfos = adminDbTopLevel.getUserInfos(true);
HashMap<String, User> usersToScan = new HashMap<String, User>();
for (UserInfo userInfo : allUserInfos) {
if (singleUsername != null) {
// accept only the "singleUser"
if (userInfo.userid.equals(singleUsername)) {
usersToScan.put(userInfo.userid, new User(userInfo.userid, userInfo.id));
break;
}
} else if (startingUsername != null) {
// accept all users starting with the "startingUser"
if (userInfo.userid.compareToIgnoreCase(startingUsername) >= 0) {
usersToScan.put(userInfo.userid, new User(userInfo.userid, userInfo.id));
}
} else {
// all users
usersToScan.put(userInfo.userid, new User(userInfo.userid, userInfo.id));
}
}
//
// get list of directories to scan (for selected users on both user data directories)
//
List<File> useDirectoriesToScan = getDirectoriesToScan(usersToScan, primaryDataRootDir, secondaryDataRootDir);
for (File userDir : useDirectoriesToScan) {
try {
if (lg.isTraceEnabled())
lg.trace("USER: " + userDir.getName());
User user = usersToScan.get(userDir.getName());
// find all the user simulations and external data sets (field data)
SimulationInfo[] simulationInfos = dbServerImpl.getSimulationInfos(user, false);
ExternalDataIdentifier[] extDataIDArr = adminDbTopLevel.getExternalDataIdentifiers(user, true);
// scan this user directory
scanUserDirectory(userDir, extDataIDArr, simulationInfos, outputDir, SCAN_ONLY, (ampliCredName == null || ampliCredPassword == null ? null : new AmplistorUtils.AmplistorCredential(ampliCredName, ampliCredPassword)));
} catch (Exception ex) {
lg.error(ex.getMessage(), ex);
}
}
} catch (Exception ex) {
ex.printStackTrace(System.out);
} finally {
try {
if (conFactory != null) {
conFactory.close();
}
} catch (Throwable ex) {
ex.printStackTrace();
}
System.exit(0);
}
}
Aggregations