Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
bb9feca
update C build system to simplify the process of building on Debian-d…
eighthave Aug 14, 2012
0ea8efa
rename everything to gnupg-for-java to keep the name consistent throu…
eighthave Aug 14, 2012
4830b16
convert to very plain JNI loading using System.loadLibrary() and JNI_…
eighthave Aug 15, 2012
0f5f21d
use the libgnupg-for-java.so in place when running the tests
eighthave Aug 15, 2012
f7ddc34
ignore dist/ and hs_err_pid*.log
eighthave Aug 15, 2012
c76f44b
use a standard ant dir structure for JNI stuff: jni/ for source, buil…
eighthave Aug 15, 2012
1fca8e5
move .java files straight into src/
eighthave Aug 15, 2012
56d2ea0
moved test class into src/ to be built like a regular Java class
eighthave Aug 15, 2012
830244f
clean up libgnupg-for-java.so build to reflect new layouts and have w…
eighthave Aug 15, 2012
8169041
make sure the $HOME dir for the tests exists and is empty before runn…
eighthave Aug 15, 2012
e4a94d8
call gpgme_check_version() in JNI_OnLoad() since it seems to set up r…
eighthave Aug 15, 2012
c5d82ac
fix Java warnings in com/freiheit/gnupg
eighthave Aug 9, 2012
eed4bae
jni: LC_MESSAGES might not be defined on WIN32 or other platforms
eighthave Oct 23, 2012
8a1bacb
gpgme needs LD_LIBRARY_PATH set since it launches cmd line progs like…
eighthave Oct 23, 2012
33d480f
only use LD_LIBRARY_PATH code on Android
eighthave Oct 23, 2012
91aed13
fix the listkeys feature of the gpgme library
eighthave Mar 13, 2014
694cb36
gnupg-for-java: expose all booleans in gpgme_key_t as Java methods
eighthave May 24, 2013
2148509
remove unneeded autogenerated JNI headers
eighthave May 24, 2013
f90f6cf
gnupg-for-java: add GnuPGKey.hasSecretKey() to report if any subkey i…
eighthave May 24, 2013
0c208a3
gnupg-for-java: fix compiler warnings
eighthave May 24, 2013
4afc03e
gnupg-for-java: also allow fetching secret keys using GnuPGKey contru…
eighthave May 24, 2013
cbfe16a
allow fetching secret keys using GnuPGContext.getKeyByFingerprint()
eighthave May 24, 2013
05e35c7
add listSecretKeys() and searchSecretKeys() to GnuPGContext
eighthave May 24, 2013
eb3d094
simplify and complete get/set for Armor and TextMode
eighthave May 25, 2013
1c912a1
add GnuPGData.size() to improve ByteArrayOutputStream performance
eighthave May 25, 2013
a163416
add javaish encryption methods
eighthave May 25, 2013
07d843f
sync up trivial changes from gnupg-for-android
eighthave Mar 13, 2014
0d51265
include signature notations in key lists
eighthave May 25, 2013
f17ef6e
put gnupg libs first in LD_LIBRARY_PATH to make sure we get the right…
eighthave May 31, 2013
1f88566
standardize layout of public method declarations for clarity
eighthave Jun 5, 2013
8b7c761
fix gpgmeOpEncryptSign method signature in Java
eighthave Jun 5, 2013
351d29d
implement getSigner() and getSignersLength()
eighthave Jun 5, 2013
473e0c6
add encryptAndSign method to force signing with encryption
eighthave Jun 5, 2013
f0478e2
make encrypt() do signing if GnuPGContext has signers added
eighthave Jun 5, 2013
987e168
add simple method for generating a new PGP key
eighthave Jun 13, 2013
69b4153
implement key importing from a file in gnupg-for-java
abeluck Jun 14, 2013
1fe5bf8
disable gpgme passphraseListener, use pinentry on gpg 2.x
eighthave Jun 15, 2013
7f84208
use POSIX FILE streams when creating GnuPGData for files
eighthave Jul 12, 2013
8419673
expose gpgmeOpDecryptVerify as a proper Java method
eighthave Jul 16, 2013
52f19f7
reduce the keylist return to the bare minimum for speed
eighthave Jul 19, 2013
4d85b13
purge emacs code format comment, use the emacs 'java' mode
eighthave Jul 29, 2013
29ac346
ran Eclipse code formatter in Android mode on *.java
eighthave Jul 29, 2013
57a073a
add simple, java-ish decrypt methods
eighthave Jun 5, 2013
eed6e15
fix crash when get sigs on a key when none are returned
eighthave Aug 13, 2013
5a11f75
format JNI C code with astyle. styled included in documentation
abeluck Dec 3, 2013
174f611
POSIX setenv() to change app's env vars, which GnuPG requires
eighthave Dec 7, 2013
59d4f53
add changePassphrase() and purge old non-functional code
eighthave Dec 11, 2013
f8bd42f
replace crazy loops with linked list when building keylists
eighthave Dec 13, 2013
2a60215
purge dead passphrase code
eighthave Jan 17, 2014
3d4d40f
ignore generated JNI headers
eighthave Mar 14, 2014
b24e3b5
add Eclipse project to make it easier to get started
eighthave Mar 14, 2014
35140b0
purge Android-specific logging code
eighthave Mar 14, 2014
09bc751
add jar path to runTests.sh
eighthave Mar 14, 2014
dd23cc1
purge unused variables
eighthave Mar 14, 2014
0cb77d5
include gpgme source for context.h
eighthave Mar 14, 2014
2af3b04
remove variable that is never accessed/read and enable that warning
eighthave Mar 14, 2014
dcf4e83
purge last remnant of old GnuPG 1.4 passphrase handling
eighthave Mar 14, 2014
7e0a74c
run Eclipse Android-mode code formatter GnuPGTestSuite.java
eighthave Mar 14, 2014
7a00a5c
updated README
eighthave Mar 14, 2014
b0b1177
run gpgme_check_version() in JNI_OnLoad to init thread support
eighthave Mar 14, 2014
a4d5518
fix javadoc build to make plain javadoc style
eighthave Mar 16, 2014
34aec60
add Guardian Project logo and name to javadoc
eighthave Mar 17, 2014
c4a488a
fix all javadoc warnings and some related improvements
eighthave Mar 17, 2014
727ef48
generate etags with 'make TAGS'
eighthave Mar 17, 2014
a74d932
replace hack using private header with public gpgme_signers_count()
eighthave Mar 17, 2014
1aa5368
include data.h from gpgme 1.4.3
eighthave Mar 17, 2014
7524483
update build version to 0.2-pre
eighthave Mar 17, 2014
9a9ae7a
make JNI headers are optional
eighthave Mar 17, 2014
c70a921
quick documentation of build process
eighthave Mar 17, 2014
524512a
cleaner way include gpgme's data.h locally
eighthave Mar 18, 2014
6082563
ignore .class files
eighthave Mar 21, 2014
06522d5
add run script to examples/
eighthave Mar 21, 2014
b1a18bb
purge unneeded C test code
eighthave Mar 21, 2014
f15d15c
include a bunch of relevant files to test with
eighthave Mar 21, 2014
434369d
move format-code.sh to jni/ since it is only used there
eighthave Mar 21, 2014
7ac81bb
fix tests in Eclipse: set path to libgnupg-for-java.so
eighthave Mar 21, 2014
9e54a17
update format-code.sh to get closest to current style
eighthave Mar 21, 2014
cf92f88
reformat all .c and .h files with updated format-code.sh
eighthave Mar 21, 2014
d4b23c3
including emacs formatting commands at end of every code file
eighthave Mar 21, 2014
de1fb1a
update JNI build for GNU/Linux, Windows, and a partial Mac OS X
eighthave Mar 25, 2014
d69a6bb
generate and build against JNI headers so definitions match
eighthave Mar 25, 2014
5cce7a1
clean up naming in build system
eighthave Mar 25, 2014
a0913cf
clean up build system to use variables and run the test suite
eighthave Mar 25, 2014
763134f
include JUnit from Eclipse and set the location of the native libs
eighthave Mar 25, 2014
2e6e0e5
print error if calling make directly, make should be called by ant
eighthave Mar 25, 2014
05f74c7
remove unused headers
eighthave Mar 25, 2014
ac0cb87
set required gpgme version to 1.5.0
eighthave Jul 30, 2014
90fb745
Simple Maven script
daniele-athome Dec 12, 2014
79ed829
Implement GnuPGKey.getTimestamp
daniele-athome Nov 3, 2014
f5b4d5b
Remove debugging log
daniele-athome Jan 23, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="examples"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="gnupg-for-java/build"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.class
build/
dist/
hs_err_pid*.log
jni/*.o
jni/*.orig
jni/TAGS
# generated JNI headers
jni/com_freiheit_gnupg_GnuPG*.h
lib/libgnupg-for-java.so

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

target/
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>gnupg-for-java</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
73 changes: 64 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,71 @@
About GnuPG for Java
=======================
GnuPG for Java
==============

This is a lib I wrote a couple of years ago. It is a native binding to the
gpgme library from Werner Koch. It uses JNI.
GnuPG for Java is a Java wrapper for the gpgme (GnuPG Made Easy) library for
working with the GnuPG encryption suite. It is a native binding to the gpgme
using JNI. It requires gpgme 1.4.3 or newer, and expects to work with GnuPG
2.x as the "engine" in gpgme. With GnuPG 2.x, gpg-agent will handle prompting
the user for the passphrase, as well as passphrase caching.

gpgpme is the standard library for developing third-party apps on top of GnuPG.

I wrote it for 32-Bit Intel GNU/Linux platforms. Some of my colleagues added
64-Bit Intel GNU/Linux support. It should run on other Unix-platforms, too. But
this is not tested. Also I am not aware if it runs with the current version
of gpgme. It should be easy to add Windows support by compiling a DLL, adding
this to the jar and extend the loading mechanism to load a DLL on a Windows platform
Stefan Richter originally wrote it for 32-Bit Intel GNU/Linux platforms. Some
of his colleagues added 64-Bit Intel GNU/Linux support. It should build and
run on other UNIX platforms too, but that has not been tested. The Guardian
Project then ported it to GnuPG 2.x and Android as the basis of Gnu Privacy
Guard for Android, and added lots of features and fixed lots of bugs in the
process.

It should be easy to add Windows support by compiling a DLL, adding this to
the jar and extend the loading mechanism to load a DLL on a Windows platform
instead of loading a .so lib.


## Setup for Building

You will need a JUnit jar to run the tests. If your system does not provide
one already, you can download the jar and put it into the build/ directory of
this project.

### Debian/Ubuntu/Mint/etc

sudo apt-get install default-jdk make ant build-essential \
libgpgme11-dev libgpg-error-dev


### Windows

* Install MinGW (for 32-bit): http://mingw.org/
* Install Gpg4win: http://gpg4win.org/download.html
** Signing Key Fingerprint: `61AC 3F5E E4BE 593C 13D6 8B1E 7CBD 620B EC70 B1B8`


### Mac OS X

You need to install GnuPG2 from one of a couple sources. You can get
it from Homebrew, MacPorts, or Fink. Or you can install
"GPGTools":https://gpgtools.org and then build gpgme from source.


## Building

To build the `gnupg-for-java.jar` and `libgnupg-for-java.so` in build/, run
this:

ant clean release

You can run the test suite using `ant` also:

ant test

If you want the optional javadoc in build/docs/, run:

ant javadoc


## Hacking Notes

Please conform to our code format standard. For C files use
./format-code.sh. For Java files, use Eclipse with the Android mode from the
Android project. The default Eclipse formatting is usually close enough.

18 changes: 3 additions & 15 deletions build.properties
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
# default build.properties

app.name=javagnupg
app.type=@APP-TYPE@
app.version=0.1.5-ascii-armor-linux-i386-ia64
app.name=gnupg-for-java
app.version=0.2-pre
app.customer=LGPL
app.vendor=freiheit.com technologies gmbh
app.year=2008

lib=./lib
app.year=2014

build.compiler=modern
compile.debug=true
compile.deprecation=false
compile.optimize=true

#where to put the source code
src=src

#where to put the generated class files
build=build

#where to put the generated class files
dist=dist

#where to put etc stuff :-)
etc=etc
91 changes: 43 additions & 48 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,105 +1,100 @@
<project name="javagnupg" default="full-jar" basedir=".">
<?xml version="1.0" encoding="UTF-8"?>
<project name="gnupg-for-java" default="release" basedir=".">
<property file="build.properties"/>

<property name="build.dir" location="build" />
<property name="classes.dir" location="${build.dir}/classes" />
<property name="docs.dir" location="${build.dir}/docs" />
<property name="jarfile" value="${build.dir}/${app.name}-${app.version}.jar"/>

<target name="prepare" description="Create the necessary directories and files for the build">
<mkdir dir="${build}"/>
<mkdir dir="${dist}"/>
<mkdir dir="${build.dir}"/>
</target>

<target name="clean" depends="clean-native" description="Remove all generated dirs and files...">
<delete dir="${build}"/>
<delete dir="${dist}"/>
<delete file="${jarfile}"/>
<delete dir="${classes.dir}" includeEmptyDirs="true"/>
</target>

<target name="compile-java" depends="prepare" description="Compile the Java code for the GnuPG-Library">
<javac srcdir="${src}/java" destdir="${build}" deprecation="off" debug="on">
<src path="${src}/java"/>
</javac>
</target>

<target name="compile-tests" depends="prepare" description="Compile the JUnit test code for the GnuPG-Library">
<javac srcdir="${src}/junit" destdir="${build}" deprecation="off" debug="on">
<classpath>
<pathelement location="${lib}/junit-3.8.1.jar"/>
</classpath>
</javac>
<mkdir dir="${classes.dir}"/>
<javac srcdir="src" destdir="${classes.dir}" debug="on">
<src path="src"/>
</javac>
</target>

<target name="test" depends="gen-jni-header, compile-tests, full-jar" description="Test the library functions...">
<target name="test" depends="gen-jni-headers, release" description="Test the library functions...">
<property name="TestEnv" value="textui"/>
<!-- "textui" for text-environment
"swingui" for swing-environment
"awtui" for awt-environment -->

<delete dir="/tmp/gnupg-for-java-tests"/>
<mkdir dir="/tmp/gnupg-for-java-tests"/>
<java classname="junit.${TestEnv}.TestRunner" fork ="yes">
<classpath>
<pathelement location ="${basedir}/${dist}/${app.name}-${app.version}.jar"/>
<pathelement location="${lib}/junit-3.8.1.jar"/>
<fileset dir="${build.dir}" includes="*.jar"/>
<fileset dir="${classes.dir}"/>
</classpath>
<!--classpath refid="compile.classpath"/-->
<arg value="com.freiheit.gnupg.GnuPGTestSuite"/>
<sysproperty key="java.library.path" value="${build.dir}"/>
<arg value="com.freiheit.gnupg.tests.GnuPGTestSuite"/>
</java>
</target>


<target name="full-jar" depends="gen-jni-library" description="Use this is you want to rebuild everything">
<target name="release" depends="gen-jni-library" description="Use this is you want to rebuild everything">
<antcall target="jar"/>
</target>

<target name="jar" depends="compile-java" description="Use this, if you only want to recompile changed java code">
<copydir dest="${build}" src="${src}"/>
<delete failonerror="false" file="${build}/c/libjavagnupg.so"/>
<jar jarfile="${dist}/${app.name}-${app.version}.jar" basedir="${build}" />
<jar jarfile="${jarfile}" basedir="${classes.dir}" />
</target>

<target name="clean-native" description="calls make clean in the c/ directory">
<exec executable="make" dir="${src}/c" failonerror="false">
<arg value="-e"/>
<arg value="clean"/>
</exec>
<exec executable="make" dir="jni" failonerror="false">
<arg value="BUILD_DIR=${build.dir}"/>
<arg value="clean"/>
</exec>
</target>

<!-- I am not using the javah-target, because it must installed additionally. -->
<!-- Instead I am calling a separate GNUmakefile, that manages all C-related tasks -->

<target name="generate-jni-headers" depends="compile-java" description="Use this, if you want to generate headers without resolving dependencies automatically">
<exec executable="make" dir="${src}/c" failonerror="true">
<arg value="header"/>
<arg value="-e"/>
<exec executable="make" dir="jni" failonerror="true">
<arg value="BUILD_DIR=${build.dir}"/>
<arg value="CLASSES_DIR=${classes.dir}"/>
<arg value="headers"/>
</exec>
</target>

<target name="gen-jni-header" depends="compile-java" description="Generate the JNI C-Header Files from the Java-Classes">
<target name="gen-jni-headers" depends="compile-java" description="Generate the JNI C-Header Files from the Java-Classes">
<antcall target="generate-jni-headers"/>
</target>

<target name="recompile-c-code" description="Use this, if you just want to compile without resolving dependencies automatically">
<exec executable="make" dir="${src}/c" failonerror="true">
<exec executable="make" dir="jni" failonerror="true">
<arg value="BUILD_DIR=${build.dir}"/>
<arg value="lib"/>
<arg value="-e"/>
</exec>
</target>

<target name="gen-jni-library" depends="gen-jni-header" description="Generate the Shared Library with the JNI-Binding Code">
<target name="gen-jni-library" depends="gen-jni-headers" description="Generate the Shared Library with the JNI-Binding Code">
<antcall target="recompile-c-code"/>
</target>

<target name="javadoc" description="Create Javadoc-API documentation">
<mkdir dir="${build}/docs/api"/>
<mkdir dir="${build}/docs/images"/>
<copy todir="${build}/docs/images" file="etc/whitepaper.gif"/>
<copy todir="${build}/docs/images" file="etc/fdc.javadoc.png"/>
<mkdir dir="${docs.dir}/images"/>
<copy todir="${docs.dir}/images" file="etc/guardianproject-logo.png"/>
<copy todir="${docs.dir}/images" file="etc/fdc.javadoc.png"/>

<javadoc sourcepath="${src}/java"
destdir="${build}/docs/${app.name}-${app.version}"
<javadoc sourcepath="src"
destdir="${docs.dir}/${app.name}-${app.version}"
windowtitle="${app.name} (Version ${app.version})"
doctitle="${app.name} (Version ${app.version})"
bottom="&#169; ${app.year} ${app.vendor}"
header="freiheit.com technologies gmbh"
header="freiheit.com technologies gmbh &amp; The Guardian Project"
packagenames="com.freiheit.*"
stylesheetfile="${etc}/stylesheet.css"
overview="${etc}/overview.html">
<!--classpath refid="compile.classpath"/-->
<!--
!!! relative path for headers does NOT work !!!
header="&lt;img src='../images/fdc.javadoc.png'&gt;"
Expand All @@ -110,7 +105,7 @@
</target>

<target name="zip_javadoc" depends="javadoc" description="Create a zip-file for API-Javadoc">
<zip zipfile="${build}/${app.name}-${app.version}-javadoc.zip" basedir="${build}/docs/${app.name}-${app.version}"/>
<zip zipfile="build/${app.name}-${app.version}-javadoc.zip" basedir="${docs.dir}/${app.name}-${app.version}"/>
</target>

</project>
74 changes: 0 additions & 74 deletions c-test-code/oerks.c

This file was deleted.

Binary file added etc/guardianproject-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading