diff --git a/bindings/java/ivy.xml b/bindings/java/ivy.xml index aa176eb81309de0d79359b545ed231c74b9ca535..346f0b45258ee95a5f2437eb8345f211bd622bfa 100644 --- a/bindings/java/ivy.xml +++ b/bindings/java/ivy.xml @@ -1,11 +1,14 @@ <ivy-module version="2.0"> - <info organisation="org.sleuthkit" module="datamodel"/> - <dependencies> + <info organisation="org.sleuthkit" module="datamodel"/> + <dependencies> <dependency org="junit" name="junit" rev="4.8.2"/> <dependency org="com.googlecode.java-diff-utils" name="diffutils" rev="1.2.1"/> <dependency org="org.xerial" name="sqlite-jdbc" rev="3.7.15-M1" > <artifact name="sqlite-jdbc" type="jar" /> </dependency> - </dependencies> + <dependency org="org.postgresql" name="postgresql" rev="9.4-1201-jdbc41" > + <artifact name="postgresql" type="jar" /> + </dependency> + </dependencies> </ivy-module> diff --git a/bindings/java/nbproject/project.xml b/bindings/java/nbproject/project.xml index 28547940761d03c42bd0f4bc0250e5dc012ef42e..a117606b0a0de183f07c908b3f1ad455b77cd7e8 100755 --- a/bindings/java/nbproject/project.xml +++ b/bindings/java/nbproject/project.xml @@ -114,7 +114,7 @@ <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/3"> <compilation-unit> <package-root>src</package-root> - <classpath mode="compile">lib;lib/diffutils-1.2.1.jar;lib/junit-4.8.2.jar;lib/sqlite-jdbc-3.7.15-M1.jar</classpath> + <classpath mode="compile">lib;lib/diffutils-1.2.1.jar;lib/junit-4.8.2.jar;lib/sqlite-jdbc-3.7.15-M1.jar;lib/postgresql-9.4-1201.jdbc41.jar</classpath> <built-to>build</built-to> <source-level>1.6</source-level> </compilation-unit> diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java index 56076163a7064fee321f621a4db569f3ea6d9c9f..9065b5c83fc827affdc1291ca84f5198cf427fe6 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java @@ -547,13 +547,13 @@ public static SleuthkitCase openCase(String dbPath) throws TskCoreException { * @throws org.sleuthkit.datamodel.TskCoreException */ public static SleuthkitCase openCase(String databaseName, CaseDbConnectionInfo info) throws TskCoreException { - /// KDM new case here... handle both + /// KDM TODO /* - final SleuthkitJNI.CaseDbHandle caseHandle = SleuthkitJNI.openCaseDb(dbPath); + final SleuthkitJNI.CaseDbHandle caseHandle = SleuthkitJNI.openCaseRemoteDb(databaseName, info); try { return new SleuthkitCase(dbPath, caseHandle); } catch (Exception ex) { - throw new TskCoreException("Failed to open case database at " + dbPath, ex); + throw new TskCoreException("Failed to open case database " + databaseName, ex); } */ return null; @@ -585,13 +585,13 @@ public static SleuthkitCase newCase(String dbPath) throws TskCoreException { * @throws org.sleuthkit.datamodel.TskCoreException */ public static SleuthkitCase newCase(String databaseName, CaseDbConnectionInfo info) throws TskCoreException { - /// KDM new case here... handle both - /* - SleuthkitJNI.CaseDbHandle caseHandle = SleuthkitJNI.newCaseDb(dbPath); + /* KDM TODO + SleuthkitJNI.CaseDbHandle caseHandle = SleuthkitJNI.newCaseRemoteDb(databaseName, info); try { - return new SleuthkitCase(dbPath, caseHandle); + return new SleuthkitCase(info.getHost(), Integer.parseInt(info.getPort()), + databaseName, info.getUserName(), info.getPassword(), caseHandle, null); /// KDM last argument (caseDirPath) doesn't make much sense in this context. fix it. } catch (Exception ex) { - throw new TskCoreException("Failed to create case database at " + dbPath, ex); + throw new TskCoreException("Failed to create case database " + databaseName, ex); } */ return null; @@ -5626,4 +5626,17 @@ public void close() throws TskCoreException { } } } + + public static boolean settingsValid(CaseDbConnectionInfo info) { + // Check if we can talk to the database + try { + Connection conn = DriverManager.getConnection("jdbc:postgresql://"+ + info.getHost()+":"+info.getPort()+"/postgres", + info.getUserName(), + info.getPassword()); // NON-NLS + } catch (Exception ex) { + return false; + } + return true; + } }