Skip to content

Commit 3cdfc0c

Browse files
committed
Initial work on libpasta java port.
0 parents  commit 3cdfc0c

File tree

7 files changed

+145
-0
lines changed

7 files changed

+145
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "pasta-bindings"]
2+
path = pasta-bindings
3+
url = https://github.com/libpasta/pasta-bindings/

pasta-bindings

Submodule pasta-bindings added at 22a50c5

pom.xml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>io.github.libpasta</groupId>
5+
<artifactId>libpasta-java</artifactId>
6+
<packaging>jar</packaging>
7+
<version>0.0.4</version>
8+
<name>libpasta-java</name>
9+
<url>https://libpasta.github.io/</url>
10+
<dependencies>
11+
<dependency>
12+
<groupId>junit</groupId>
13+
<artifactId>junit</artifactId>
14+
<version>3.8.1</version>
15+
<scope>test</scope>
16+
</dependency>
17+
<dependency>
18+
<groupId>org.scijava</groupId>
19+
<artifactId>native-lib-loader</artifactId>
20+
<version>2.2.0</version>
21+
</dependency>
22+
</dependencies>
23+
24+
<build>
25+
<plugins>
26+
<!-- any other plugins -->
27+
<plugin>
28+
<artifactId>maven-assembly-plugin</artifactId>
29+
<executions>
30+
<execution>
31+
<phase>package</phase>
32+
<goals>
33+
<goal>single</goal>
34+
</goals>
35+
</execution>
36+
</executions>
37+
<configuration>
38+
<descriptorRefs>
39+
<descriptorRef>jar-with-dependencies</descriptorRef>
40+
</descriptorRefs>
41+
</configuration>
42+
</plugin>
43+
</plugins>
44+
</build>
45+
</project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* ----------------------------------------------------------------------------
2+
* This file was automatically generated by SWIG (http://www.swig.org).
3+
* Version 3.0.12
4+
*
5+
* Do not make changes to this file unless you know what you are doing--modify
6+
* the SWIG interface file instead.
7+
* ----------------------------------------------------------------------------- */
8+
package io.github.libpasta;
9+
10+
public class pasta {
11+
public static String hash_password(String password) {
12+
return pastaJNI.hash_password(password);
13+
}
14+
15+
public static boolean verify_password(String hash, String password) {
16+
return pastaJNI.verify_password(hash, password);
17+
}
18+
19+
public static void free_string(String arg0) {
20+
pastaJNI.free_string(arg0);
21+
}
22+
23+
public static String read_password(String prompt) {
24+
return pastaJNI.read_password(prompt);
25+
}
26+
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* ----------------------------------------------------------------------------
2+
* This file was automatically generated by SWIG (http://www.swig.org).
3+
* Version 3.0.12
4+
*
5+
* Do not make changes to this file unless you know what you are doing--modify
6+
* the SWIG interface file instead.
7+
* ----------------------------------------------------------------------------- */
8+
package io.github.libpasta;
9+
10+
import org.scijava.nativelib.*;
11+
12+
public class pastaJNI {
13+
14+
static {
15+
try {
16+
NativeLibraryUtil.loadNativeLibrary(pastaJNI.class, "pasta_jni");
17+
} catch (Exception e) {
18+
System.err.println("Native code library failed to load. \n" + e);
19+
System.exit(1);
20+
}
21+
}
22+
23+
public final static native String hash_password(String jarg1);
24+
public final static native boolean verify_password(String jarg1, String jarg2);
25+
public final static native void free_string(String jarg1);
26+
public final static native String read_password(String jarg1);
27+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package io.github.libpasta;
2+
3+
import junit.framework.Test;
4+
import junit.framework.TestCase;
5+
import junit.framework.TestSuite;
6+
7+
/**
8+
* Unit test for simple App.
9+
*/
10+
public class AppTest
11+
extends TestCase
12+
{
13+
/**
14+
* Create the test case
15+
*
16+
* @param testName name of the test case
17+
*/
18+
public AppTest( String testName )
19+
{
20+
super( testName );
21+
}
22+
23+
/**
24+
* @return the suite of tests being tested
25+
*/
26+
public static Test suite()
27+
{
28+
return new TestSuite( AppTest.class );
29+
}
30+
31+
/**
32+
* Rigourous Test :-)
33+
*/
34+
public void testApp()
35+
{
36+
// assertTrue( true );
37+
String hash = pasta.hash_password("hello123");
38+
assert pasta.verify_password(hash, "hello123");
39+
System.out.println((char)27 + "[1;32mJava test passed." + (char)27 + "[m");
40+
}
41+
}

0 commit comments

Comments
 (0)