Commit 7e8e57a9 authored by George Nash's avatar George Nash Committed by Rick Bell

Add oc_pki methods to Java

Change-Id: I5d9dfb4d2e8ad98bf3fd5b863750aac8e0bfd1f0
Signed-off-by: George Nash's avatarGeorge Nash <george.nash@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/29436Reviewed-by: Larry Sachs's avatarLarry Sachs <larry.j.sachs@intel.com>
Tested-by: default avatarIoTivity Jenkins <jenkins-daemon@iotivity.org>
Reviewed-by: default avatarRick Bell <richard.s.bell@intel.com>
parent 0cf03d6a
...@@ -182,6 +182,10 @@ ${OBJDIR}/swig/oc_obt_wrap.o: ${SWIG_DIR}/oc_obt_wrap.c ...@@ -182,6 +182,10 @@ ${OBJDIR}/swig/oc_obt_wrap.o: ${SWIG_DIR}/oc_obt_wrap.c
@mkdir -p ${@D} @mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -I../ -DOC_CLIENT -DOC_SERVER ${CC} -c -o $@ $< ${CFLAGS} -I../ -DOC_CLIENT -DOC_SERVER
${OBJDIR}/swig/oc_pki_wrap.o: ${SWIG_DIR}/oc_pki_wrap.c
@mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -I../ -DOC_CLIENT -DOC_SERVER
${OBJDIR}/swig/oc_storage_wrap.o: ${SWIG_DIR}/oc_storage_wrap.c ${OBJDIR}/swig/oc_storage_wrap.o: ${SWIG_DIR}/oc_storage_wrap.c
@mkdir -p ${@D} @mkdir -p ${@D}
${CC} -c -o $@ $< ${CFLAGS} -I../ -DOC_CLIENT -DOC_SERVER ${CC} -c -o $@ $< ${CFLAGS} -I../ -DOC_CLIENT -DOC_SERVER
......
...@@ -176,6 +176,7 @@ ...@@ -176,6 +176,7 @@
<ClCompile Include="..\..\..\..\swig\java_lang\oc_collection_wrap.c" /> <ClCompile Include="..\..\..\..\swig\java_lang\oc_collection_wrap.c" />
<ClCompile Include="..\..\..\..\swig\java_lang\oc_endpoint_wrap.c" /> <ClCompile Include="..\..\..\..\swig\java_lang\oc_endpoint_wrap.c" />
<ClCompile Include="..\..\..\..\swig\java_lang\oc_obt_wrap.c" /> <ClCompile Include="..\..\..\..\swig\java_lang\oc_obt_wrap.c" />
<ClCompile Include="..\..\..\..\swig\java_lang\oc_pki_wrap.c" />
<ClCompile Include="..\..\..\..\swig\java_lang\oc_rep_wrap.c" /> <ClCompile Include="..\..\..\..\swig\java_lang\oc_rep_wrap.c" />
<ClCompile Include="..\..\..\..\swig\java_lang\oc_storage_wrap.c" /> <ClCompile Include="..\..\..\..\swig\java_lang\oc_storage_wrap.c" />
<ClCompile Include="..\..\..\..\swig\java_lang\oc_uuid_wrap.c" /> <ClCompile Include="..\..\..\..\swig\java_lang\oc_uuid_wrap.c" />
......
...@@ -19,6 +19,8 @@ gcc -c -fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestand ...@@ -19,6 +19,8 @@ gcc -c -fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestand
gcc -c -fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-reorder-functions -fno-defer-pop -fno-strict-overflow -I"$JAVA_HOME/include/" -I"$JAVA_HOME/include/linux/" -I../.. -I../../include/ -I../../port/ -I../../port/linux/ -I../../util/ -I../../deps/tinycbor/src/ -Wall -Wextra -Werror -pedantic -D__OC_RANDOM -DOC_CLIENT -DOC_SERVER -DOC_IPV4 -DOC_DYNAMIC_ALLOCATION -DOC_DEBUG -DOC_SECURITY -g -O0 -Wno-unused-parameter -Wno-strict-aliasing -Wno-unused-function -Wno-unused-variable -Wno-sign-compare -Wno-address oc_endpoint_wrap.c -o ./obj/oc_endpoint_wrap.o gcc -c -fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-reorder-functions -fno-defer-pop -fno-strict-overflow -I"$JAVA_HOME/include/" -I"$JAVA_HOME/include/linux/" -I../.. -I../../include/ -I../../port/ -I../../port/linux/ -I../../util/ -I../../deps/tinycbor/src/ -Wall -Wextra -Werror -pedantic -D__OC_RANDOM -DOC_CLIENT -DOC_SERVER -DOC_IPV4 -DOC_DYNAMIC_ALLOCATION -DOC_DEBUG -DOC_SECURITY -g -O0 -Wno-unused-parameter -Wno-strict-aliasing -Wno-unused-function -Wno-unused-variable -Wno-sign-compare -Wno-address oc_endpoint_wrap.c -o ./obj/oc_endpoint_wrap.o
gcc -c -fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-reorder-functions -fno-defer-pop -fno-strict-overflow -I"$JAVA_HOME/include/" -I"$JAVA_HOME/include/linux/" -I../.. -I../../include/ -I../../port/ -I../../port/linux/ -I../../util/ -I../../deps/tinycbor/src/ -Wall -Wextra -Werror -pedantic -D__OC_RANDOM -DOC_CLIENT -DOC_SERVER -DOC_IPV4 -DOC_DYNAMIC_ALLOCATION -DOC_DEBUG -DOC_SECURITY -g -O0 -Wno-unused-parameter -Wno-strict-aliasing -Wno-unused-function -Wno-unused-variable -Wno-sign-compare -Wno-address oc_pki_wrap.c -o ./obj/oc_pki_wrap.o
gcc -c -fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-reorder-functions -fno-defer-pop -fno-strict-overflow -I"$JAVA_HOME/include/" -I"$JAVA_HOME/include/linux/" -I../.. -I../../include/ -I../../port/ -I../../port/linux/ -I../../util/ -I../../deps/tinycbor/src/ -Wall -Wextra -Werror -pedantic -D__OC_RANDOM -DOC_CLIENT -DOC_SERVER -DOC_IPV4 -DOC_DYNAMIC_ALLOCATION -DOC_DEBUG -DOC_SECURITY -g -O0 -Wno-unused-parameter -Wno-strict-aliasing -Wno-unused-function -Wno-unused-variable -Wno-sign-compare -Wno-address oc_rep_wrap.c -o ./obj/oc_rep_wrap.o gcc -c -fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-reorder-functions -fno-defer-pop -fno-strict-overflow -I"$JAVA_HOME/include/" -I"$JAVA_HOME/include/linux/" -I../.. -I../../include/ -I../../port/ -I../../port/linux/ -I../../util/ -I../../deps/tinycbor/src/ -Wall -Wextra -Werror -pedantic -D__OC_RANDOM -DOC_CLIENT -DOC_SERVER -DOC_IPV4 -DOC_DYNAMIC_ALLOCATION -DOC_DEBUG -DOC_SECURITY -g -O0 -Wno-unused-parameter -Wno-strict-aliasing -Wno-unused-function -Wno-unused-variable -Wno-sign-compare -Wno-address oc_rep_wrap.c -o ./obj/oc_rep_wrap.o
gcc -c -fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-reorder-functions -fno-defer-pop -fno-strict-overflow -I"$JAVA_HOME/include/" -I"$JAVA_HOME/include/linux/" -I../.. -I../../include/ -I../../port/ -I../../port/linux/ -I../../util/ -I../../deps/tinycbor/src/ -Wall -Wextra -Werror -pedantic -D__OC_RANDOM -DOC_CLIENT -DOC_SERVER -DOC_IPV4 -DOC_DYNAMIC_ALLOCATION -DOC_DEBUG -DOC_SECURITY -g -O0 -Wno-unused-parameter -Wno-strict-aliasing -Wno-unused-function -Wno-sign-compare -Wno-address -Wno-unused-variable oc_uuid_wrap.c -o ./obj/oc_uuid_wrap.o gcc -c -fPIC -fno-asynchronous-unwind-tables -fno-omit-frame-pointer -ffreestanding -Os -fno-stack-protector -ffunction-sections -fdata-sections -fno-reorder-functions -fno-defer-pop -fno-strict-overflow -I"$JAVA_HOME/include/" -I"$JAVA_HOME/include/linux/" -I../.. -I../../include/ -I../../port/ -I../../port/linux/ -I../../util/ -I../../deps/tinycbor/src/ -Wall -Wextra -Werror -pedantic -D__OC_RANDOM -DOC_CLIENT -DOC_SERVER -DOC_IPV4 -DOC_DYNAMIC_ALLOCATION -DOC_DEBUG -DOC_SECURITY -g -O0 -Wno-unused-parameter -Wno-strict-aliasing -Wno-unused-function -Wno-sign-compare -Wno-address -Wno-unused-variable oc_uuid_wrap.c -o ./obj/oc_uuid_wrap.o
......
...@@ -13,6 +13,8 @@ swig -java -package org.iotivity -outcurrentdir -outdir ../iotivity-lite-java/sr ...@@ -13,6 +13,8 @@ swig -java -package org.iotivity -outcurrentdir -outdir ../iotivity-lite-java/sr
swig -java -package org.iotivity -outcurrentdir -outdir ../iotivity-lite-java/src/org/iotivity/ -I../../include/ ../swig_interfaces/oc_endpoint.i swig -java -package org.iotivity -outcurrentdir -outdir ../iotivity-lite-java/src/org/iotivity/ -I../../include/ ../swig_interfaces/oc_endpoint.i
swig -java -package org.iotivity -outcurrentdir -outdir ../iotivity-lite-java/src/org/iotivity/ -I../../include/ ../swig_interfaces/oc_pki.i
swig -java -package org.iotivity -outcurrentdir -outdir ../iotivity-lite-java/src/org/iotivity/ -I../../include/ ../swig_interfaces/oc_rep.i swig -java -package org.iotivity -outcurrentdir -outdir ../iotivity-lite-java/src/org/iotivity/ -I../../include/ ../swig_interfaces/oc_rep.i
if [ "$#" -ge 1 ] && [ "$1" = "linux" ] if [ "$#" -ge 1 ] && [ "$1" = "linux" ]
......
package org.iotivity;
public class OCSpTypesMask {
public static final int BASELINE = 1 << 1;
public static final int BLACK = 1 << 2;
public static final int BLUE = 1 << 3;
public static final int PURPLE = 1 << 4;
}
\ No newline at end of file
...@@ -79,6 +79,14 @@ ...@@ -79,6 +79,14 @@
%typemap(jstype) oc_ace_permissions_t "int"; %typemap(jstype) oc_ace_permissions_t "int";
%typemap(javain) oc_ace_permissions_t "$javainput" %typemap(javain) oc_ace_permissions_t "$javainput"
%typemap(javaout) oc_ace_permissions_t { return $jnicall; } %typemap(javaout) oc_ace_permissions_t { return $jnicall; }
%typemap(in) oc_sp_types_t "$1 = (oc_sp_types_t)$input;"
%typemap(out) oc_sp_types_t "$result = (jint)$1;"
%typemap(jni) oc_sp_types_t "jint";
%typemap(jtype) oc_sp_types_t "int";
%typemap(jstype) oc_sp_types_t "int";
%typemap(javain) oc_sp_types_t "$javainput"
%typemap(javaout) oc_sp_types_t { return $jnicall; }
/******************************************************************** /********************************************************************
* oc_string_t input param - treat as String * oc_string_t input param - treat as String
********************************************************************/ ********************************************************************/
...@@ -292,3 +300,20 @@ ...@@ -292,3 +300,20 @@
%typemap(javaout) oc_string_array_t { %typemap(javaout) oc_string_array_t {
return $jnicall; return $jnicall;
} }
/********************************************************************
* map unsigned char*. size_t to byte[]
* use the swig apply key word to use.
* example:
* %apply (const unsigned char * BYTE, size_t LENGTH) { (const unsigned char *value, size_t length) };
********************************************************************/
%typemap(in) (const unsigned char * BYTE, size_t LENGTH) {
/* Functions from jni.h */
$1 = (unsigned char *) JCALL2(GetByteArrayElements, jenv, $input, 0);
$2 = (size_t) JCALL1(GetArrayLength, jenv, $input);
}
%typemap(jni) (const unsigned char * BYTE, size_t LENGTH) "jbyteArray"
%typemap(jtype) (const unsigned char * BYTE, size_t LENGTH) "byte[]"
%typemap(jstype) (const unsigned char * BYTE, size_t LENGTH) "byte[]"
%typemap(javain) (const unsigned char * BYTE, size_t LENGTH) "$javainput"
\ No newline at end of file
/* File oc_pki.i */
%module OCPki
%include "stdint.i"
%include "iotivity.swg"
%import "oc_uuid.i"
%pragma(java) jniclasscode=%{
static {
try {
System.loadLibrary("iotivity-lite-jni");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. \n" + e);
System.exit(1);
}
}
%}
%{
#include "oc_pki.h"
%}
%rename (OCSpTypesMask) oc_sp_types_t;
typedef enum {
OC_SP_BASELINE = 1 << 1,
OC_SP_BLACK = 1 << 2,
OC_SP_BLUE = 1 << 3,
OC_SP_PURPLE = 1 << 4
} oc_sp_types_t;
%apply (const unsigned char * BYTE, size_t LENGTH) { (const unsigned char *cert, size_t cert_size) };
%apply (const unsigned char * BYTE, size_t LENGTH) { (const unsigned char *key, size_t key_size) };
%rename (addMfgCert) oc_pki_add_mfg_cert;
%rename (addMfgIntermediateCert) oc_pki_add_mfg_intermediate_cert;
%rename (addMfgTrustAnchor) oc_pki_add_mfg_trust_anchor;
%rename (addTrustAnchor) oc_pki_add_trust_anchor;
%rename (setSecurityProfile) oc_pki_set_security_profile;
%include "oc_pki.h"
\ No newline at end of file
...@@ -132,16 +132,6 @@ void jni_rep_set_text_string(CborEncoder * object, const char* key, const char* ...@@ -132,16 +132,6 @@ void jni_rep_set_text_string(CborEncoder * object, const char* key, const char*
} }
%} %}
%typemap(in) (const unsigned char * BYTE, size_t LENGTH) {
/* Functions from jni.h */
$1 = (unsigned char *) JCALL2(GetByteArrayElements, jenv, $input, 0);
$2 = (size_t) JCALL1(GetArrayLength, jenv, $input);
}
%typemap(jni) (const unsigned char * BYTE, size_t LENGTH) "jbyteArray"
%typemap(jtype) (const unsigned char * BYTE, size_t LENGTH) "byte[]"
%typemap(jstype) (const unsigned char * BYTE, size_t LENGTH) "byte[]"
%typemap(javain) (const unsigned char * BYTE, size_t LENGTH) "$javainput"
/* Specify signature of method to handle */ /* Specify signature of method to handle */
%apply (const unsigned char * BYTE, size_t LENGTH) { (const unsigned char *value, size_t length) }; %apply (const unsigned char * BYTE, size_t LENGTH) { (const unsigned char *value, size_t length) };
%rename (setByteString) jni_rep_set_byte_string; %rename (setByteString) jni_rep_set_byte_string;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment