Andorid(JNI) Implementation for Cloud Provisioning.
authorRandeep Singh <randeep.s@samsung.com>
Thu, 29 Sep 2016 08:36:44 +0000 (14:06 +0530)
committerRandeep Singh <randeep.s@samsung.com>
Thu, 29 Sep 2016 12:29:06 +0000 (12:29 +0000)
Patch #1: Add JNI interface for getAclByDeviceID API.
Patch #2: Fixes.

Change-Id: I0e8b09f9f1be66d202834e56f3d535604f6a766b
Signed-off-by: Sandeep Sharma <sandeep.s9@samsung.com>
Signed-off-by: Randeep Singh <randeep.s@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11507
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Ashwini Kumar <k.ashwini@samsung.com>
(cherry picked from commit 05969521d6bab5c3c5e148b418872d21ac4d8282)
Reviewed-on: https://gerrit.iotivity.org/gerrit/12557

12 files changed:
android/android_api/base/jni/Android.mk
android/android_api/base/jni/JniGetAclIdByDeviceListener.cpp [new file with mode: 0644]
android/android_api/base/jni/JniGetAclIdByDeviceListener.h [new file with mode: 0644]
android/android_api/base/jni/JniOcCloudProvisioning.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOcCloudProvisioning.h [new file with mode: 0644]
android/android_api/base/jni/JniOcCloudResultListener.cpp [new file with mode: 0644]
android/android_api/base/jni/JniOcCloudResultListener.h [new file with mode: 0644]
android/android_api/base/jni/JniOcStack.cpp
android/android_api/base/jni/JniOcStack.h
android/android_api/base/src/main/java/org/iotivity/base/OcCloudProvisioning.java
resource/include/OCCloudProvisioning.h
resource/provisioning/src/OCCloudProvisioning.cpp

index 7039ac3..182513d 100644 (file)
@@ -47,9 +47,6 @@ include $(PREBUILT_SHARED_LIBRARY)
 endif\r
 \r
 include $(CLEAR_VARS)\r
-ifeq ($(SECURE), 1)\r
-    LOCAL_CFLAGS += -D__WITH_DTLS__\r
-endif\r
 OIC_SRC_PATH := ../../../resource\r
 LOCAL_MODULE := libca-interface\r
 LOCAL_SRC_FILES := JniCaInterface.c\r
@@ -69,14 +66,9 @@ ifeq ($(WITH_CLOUD), 1)
 endif\r
 \r
 ifeq ($(WITH_TCP), 1)\r
-    LOCAL_CPPFLAGS += -DWITH_TCP\r
     LOCAL_CPPFLAGS += -D__WITH_TLS__\r
 endif\r
 \r
-ifeq ($(SECURED), 1)\r
-    LOCAL_CPPFLAGS += -D__WITH_DTLS__\r
-endif\r
-\r
 MQ_FLAG = 0\r
 ifeq ($(WITH_MQ_PUB), 1)\r
 LOCAL_CFLAGS += -DWITH_MQ -DMQ_PUBLISHER\r
@@ -137,6 +129,13 @@ ifeq ($(WITH_CLOUD), 1)
     LOCAL_SRC_FILES +=  JniOcAccountManager.cpp\r
 endif\r
 \r
+ifeq ($(WITH_TCP), 1)\r
+    LOCAL_SRC_FILES +=  JniOcCloudProvisioning.cpp \\r
+                        JniOcCloudResultListener.cpp \\r
+                        JniGetAclIdByDeviceListener.cpp\r
+endif\r
+\r
+\r
 LOCAL_LDLIBS := -llog\r
 LOCAL_STATIC_LIBRARIES := android-oc\r
 LOCAL_STATIC_LIBRARIES += android-octbstack\r
@@ -165,9 +164,9 @@ LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../extlibs/boost/boost_1_58_0
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../extlibs/cjson\r
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../build_common/android/compatibility\r
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include\r
-LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include/cloud\r
-LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include/oxm\r
+LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include/oxm/\r
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include/internal\r
+LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include/cloud/\r
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/include\r
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/include/internal\r
 LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/connectivity/api\r
diff --git a/android/android_api/base/jni/JniGetAclIdByDeviceListener.cpp b/android/android_api/base/jni/JniGetAclIdByDeviceListener.cpp
new file mode 100644 (file)
index 0000000..c13682f
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+* //******************************************************************
+* //
+* // Copyright 2016 Samsung Electronics All Rights Reserved.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+* //
+* // Licensed under the Apache License, Version 2.0 (the "License");
+* // you may not use this file except in compliance with the License.
+* // You may obtain a copy of the License at
+* //
+* //      http://www.apache.org/licenses/LICENSE-2.0
+* //
+* // Unless required by applicable law or agreed to in writing, software
+* // distributed under the License is distributed on an "AS IS" BASIS,
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* // See the License for the specific language governing permissions and
+* // limitations under the License.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+*/
+#include "JniGetAclIdByDeviceListener.h"
+
+JniGetAclIdByDeviceListener::JniGetAclIdByDeviceListener(JNIEnv *env, jobject jListener,
+    RemoveCallback removeListener)
+{
+    m_jwListener = env->NewWeakGlobalRef(jListener);
+    m_removeGetAclbyIDListener = removeListener;
+}
+
+JniGetAclIdByDeviceListener::~JniGetAclIdByDeviceListener()
+{
+    LOGI("~JniGetAclIdByDeviceListener()");
+    if (m_jwListener)
+    {
+        jint ret = JNI_ERR;
+        JNIEnv *env = GetJNIEnv(ret);
+        if (nullptr == env)
+        {
+            return;
+        }
+        env->DeleteWeakGlobalRef(m_jwListener);
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+    }
+}
+
+void JniGetAclIdByDeviceListener::GetAclIdByDeviceListenerCB(int result, std::string aclID)
+{
+    jint ret = JNI_ERR;
+    JNIEnv *env = GetJNIEnv(ret);
+    if (nullptr == env)
+    {
+        return;
+    }
+
+    jobject jListener = env->NewLocalRef(m_jwListener);
+    if (!jListener)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+        return;
+    }
+
+    jclass clsL = env->GetObjectClass(jListener);
+
+    if (!clsL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+        return;
+    }
+
+    jmethodID midL = env->GetMethodID(clsL, "getAclIdByDeviceListener", "(ZLjava/lang/String;)V");
+    if (!midL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+        return;
+    }
+    jstring jStr = env-> NewStringUTF(aclID.c_str());
+    if (!jStr)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+        return;
+
+    }
+    env->CallVoidMethod(jListener, midL, (jboolean)result, jStr);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Java exception is thrown");
+    }
+    checkExAndRemoveListener(env);
+    if (JNI_EDETACHED == ret)
+    {
+        g_jvm->DetachCurrentThread();
+    }
+}
+
+void JniGetAclIdByDeviceListener::checkExAndRemoveListener(JNIEnv* env)
+{
+    if (env->ExceptionCheck())
+    {
+        jthrowable ex = env->ExceptionOccurred();
+        env->ExceptionClear();
+        m_removeGetAclbyIDListener(env, m_jwListener);
+        env->Throw((jthrowable)ex);
+    }
+    else
+    {
+        m_removeGetAclbyIDListener(env, m_jwListener);
+    }
+}
diff --git a/android/android_api/base/jni/JniGetAclIdByDeviceListener.h b/android/android_api/base/jni/JniGetAclIdByDeviceListener.h
new file mode 100644 (file)
index 0000000..8ad5b11
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+* //******************************************************************
+* //
+* // Copyright 2016 Samsung Electronics All Rights Reserved.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+* //
+* // Licensed under the Apache License, Version 2.0 (the "License");
+* // you may not use this file except in compliance with the License.
+* // You may obtain a copy of the License at
+* //
+* //      http://www.apache.org/licenses/LICENSE-2.0
+* //
+* // Unless required by applicable law or agreed to in writing, software
+* // distributed under the License is distributed on an "AS IS" BASIS,
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* // See the License for the specific language governing permissions and
+* // limitations under the License.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+*/
+
+#include <jni.h>
+#include "JniOcStack.h"
+
+/* Header for class org_iotivity_base_OcCloudProvisioning_GetAclIdByDeviceListener */
+#ifndef _Included_org_iotivity_base_OcCloudProvisioning_JniGetAclIdByDeviceListener
+#define _Included_org_iotivity_base_OcCloudProvisioning_JniGetAclIdByDeviceListener
+
+typedef std::function<void(JNIEnv* env, jobject jListener)> RemoveCallback;
+
+class JniGetAclIdByDeviceListener
+{
+    public:
+        JniGetAclIdByDeviceListener(JNIEnv *env, jobject jListener,
+                RemoveCallback removeListener);
+        ~JniGetAclIdByDeviceListener();
+
+        void GetAclIdByDeviceListenerCB(int result, std::string aclID);
+
+    private:
+        RemoveCallback m_removeGetAclbyIDListener;
+        jweak m_jwListener;
+        void checkExAndRemoveListener(JNIEnv* env);
+};
+#endif
diff --git a/android/android_api/base/jni/JniOcCloudProvisioning.cpp b/android/android_api/base/jni/JniOcCloudProvisioning.cpp
new file mode 100644 (file)
index 0000000..72f94de
--- /dev/null
@@ -0,0 +1,561 @@
+/*
+* //******************************************************************
+* //
+* // Copyright 2016 Samsung Electronics All Rights Reserved.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+* //
+* // Licensed under the Apache License, Version 2.0 (the "License");
+* // you may not use this file except in compliance with the License.
+* // You may obtain a copy of the License at
+* //
+* //      http://www.apache.org/licenses/LICENSE-2.0
+* //
+* // Unless required by applicable law or agreed to in writing, software
+* // distributed under the License is distributed on an "AS IS" BASIS,
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* // See the License for the specific language governing permissions and
+* // limitations under the License.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+*/
+
+#include "JniOcCloudProvisioning.h"
+#include "oic_malloc.h"
+
+namespace PH = std::placeholders;
+
+JniOcCloudProvisioning::JniOcCloudProvisioning(std::shared_ptr<OCCloudProvisioning> p)
+    : m_sharedCloudObject(p)
+{}
+
+JniOcCloudProvisioning::~JniOcCloudProvisioning()
+{
+    LOGD("~JniOcCloudProvisioning");
+    m_sharedCloudObject = nullptr;
+}
+
+JniOcCloudResultListener* JniOcCloudProvisioning::AddCloudResultListener(JNIEnv* env,
+        jobject jListener)
+{
+    JniOcCloudResultListener *resultListener = NULL;
+    resultMapLock.lock();
+
+    for (auto it = resultMap.begin(); it != resultMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            resultListener = refPair.first;
+            refPair.second++;
+            it->second = refPair;
+            resultMap.insert(*it);
+            LOGD("Cloud Provision resultListener: ref. count incremented");
+            break;
+        }
+    }
+    if (!resultListener)
+    {
+        resultListener = new JniOcCloudResultListener(env, jListener,
+                RemoveCallback(std::bind(&JniOcCloudProvisioning::RemoveCloudResultListener,
+                        this, PH::_1, PH::_2)));
+        jobject jgListener = env->NewGlobalRef(jListener);
+
+        resultMap.insert(std::pair < jobject, std::pair < JniOcCloudResultListener*,
+                int >> (jgListener, std::pair<JniOcCloudResultListener*, int>(resultListener, 1)));
+        LOGD("Cloud Provision resultListener: new listener");
+    }
+    resultMapLock.unlock();
+    return resultListener;
+}
+
+void JniOcCloudProvisioning::RemoveCloudResultListener(JNIEnv* env, jobject jListener)
+{
+    resultMapLock.lock();
+
+    for (auto it = resultMap.begin(); it != resultMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            if (refPair.second > 1)
+            {
+                refPair.second--;
+                it->second = refPair;
+                resultMap.insert(*it);
+                LOGI("Cloud Provision resultListener: ref. count decremented");
+            }
+            else
+            {
+                env->DeleteGlobalRef(it->first);
+                JniOcCloudResultListener* listener = refPair.first;
+                delete listener;
+                resultMap.erase(it);
+                LOGI("Cloud Provision resultListener removed");
+            }
+            break;
+        }
+    }
+    resultMapLock.unlock();
+}
+
+JniGetAclIdByDeviceListener* JniOcCloudProvisioning::AddGetAclByDeviceListener(JNIEnv* env,
+        jobject jListener)
+{
+    JniGetAclIdByDeviceListener *resultListener = NULL;
+    aclresultMapLock.lock();
+
+    for (auto it = aclresultMap.begin(); it != aclresultMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            resultListener = refPair.first;
+            refPair.second++;
+            it->second = refPair;
+            aclresultMap.insert(*it);
+            LOGD("GetACLByDeviceID Listener: ref. count incremented");
+            break;
+        }
+    }
+    if (!resultListener)
+    {
+        resultListener = new JniGetAclIdByDeviceListener(env, jListener,
+                RemoveCallback(std::bind(&JniOcCloudProvisioning::RemoveGetAclByDeviceIdListener,
+                        this, PH::_1, PH::_2)));
+        jobject jgListener = env->NewGlobalRef(jListener);
+
+        aclresultMap.insert(std::pair < jobject, std::pair < JniGetAclIdByDeviceListener*,
+                int >> (jgListener, std::pair<JniGetAclIdByDeviceListener*, int>(resultListener, 1)));
+        LOGD("GetACLByDeviceID Listener: new listener");
+    }
+    aclresultMapLock.unlock();
+    return resultListener;
+}
+
+void JniOcCloudProvisioning::RemoveGetAclByDeviceIdListener(JNIEnv* env, jobject jListener)
+{
+    aclresultMapLock.lock();
+
+    for (auto it = aclresultMap.begin(); it != aclresultMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            if (refPair.second > 1)
+            {
+                refPair.second--;
+                it->second = refPair;
+                aclresultMap.insert(*it);
+                LOGI("GetACLByDeviceID Listener: ref. count decremented");
+            }
+            else
+            {
+                env->DeleteGlobalRef(it->first);
+                JniGetAclIdByDeviceListener* listener = refPair.first;
+                delete listener;
+                aclresultMap.erase(it);
+                LOGI("GetACLByDeviceID Listener removed");
+            }
+            break;
+        }
+    }
+    aclresultMapLock.unlock();
+}
+JniOcCloudProvisioning * Create_native_object(JNIEnv *env, jobject thiz)
+{
+    jstring jip = (jstring)env->CallObjectMethod(thiz, g_mid_OcCloudProvisioning_getIP);
+    if (!jip || env->ExceptionCheck())
+    {
+        return nullptr;
+    }
+    const char *str = env->GetStringUTFChars(jip, NULL);
+    std::string ipaddress(str);
+    env->ReleaseStringUTFChars(jip, str);
+
+    jint port = env->CallIntMethod(thiz, g_mid_OcCloudProvisioning_getPort);
+    if (env->ExceptionCheck())
+    {
+        return nullptr;
+    }
+    JniOcCloudProvisioning *cloud = new JniOcCloudProvisioning(
+            std::shared_ptr<OCCloudProvisioning>(new OCCloudProvisioning(ipaddress, (uint16_t)port)));
+    SetHandle<JniOcCloudProvisioning>(env, thiz, cloud);
+    return cloud;
+}
+
+JniOcCloudProvisioning* JniOcCloudProvisioning::getJniOcCloudProvisioningPtr(JNIEnv *env, jobject thiz)
+{
+    JniOcCloudProvisioning *cloud = GetHandle<JniOcCloudProvisioning>(env, thiz);
+
+    if (env->ExceptionCheck())
+    {
+        LOGE("Failed to get native handle from OcCloudProvisioning class");
+    }
+
+    return cloud;
+}
+
+OCStackResult JniOcCloudProvisioning::requestCertificate(JNIEnv* env, jobject jListener)
+{
+    JniOcCloudResultListener *resultListener = AddCloudResultListener(env, jListener);
+
+    ResponseCallBack responseCallBack = [resultListener](OCStackResult result, void *data)
+    {
+        resultListener->CloudResultListenerCB(result, data, ListenerFunc::REQUEST_CERTIFICATE);
+    };
+
+    return m_sharedCloudObject->requestCertificate(responseCallBack);
+}
+
+OCStackResult JniOcCloudProvisioning::getIndividualAclInfo(JNIEnv* env, jobject jListener, std::string &aclID)
+{
+    JniOcCloudResultListener *resultListener = AddCloudResultListener(env, jListener);
+
+    ResponseCallBack responseCallBack = [resultListener](OCStackResult result, void *data)
+    {
+        resultListener->CloudResultListenerCB(result, data, ListenerFunc::GET_ACLINFO);
+    };
+
+    return m_sharedCloudObject->getIndividualAclInfo(aclID, responseCallBack);
+}
+
+OCStackResult JniOcCloudProvisioning::getCRL(JNIEnv* env, jobject jListener)
+{
+    JniOcCloudResultListener *resultListener = AddCloudResultListener(env, jListener);
+
+    ResponseCallBack responseCallBack = [resultListener](OCStackResult result, void *data)
+    {
+        resultListener->CloudResultListenerCB(result, data, ListenerFunc::GET_CRL);
+    };
+
+    return m_sharedCloudObject->getCRL(responseCallBack);
+}
+
+OCStackResult JniOcCloudProvisioning::postCRL(JNIEnv* env, const std::string& thisUpdate,
+                                  const std::string& nextUpdate, const OCByteString *crl,
+                                   const stringArray_t *serialNumbers, jobject jListener)
+{
+    JniOcCloudResultListener *resultListener = AddCloudResultListener(env, jListener);
+
+    ResponseCallBack responseCallBack = [resultListener](OCStackResult result, void *data)
+    {
+        resultListener->CloudResultListenerCB(result, data, ListenerFunc::POST_CRL);
+    };
+
+    return m_sharedCloudObject->postCRL(thisUpdate, nextUpdate, crl, serialNumbers,
+            responseCallBack);
+}
+
+OCStackResult JniOcCloudProvisioning::getAclIdByDevice(JNIEnv* env, std::string deviceId,
+        jobject jListener)
+{
+    JniGetAclIdByDeviceListener *resultListener = AddGetAclByDeviceListener(env, jListener);
+
+    AclIdResponseCallBack aclIdResponseCallBack = [resultListener](OCStackResult result,
+            std::string aclId)
+    {
+        resultListener->GetAclIdByDeviceListenerCB(result, aclId);
+    };
+
+    return m_sharedCloudObject->getAclIdByDevice(deviceId, aclIdResponseCallBack);
+}
+/*
+ * Class:     org_iotivity_base_OcCloudProvisioning
+ * Method:    requestCertificate
+ * Signature: (Lorg/iotivity/base/OcCloudProvisioning/RequestCertificateListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_requestCertificate
+  (JNIEnv* env, jobject thiz, jobject jListener)
+{
+    LOGD("OcCloudProvisioning_requestCertificate");
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "Listener cannot be null");
+        return;
+    }
+
+    JniOcCloudProvisioning *cloud = JniOcCloudProvisioning::getJniOcCloudProvisioningPtr(env, thiz);
+    if (!cloud)
+    {
+        LOGD("OcCloudProvisioning_requestCertificate, No native object, creating now");
+        cloud = Create_native_object(env, thiz);
+        if (!cloud)
+        {
+            ThrowOcException(OC_STACK_ERROR, "OcCloudProvisioning_requestCertificate,"
+                    "Can not Create Native object");
+            return;
+        }
+    }
+
+    try
+    {
+        OCStackResult result = cloud->requestCertificate(env, jListener);
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcCloudProvisioning_requestCertificate");
+            return;
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+    return;
+}
+
+/*
+ * Class:     org_iotivity_base_OcCloudProvisioning
+ * Method:    getAclIdByDevice
+ * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcCloudProvisioning/GetAclIdByDeviceListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getAclIdByDevice
+  (JNIEnv *env, jobject thiz, jstring jdeviceId, jobject jListener)
+{
+    LOGD("OcCloudProvisioning_getAclIdByDevice");
+    if (!jListener || !jdeviceId)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "Listener and deviceID cannot be null");
+        return;
+    }
+
+    JniOcCloudProvisioning *cloud = JniOcCloudProvisioning::getJniOcCloudProvisioningPtr(env, thiz);
+    if (!cloud)
+    {
+        LOGD("OcCloudProvisioning_getAclIdByDevice, No native object, creating now");
+        cloud = Create_native_object(env, thiz);
+        if (!cloud)
+        {
+            ThrowOcException(OC_STACK_ERROR, "OcCloudProvisioning_getAclIdByDevice,"
+                    "Can not Create Native object");
+            return;
+        }
+    }
+
+    const char *str = env->GetStringUTFChars(jdeviceId, NULL);
+    if (!str || env->ExceptionCheck())
+    {
+        ThrowOcException(OC_STACK_ERROR,"OcCloudProvisioning_getAclIdByDevice");
+        return;
+    }
+    std::string deviceId(str);
+    env->ReleaseStringUTFChars(jdeviceId, str);
+
+    try
+    {
+        OCStackResult result = cloud->getAclIdByDevice(env, deviceId, jListener);
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcCloudProvisioning_getAclIdByDevice");
+            return;
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+    return;
+}
+
+/*
+ * Class:     org_iotivity_base_OcCloudProvisioning
+ * Method:    getIndividualAclInfo
+ * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcCloudProvisioning/GetIndividualAclInfoListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getIndividualAclInfo
+  (JNIEnv *env, jobject thiz, jstring jaclID, jobject jListener)
+{
+    LOGD("OcCloudProvisioning_getIndividualAclInfo");
+    if (!jListener || !jaclID)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "Listener/aclID cannot be null");
+        return;
+    }
+
+    JniOcCloudProvisioning *cloud = JniOcCloudProvisioning::getJniOcCloudProvisioningPtr(env, thiz);
+    if (!cloud)
+    {
+        LOGD("OcCloudProvisioning_getIndividualAclInfo, No native object, creating now");
+        cloud = Create_native_object(env, thiz);
+        if (!cloud)
+        {
+            ThrowOcException(OC_STACK_ERROR, "OcCloudProvisioning_getIndividualAclInfo,"
+                    "Can not Create Native object");
+            return;
+        }
+    }
+
+    const char *str = env->GetStringUTFChars(jaclID, NULL);
+    std::string aclID(str);
+    env->ReleaseStringUTFChars(jaclID, str);
+
+    try
+    {
+        OCStackResult result = cloud->getIndividualAclInfo(env, jListener, aclID);
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcCloudProvisioning_getIndividualAclInf");
+            return;
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+    return;
+}
+
+/*
+ * Class:     org_iotivity_base_OcCloudProvisioning
+ * Method:    getCRL
+ * Signature: (Lorg/iotivity/base/OcCloudProvisioning/GetCRLListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getCRL
+  (JNIEnv *env, jobject thiz, jobject jListener)
+{
+    LOGD("OcCloudProvisioning_getCRL");
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "Listener cannot be null");
+        return;
+    }
+
+    JniOcCloudProvisioning *cloud = JniOcCloudProvisioning::getJniOcCloudProvisioningPtr(env, thiz);
+    if (!cloud)
+    {
+        LOGD("OcCloudProvisioning_getCRL, No native object, creating now");
+        cloud = Create_native_object(env, thiz);
+        if (!cloud)
+        {
+            ThrowOcException(OC_STACK_ERROR, "OcCloudProvisioning_getCRL,"
+                    "Can not Create Native object");
+            return;
+        }
+    }
+
+    try
+    {
+        OCStackResult result = cloud->getCRL(env, jListener);
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcCloudProvisioning_requestCertificate");
+            return;
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+    return;
+}
+
+/*
+ * Class:     org_iotivity_base_OcCloudProvisioning
+ * Method:    postCRL0
+ * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/ArrayList;Lorg/iotivity/base/OcCloudProvisioning/PostCRLListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_postCRL0
+  (JNIEnv *env , jobject thiz, jstring jthisUpdate, jstring jnextUpdate, jstring jcrl,
+   jobjectArray jserialnumArray, jobject jListener)
+{
+    LOGD("OcCloudProvisioning_postCRL0");
+    if (!jListener || !jthisUpdate || !jnextUpdate || !jserialnumArray)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, " Invalid parameter (NULL param)");
+        return;
+    }
+
+    JniOcCloudProvisioning *cloud = JniOcCloudProvisioning::getJniOcCloudProvisioningPtr(env, thiz);
+    if (!cloud)
+    {
+        LOGD("OcCloudProvisioning_getCRL, No native object, creating now");
+        cloud = Create_native_object(env, thiz);
+        if (!cloud)
+        {
+            ThrowOcException(OC_STACK_ERROR, "OcCloudProvisioning_PostCRL0,"
+                    "Can not Create Native object");
+            return;
+        }
+    }
+
+    const char *str = env->GetStringUTFChars(jthisUpdate, NULL);
+    if (!str || env->ExceptionCheck())
+    {
+        ThrowOcException(OC_STACK_ERROR,"OcCloudProvisioning_PostCRL0");
+        return;
+    }
+    std::string thisUpdate(str);
+    env->ReleaseStringUTFChars(jthisUpdate, str);
+
+    str = env->GetStringUTFChars(jnextUpdate, NULL);
+    if (!str || env->ExceptionCheck())
+    {
+        ThrowOcException(OC_STACK_ERROR,"OcCloudProvisioning_PostCRL0");
+        return;
+    }
+    std::string nextUpdate(str);
+    env->ReleaseStringUTFChars(jnextUpdate, str);
+
+    OCByteString *crl = NULL;
+    if (jcrl)
+    {
+        str = env->GetStringUTFChars(jcrl, NULL);
+        if (!str || env->ExceptionCheck())
+        {
+            ThrowOcException(OC_STACK_ERROR,"OcCloudProvisioning_PostCRL0");
+            return;
+        }
+        crl = (OCByteString*)OICCalloc(1, sizeof(OCByteString));
+        crl->len = (size_t)(strlen(str));
+        crl->bytes = (uint8_t*)OICCalloc(crl->len, sizeof(uint8_t));
+
+        for (size_t i = 0 ; i < crl->len; i++)
+        {
+            crl->bytes[i] = (uint8_t)str[i];
+        }
+    }
+
+    jsize len = env->GetArrayLength(jserialnumArray);
+
+    stringArray_t *serialNumArray = (stringArray_t*)OICCalloc(1, sizeof(stringArray_t));
+    serialNumArray->array = (char**)OICCalloc(len, sizeof(char*));
+    serialNumArray->length = len;
+
+    for (jsize i = 0; i < len; ++i)
+    {
+        jstring jStr = (jstring)env->GetObjectArrayElement(jserialnumArray, i);
+        if (!jStr)
+        {
+            ThrowOcException(OC_STACK_ERROR,"OcCloudProvisioning_PostCRL0");
+            return;
+        }
+        serialNumArray->array[i] = (char*)env->GetStringUTFChars(jStr, nullptr);
+        if (env->ExceptionCheck())
+        {
+            ThrowOcException(OC_STACK_ERROR,"OcCloudProvisioning_PostCRL0");
+            return;
+        }
+        env->DeleteLocalRef(jStr);
+    }
+
+    try
+    {
+        OCStackResult result = cloud->postCRL(env, thisUpdate, nextUpdate, crl,
+                serialNumArray, jListener);
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcCloudProvisioning_PostCRL0");
+            return;
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+    return;
+}
diff --git a/android/android_api/base/jni/JniOcCloudProvisioning.h b/android/android_api/base/jni/JniOcCloudProvisioning.h
new file mode 100644 (file)
index 0000000..58693c7
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+* //******************************************************************
+* //
+* // Copyright 2016 Samsung Electronics All Rights Reserved.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+* //
+* // Licensed under the Apache License, Version 2.0 (the "License");
+* // you may not use this file except in compliance with the License.
+* // You may obtain a copy of the License at
+* //
+* //      http://www.apache.org/licenses/LICENSE-2.0
+* //
+* // Unless required by applicable law or agreed to in writing, software
+* // distributed under the License is distributed on an "AS IS" BASIS,
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* // See the License for the specific language governing permissions and
+* // limitations under the License.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+*/
+
+#include "JniOcStack.h"
+#include "OCCloudProvisioning.h"
+#include "JniOcCloudResultListener.h"
+#include "JniGetAclIdByDeviceListener.h"
+#include <mutex>
+
+
+using namespace OC;
+
+#ifndef _Included_org_iotivity_base_OcCloudProvisioning
+#define _Included_org_iotivity_base_OcCloudProvisioning
+class JniOcCloudProvisioning
+{
+    public:
+        JniOcCloudProvisioning(std::shared_ptr<OCCloudProvisioning> cloudObject);
+        ~JniOcCloudProvisioning();
+
+        static JniOcCloudProvisioning* getJniOcCloudProvisioningPtr(JNIEnv *env, jobject thiz);
+        JniOcCloudResultListener* AddCloudResultListener(JNIEnv* env, jobject jListener);
+        JniGetAclIdByDeviceListener* AddGetAclByDeviceListener(JNIEnv* env, jobject jListener);
+        void  RemoveCloudResultListener(JNIEnv* env, jobject jListener);
+        void RemoveGetAclByDeviceIdListener(JNIEnv*, jobject);
+
+        OCStackResult requestCertificate(JNIEnv* env, jobject jListener);
+        OCStackResult getAclIdByDevice(JNIEnv*, std::string, jobject);
+        OCStackResult getIndividualAclInfo(JNIEnv*, jobject, std::string &);
+        OCStackResult getCRL(JNIEnv* env, jobject jListener);
+        OCStackResult postCRL(JNIEnv* env, const std::string& thisUpdate,
+                                  const std::string& nextUpdate, const OCByteString *crl,
+                                   const stringArray_t *serialNumbers, jobject jListener);
+
+    private:
+        std::map<jobject, std::pair<JniOcCloudResultListener*, int>> resultMap;
+        std::map<jobject, std::pair<JniGetAclIdByDeviceListener*, int>> aclresultMap;
+        std::mutex resultMapLock;
+        std::mutex aclresultMapLock;
+        std::shared_ptr<OCCloudProvisioning>m_sharedCloudObject;
+};
+
+
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class:     org_iotivity_base_OcCloudProvisioning
+ * Method:    requestCertificate
+ * Signature: (Lorg/iotivity/base/OcCloudProvisioning/RequestCertificateListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_requestCertificate
+  (JNIEnv *, jobject, jobject);
+
+/*
+ * Class:     org_iotivity_base_OcCloudProvisioning
+ * Method:    getAclIdByDevice
+ * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcCloudProvisioning/GetAclIdByDeviceListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getAclIdByDevice
+  (JNIEnv *, jobject, jstring, jobject);
+
+/*
+ * Class:     org_iotivity_base_OcCloudProvisioning
+ * Method:    getIndividualAclInfo
+ * Signature: (Ljava/lang/String;Lorg/iotivity/base/OcCloudProvisioning/GetIndividualAclInfoListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getIndividualAclInfo
+  (JNIEnv *, jobject, jstring, jobject);
+
+/*
+ * Class:     org_iotivity_base_OcCloudProvisioning
+ * Method:    getCRL
+ * Signature: (Lorg/iotivity/base/OcCloudProvisioning/GetCRLListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_getCRL
+  (JNIEnv *, jobject, jobject);
+
+/*
+ * Class:     org_iotivity_base_OcCloudProvisioning
+ * Method:    postCRL0
+ * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/ArrayList;Lorg/iotivity/base/OcCloudProvisioning/PostCRLListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_postCRL0
+  (JNIEnv *, jobject, jstring, jstring, jstring, jobjectArray, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/android/android_api/base/jni/JniOcCloudResultListener.cpp b/android/android_api/base/jni/JniOcCloudResultListener.cpp
new file mode 100644 (file)
index 0000000..9894fa2
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+* //******************************************************************
+* //
+* // Copyright 2016 Samsung Electronics All Rights Reserved.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+* //
+* // Licensed under the Apache License, Version 2.0 (the "License");
+* // you may not use this file except in compliance with the License.
+* // You may obtain a copy of the License at
+* //
+* //      http://www.apache.org/licenses/LICENSE-2.0
+* //
+* // Unless required by applicable law or agreed to in writing, software
+* // distributed under the License is distributed on an "AS IS" BASIS,
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* // See the License for the specific language governing permissions and
+* // limitations under the License.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+*/
+#include "JniOcCloudResultListener.h"
+
+JniOcCloudResultListener::JniOcCloudResultListener(JNIEnv *env, jobject jListener,
+    RemoveCallback removeCloudResultListener)
+{
+    m_jwListener = env->NewWeakGlobalRef(jListener);
+    m_removeCloudResultListener = removeCloudResultListener;
+}
+
+JniOcCloudResultListener::~JniOcCloudResultListener()
+{
+    LOGI("~JniOcCloudResultListener()");
+    if (m_jwListener)
+    {
+        jint ret = JNI_ERR;
+        JNIEnv *env = GetJNIEnv(ret);
+        if (nullptr == env)
+        {
+            return;
+        }
+        env->DeleteWeakGlobalRef(m_jwListener);
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+    }
+}
+
+void JniOcCloudResultListener::CloudResultListenerCB(int result, void *data,
+      ListenerFunc func)
+{
+    jint ret = JNI_ERR;
+    JNIEnv *env = GetJNIEnv(ret);
+    if (nullptr == env)
+    {
+        return;
+    }
+
+    jobject jListener = env->NewLocalRef(m_jwListener);
+    if (!jListener)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+        return;
+    }
+
+    jclass clsL = env->GetObjectClass(jListener);
+
+    if (!clsL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+        return;
+    }
+
+    std::string calledFunc;
+    switch (func)
+    {
+        case ListenerFunc::REQUEST_CERTIFICATE:
+            {
+                calledFunc = "requestCertificateListener";
+            }
+            break;
+        case ListenerFunc::GET_ACLINFO:
+            {
+                calledFunc = "getIndividualAclInfoListener";
+            }
+            break;
+        case ListenerFunc::GET_CRL:
+            {
+                calledFunc = "getCRLListener";
+            }
+            break;
+        case ListenerFunc::POST_CRL:
+            {
+                calledFunc = "postCRLListener";
+            }
+            break;
+        default:
+            {
+                checkExAndRemoveListener(env);
+                if (JNI_EDETACHED == ret)
+                {
+                    g_jvm->DetachCurrentThread();
+                }
+                return;
+            }
+            return;
+    }
+
+    jmethodID midL = env->GetMethodID(clsL, calledFunc.c_str(), "(Z)V");
+    if (!midL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret)
+        {
+            g_jvm->DetachCurrentThread();
+        }
+        return;
+    }
+
+    env->CallVoidMethod(jListener, midL, (jboolean)result);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Java exception is thrown");
+    }
+
+    checkExAndRemoveListener(env);
+    if (JNI_EDETACHED == ret)
+    {
+        g_jvm->DetachCurrentThread();
+    }
+}
+
+void JniOcCloudResultListener::checkExAndRemoveListener(JNIEnv* env)
+{
+    if (env->ExceptionCheck())
+    {
+        jthrowable ex = env->ExceptionOccurred();
+        env->ExceptionClear();
+        m_removeCloudResultListener(env, m_jwListener);
+        env->Throw((jthrowable)ex);
+    }
+    else
+    {
+        m_removeCloudResultListener(env, m_jwListener);
+    }
+}
diff --git a/android/android_api/base/jni/JniOcCloudResultListener.h b/android/android_api/base/jni/JniOcCloudResultListener.h
new file mode 100644 (file)
index 0000000..3cb826a
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+* //******************************************************************
+* //
+* // Copyright 2015 Samsung Electronics All Rights Reserved.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+* //
+* // Licensed under the Apache License, Version 2.0 (the "License");
+* // you may not use this file except in compliance with the License.
+* // You may obtain a copy of the License at
+* //
+* //      http://www.apache.org/licenses/LICENSE-2.0
+* //
+* // Unless required by applicable law or agreed to in writing, software
+* // distributed under the License is distributed on an "AS IS" BASIS,
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* // See the License for the specific language governing permissions and
+* // limitations under the License.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+*/
+#include <jni.h>
+#include "JniOcStack.h"
+
+#ifndef _Included_org_iotivity_base_OcCloudProvisioning_JniOcCloudResultListener
+#define _Included_org_iotivity_base_OcCloudProvisioning_JniOcCloudResultListener
+
+typedef std::function<void(JNIEnv* env, jobject jListener)> RemoveCallback;
+
+enum class ListenerFunc
+{
+    REQUEST_CERTIFICATE = 1,
+    GET_ACLINFO,
+    GET_CRL,
+    POST_CRL
+};
+
+class JniOcCloudResultListener
+{
+    public:
+        JniOcCloudResultListener(JNIEnv *env, jobject jListener,
+                RemoveCallback removeCloudResultListener);
+        ~JniOcCloudResultListener();
+
+        void CloudResultListenerCB(int result, void *data, ListenerFunc func);
+
+    private:
+        RemoveCallback m_removeCloudResultListener;
+        jweak m_jwListener;
+        void checkExAndRemoveListener(JNIEnv* env);
+};
+#endif
index 06de766..c140551 100644 (file)
@@ -79,6 +79,9 @@ jclass g_cls_OcOicSecAcl_resr = nullptr;
 jclass g_cls_OcOicSecAcl_validity = nullptr;
 jclass g_cls_OcOicSecPdAcl = nullptr;
 jclass g_cls_OcDirectPairDevice = nullptr;
+#ifdef __WITH_TLS__
+jclass g_cls_OcCloudProvisioning = nullptr;
+#endif
 #ifdef WITH_CLOUD
 jclass g_cls_OcAccountManager = nullptr;
 #endif
@@ -144,6 +147,11 @@ jmethodID g_mid_OcOicSecAcl_validity_get_recurrenceLen = nullptr;
 jmethodID g_mid_OcOicSecAcl_resr_get_interfaceLen = nullptr;
 jmethodID g_mid_OcOicSecAcl_get_rownerID = nullptr;
 
+#ifdef __WITH_TLS__
+jmethodID g_mid_OcCloudProvisioning_getIP = nullptr;
+jmethodID g_mid_OcCloudProvisioning_getPort = nullptr;
+#endif
+
 jobject getOcException(JNIEnv* env, const char* file, const char* functionName,
     const int line, const int code, const char* message)
 {
@@ -586,7 +594,19 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
 
     g_mid_OcOicSecPdAcl_get_recurrences = env->GetMethodID(g_cls_OcOicSecPdAcl, "getRecurrences", "(I)Ljava/lang/String;");
     VERIFY_VARIABLE_NULL(g_mid_OcOicSecPdAcl_get_recurrences);
+#ifdef __WITH_TLS__
+    //OcCloudProvisioning
+    clazz = env->FindClass("org/iotivity/base/OcCloudProvisioning");
+    VERIFY_VARIABLE_NULL(clazz);
+    g_cls_OcCloudProvisioning =  (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
 
+    g_mid_OcCloudProvisioning_getIP = env->GetMethodID(g_cls_OcCloudProvisioning, "getIP", "()Ljava/lang/String;");
+    VERIFY_VARIABLE_NULL(g_mid_OcCloudProvisioning_getIP);
+
+    g_mid_OcCloudProvisioning_getPort = env->GetMethodID(g_cls_OcCloudProvisioning, "getPort", "()I");
+    VERIFY_VARIABLE_NULL(g_mid_OcCloudProvisioning_getPort);
+#endif
     return JNI_CURRENT_VERSION;
 }
 
@@ -641,6 +661,9 @@ JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
 #ifdef WITH_CLOUD
         env->DeleteGlobalRef(g_cls_OcAccountManager);
 #endif
+#ifdef WITH_CLOUD
+        env->DeleteGlobalRef(g_cls_OcCloudProvisioning);
+#endif
         env->DeleteGlobalRef(g_cls_OcOicSecAcl);
         env->DeleteGlobalRef(g_cls_OcOicSecAcl_ace);
         env->DeleteGlobalRef(g_cls_OcOicSecAcl_resr);
index 600f0ab..51f856e 100644 (file)
@@ -88,6 +88,9 @@ extern jclass g_cls_OcDirectPairDevice;
 #ifdef WITH_CLOUD
 extern jclass g_cls_OcAccountManager;
 #endif
+#ifdef __WITH_TLS__
+extern jclass g_cls_OcCloudProvisioning;
+#endif
 
 extern jclass g_cls_OcOicSecAcl_ace;
 extern jclass g_cls_OcOicSecAcl_resr;
@@ -129,6 +132,10 @@ extern jmethodID g_mid_OcDirectPairDevice_dev_ctor;
 #ifdef WITH_CLOUD
 extern jmethodID g_mid_OcAccountManager_ctor;
 #endif
+#ifdef __WITH_TLS__
+extern jmethodID g_mid_OcCloudProvisioning_getIP;
+extern jmethodID g_mid_OcCloudProvisioning_getPort;
+#endif
 
 extern jmethodID g_mid_OcOicSecAcl_get_rownerID;
 extern jmethodID g_mid_OcOicSecAcl_get_aces;
index 9b73305..31a071c 100755 (executable)
@@ -125,7 +125,14 @@ public class  OcCloudProvisioning {
     * @param cloudPostCRLHandler function called by the stack on completion of request.
     * @throws OcException
     */
-    public native void postCRL0(String thisUpdate, String nextUpdate, String crl, ArrayList<String> serialNumbers,
+    public void postCRL(String thisUpdate, String nextUpdate, String crl, ArrayList<String> serialNumbers,
+                                    PostCRLListener cloudPostCRLHandler) throws OcException
+    {
+        String[] serialNums = new String[serialNumbers.size()];
+        serialNums = serialNumbers.toArray(serialNums);
+        this.postCRL0(thisUpdate, nextUpdate, crl, serialNums, cloudPostCRLHandler);
+    }
+    public native void postCRL0(String thisUpdate, String nextUpdate, String crl, String[] serialNumbers,
                                     PostCRLListener cloudPostCRLHandler) throws OcException;
 }
 
index dbb9998..deb5250 100755 (executable)
@@ -53,7 +53,6 @@ namespace OC
 \r
         private:\r
             OCDevAddr  m_devAddr;\r
-            std::weak_ptr<std::recursive_mutex> m_csdkLock;\r
         public:\r
 \r
             /**\r
index 1c422b9..2e6d4a8 100644 (file)
@@ -57,7 +57,6 @@ namespace OC
         memset(&m_devAddr, 0, sizeof(m_devAddr));
         memcpy(m_devAddr.addr, ipAddr.c_str(), MAX_ADDR_STR_SIZE);
         m_devAddr.port = port;
-        m_csdkLock = OCPlatform_impl::Instance().csdkLock();
     }
 
     OCCloudProvisioning::~OCCloudProvisioning(void)
@@ -73,7 +72,7 @@ namespace OC
         }
 
         OCStackResult result;
-        auto cLock = m_csdkLock.lock();
+        auto cLock = OCPlatform_impl::Instance().csdkLock().lock();
 
         if (cLock)
         {
@@ -101,7 +100,7 @@ namespace OC
         }
 
         OCStackResult result;
-        auto cLock = m_csdkLock.lock();
+        auto cLock = OCPlatform_impl::Instance().csdkLock().lock();
 
         if (cLock)
         {
@@ -130,7 +129,7 @@ namespace OC
         }
 
         OCStackResult result;
-        auto cLock = m_csdkLock.lock();
+        auto cLock = OCPlatform_impl::Instance().csdkLock().lock();
 
         if (cLock)
         {
@@ -158,7 +157,7 @@ namespace OC
         }
 
         OCStackResult result;
-        auto cLock = m_csdkLock.lock();
+        auto cLock = OCPlatform_impl::Instance().csdkLock().lock();
 
         if (cLock)
         {
@@ -189,7 +188,7 @@ namespace OC
         }
 
         OCStackResult result;
-        auto cLock = m_csdkLock.lock();
+        auto cLock = OCPlatform_impl::Instance().csdkLock().lock();
 
         if (cLock)
         {