Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions examples/java/src/main/java/ee/ria/cdoc/CDocTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,7 @@ static void locks(String path) {

static void test() {
System.err.println("Testing label generation");
String label = Recipient.buildLabel(new String[] {"Alpha", "1", "Beta", "2", "Gamma", "3", "Delta"});
System.err.format("Label: %s\n", label);
String label = "data:v=1&type=ID-card&serial_number=PNOEE-38001085718&cn=J%C3%95EORG%2CJAAK-KRISTJAN%2C38001085718";
java.util.Map<String,String> map = Recipient.parseLabel(label);
for (String key : map.keySet()) {
System.err.format(" %s:%s\n", key, map.get(key));
Expand Down
40 changes: 39 additions & 1 deletion libcdoc.i
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
// CDocReader
//

// Custom wrapper do away with const qualifiers
// Custom wrapper to do away with const qualifiers
%extend libcdoc::CDocReader {
std::vector<libcdoc::Lock> getLocks() {
const std::vector<libcdoc::Lock> &locks = $self->getLocks();
Expand Down Expand Up @@ -505,7 +505,14 @@ static std::vector<unsigned char> SWIG_JavaArrayToVectorUnsignedChar(JNIEnv *jen
%typemap(javadirectorin) std::string_view "$jniinput"
// No return of std::string_view so no javadirectorout

// CDocReader

%typemap(javacode) libcdoc::CDocReader %{
// Keep Java references to prevent GC deleting these prematurely
private Configuration config;
private CryptoBackend crypto;
private NetworkBackend network;

public void readFile(java.io.OutputStream ofs) throws CDocException, java.io.IOException {
byte[] buf = new byte[1024];
long result = readData(buf);
Expand All @@ -516,6 +523,37 @@ static std::vector<unsigned char> SWIG_JavaArrayToVectorUnsignedChar(JNIEnv *jen
}
%}

%typemap(javaout) libcdoc::CDocReader * libcdoc::CDocReader::createReader {
long cPtr = $jnicall;
if (cPtr == 0) return null;
CDocReader rdr = new CDocReader(cPtr, true);
// Set Java references
rdr.config = conf;
rdr.crypto = crypto;
rdr.network = network;
return rdr;
}

// CDocWriter

%typemap(javacode) libcdoc::CDocWriter %{
// Keep Java references to prevent GC deleting these prematurely
private Configuration config;
private CryptoBackend crypto;
private NetworkBackend network;
%}

%typemap(javaout) libcdoc::CDocWriter * libcdoc::CDocWriter::createWriter {
long cPtr = $jnicall;
if (cPtr == 0) return null;
CDocWriter wrtr = new CDocWriter(cPtr, true);
// Set Java references
wrtr.config = conf;
wrtr.crypto = crypto;
wrtr.network = network;
return wrtr;
}

%typemap(javacode) libcdoc::Configuration %{
public static final String KEYSERVER_SEND_URL = "KEYSERVER_SEND_URL";
public static final String KEYSERVER_FETCH_URL = "KEYSERVER_FETCH_URL";
Expand Down