public void postCRLListener(int result);
}
+ public interface UpdateIndividualACLListener {
+ public void updateIndividualACLListener(int result);
+ }
+
/**
* Method to Request a certificate from the cloud
* @param certificateIssueRequestListener function called by the stack on completion of request.
public native void getIndividualAclInfo(String aclId,
GetIndividualAclInfoListener cloudAclIndividualGetInfoHandler) throws OcException;
+ /**
+ * Method to update Individual ACL info
+ * @param aclId ACL ID
+ * @param cloudAces List of cloud Aces for updation.
+ * @param updateIndividualACLHandler function called by the stack on completion of request.
+ * @throws OcException Indicates failure to get ACL information.
+ * Use OcException.GetErrorCode() for more details.
+ */
+ public void updateIndividualACL(String aclId, List<OicSecCloudAce> cloudAces,
+ UpdateIndividualACLListener updateIndividualACLHandler) throws OcException
+ {
+ this.updateIndividualACL0(aclId,
+ cloudAces.toArray(new OicSecCloudAce[cloudAces.size()]), updateIndividualACLHandler);
+ }
+
+ public native void updateIndividualACL0(String aclId, OicSecCloudAce[] aces,
+ UpdateIndividualACLListener updateIndividualACLHandler) throws OcException;
+
/**
* Method to get certificate revocation list
* @param cloudGetCRLHandler function called by the stack on completion of request.
--- /dev/null
+/*
+ *******************************************************************
+ *
+ * Copyright 2017 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.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+import java.util.List;
+public class OicSecCloudAce {
+ private String aclID;
+ private String subjectID;
+ private int stype;
+ private int permission;
+ private List<OicSecResr> resources;
+ private List<OicSecValidity> validities;
+
+ public OicSecCloudAce(String aclID, String subjectID, int stype, int permission,
+ List<OicSecResr> resources, List<OicSecValidity> validities) {
+ super();
+ this.subjectID = subjectID;
+ this.permission = permission;
+ this.resources = resources;
+ this.validities = validities;
+ }
+
+ public String getAclID() {
+ return aclID;
+ }
+
+ public String getSubjectID() {
+ return subjectID;
+ }
+
+ public void setAclID(String aclID) {
+ this.aclID = aclID;
+ }
+
+ public void setSubjectID(String subjectID) {
+ this.subjectID = subjectID;
+ }
+
+ public int getStype() {
+ return stype;
+ }
+
+ public void setStype(int stype) {
+ this.stype = stype;
+ }
+
+
+ public int getPermission() {
+ return permission;
+ }
+
+ public void setPermission(int permission) {
+ this.permission = permission;
+ }
+
+ public List<OicSecResr> getResourcesList() {
+ return resources;
+ }
+
+ public OicSecResr[] getResources() {
+ return resources.toArray(new OicSecResr[resources.size()]);
+ }
+ public void setResources(List<OicSecResr> resources) {
+ this.resources = resources;
+ }
+
+ public List<OicSecValidity> getValiditiesList() {
+ return validities;
+ }
+
+ public OicSecValidity[] getValidities() {
+ return validities.toArray(new OicSecValidity[validities.size()]);
+ }
+
+ public void setValidities(List<OicSecValidity> validities) {
+ this.validities = validities;
+ }
+}
import org.iotivity.base.QualityOfService;
import org.iotivity.base.ServiceType;
import org.iotivity.base.examples.cloudprovisioningclient.R;
-
+import org.iotivity.base.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
public class CloudProvisioningClient extends Activity implements OcAccountManager.OnPostListener {
private static final String TAG = "Cloud Provisioning Client: ";
+ private List<OicSecCloudAce> generateAce(String aclid)
+ {
+ String type1 = "type1";
+ String type2 = "type2";
+ int typeLen = 2;
+ String interface1 = "interface1";
+ String interface2 = "interface2";
+ int interfaceLen = 2;
+
+
+ ArrayList<String> types = new ArrayList<String>();
+ types.add(type1);
+ types.add(type2);
+
+ ArrayList<String> interfaces = new ArrayList<String>();
+ interfaces.add(interface1);
+ interfaces.add(interface2);
+ OicSecResr res = new OicSecResr("/oic/a", "testrel", types, typeLen,interfaces, 2);
+ OicSecResr res1 = new OicSecResr("/oic/b", "testrel", types, typeLen,interfaces, 2);
+ List<OicSecResr> resources = new ArrayList<OicSecResr>();
+ resources.add(res);
+ resources.add(res1);
+
+ List<String> recurrences = new ArrayList<String>();
+ recurrences.add("1");
+ recurrences.add("2");
+ OicSecValidity validity1 = new OicSecValidity("1", recurrences,2);
+ OicSecValidity validity2 = new OicSecValidity("2", recurrences,2);
+ List<OicSecValidity> validities = new ArrayList<OicSecValidity>();
+ validities.add(validity1);
+ validities.add(validity2);
+
+ OicSecCloudAce ace1 = new OicSecCloudAce(aclid,"72616E64-5069-6E44-6576-557569643030", 0,
+ 31,resources, validities);
+ OicSecCloudAce ace2 = new OicSecCloudAce(aclid, "72616E64-5069-6E44-6576-557569643030", 0,
+ 8, resources, validities);
+
+ List<OicSecCloudAce> aces = new ArrayList<OicSecCloudAce>();
+ aces.add(ace1);
+ aces.add(ace2);
+ logMessage("out--generate ace");
+ return aces;
+ }
+
+
OcAccountManager.OnPostListener onSignUp = new OcAccountManager.OnPostListener() {
@Override
public synchronized void onPostCompleted(List<OcHeaderOption> list,
};
private static final int BUFFER_SIZE = 1024;
private final int REQUEST_LOGIN = 1;
- Button signUp, signIn, signOut, getAclId, getAclInfo, requestCert, postCrl, getCrl;
+ Button signUp, signIn, signOut, getAclId, getAclInfo, requestCert, postCrl, getCrl, updateAce;
TextView userid;
LinearLayout lyt1, lyt2, signupLyt, signinLyt;
// private TextView eventView;
SharedPreferences settingPreference;
OcCloudProvisioning ocCloudProvisioning;
- String acl_Id;
String createacl_Id = null;
+ String acl_Id = null;
OcCloudProvisioning.GetAclIdByDeviceListener getAclIdByDeviceListener =
new OcCloudProvisioning.GetAclIdByDeviceListener() {
@Override
Log.d(TAG, "Inside createAclIdListener ");
if (result == 0) {
createacl_Id = aclId;
+ acl_Id = aclId;
logMessage("Acl Id by create aclid !!" + createacl_Id);
} else {
logMessage("Error: Acl Id by create aclid failed !!");
}
}
};
+ OcCloudProvisioning.UpdateIndividualACLListener updateIndividualACLListener =
+ new OcCloudProvisioning.UpdateIndividualACLListener(){
+ public void updateIndividualACLListener(int result)
+ {
+ Log.d(TAG, "Inside UpdateIndividualACLListener ");
+ if (result == 4) {
+ logMessage("Success UpdateIndividualACLListener");
+ } else {
+ logMessage("Error:UpdateIndividualACLListener = "+result);
+ }
+ }
+ };
private OcAccountManager mAccountManager;
private String filePath = "";
private TextView mEventsTextView;
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
postCrl = (Button) findViewById(R.id.postCRL);
getCrl = (Button) findViewById(R.id.getCRL);
+ updateAce = (Button) findViewById(R.id.updateAce);
lyt1 = (LinearLayout) findViewById(R.id.lyt1);
lyt2 = (LinearLayout) findViewById(R.id.lyt2);
signupLyt = (LinearLayout) findViewById(R.id.signupLyt);
getCrl();
}
});
+ updateAce.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ updateAces();
+ }
+ });
}
private void getAclId() {
try {
+ logMessage("getAclId");
if(createacl_Id == null)
{
ocCloudProvisioning.createAclId(settingPreference.getString("OWNERID", ""),
private void getAclInfo() {
try {
logMessage("getAclInfo");
- logMessage("\taclid="+acl_Id);
ocCloudProvisioning.getIndividualAclInfo(acl_Id, getIndividualAclInfoListener);
} catch (OcException e) {
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add(settingPreference.getString("SERIALNUMBER", "1234"));
- ocCloudProvisioning.postCRL("20160727000000", "20161027000000", null, arrayList, postCRLListener);
+ ocCloudProvisioning.postCRL("20160727000000", "20161027000000", null,
+ arrayList, postCRLListener);
} catch (OcException e) {
e.printStackTrace();
}
}
+ private void updateAces()
+ {
+ try {
+ logMessage("updateAce");
+ ocCloudProvisioning.updateIndividualACL(acl_Id, generateAce(acl_Id),
+ updateIndividualACLListener);
+
+ } catch (OcException e) {
+ e.printStackTrace();
+ }
+ }
private void signUp() {
try {
mAccountManager = OcPlatform.constructAccountManagerObject(
sendBroadcast(intent);
}
-
private void setDefualtSettings() {
View setingLayout = getLayoutInflater().inflate(R.layout.setting_layout, null);
android:text="Get CRL" />
</LinearLayout>
-
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="0.33"
+ android:gravity="center_horizontal">
+
+ <Button
+ android:id="@+id/updateAce"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Update ACE" />
+ </LinearLayout>
</LinearLayout>
#include "JniOcStack.h"
#include "JniOcCloudProvisioning.h"
+#include "srmutility.h"
#include "oic_malloc.h"
namespace PH = std::placeholders;
return m_sharedCloudObject->createAclId(ownerId, deviceID, aclIdResponseCallBack);
}
+
+static OicSecValidity_t* getValiditiesList(JNIEnv *env, jobject validityObject)
+{
+ jstring jData;
+ jobjectArray valList = (jobjectArray)env->CallObjectMethod(validityObject,
+ g_mid_OcOicSecCloudAcl_ace_get_validities);
+ if (!valList || env->ExceptionCheck())
+ {
+ return nullptr;
+ }
+ int nr_validities = env->GetArrayLength(valList);
+
+ OicSecValidity_t *valHead = NULL;
+
+ for (int i = 0 ; i < nr_validities; i++)
+ {
+ OicSecValidity_t *tmp = (OicSecValidity_t*)OICCalloc(1, sizeof(OicSecValidity_t));
+ jobject element = env->GetObjectArrayElement(valList, i);
+ if (!element || env->ExceptionCheck())
+ {
+ return nullptr;
+ }
+
+ jData = (jstring)env->CallObjectMethod(element, g_mid_OcOicSecAcl_validity_get_getPeriod);
+ if (!jData || env->ExceptionCheck())
+ {
+ return nullptr;
+ }
+ tmp->period = (char*)env->GetStringUTFChars(jData, 0);
+
+ jint jrecurrenceLen = (jint) env->CallIntMethod(element,
+ g_mid_OcOicSecAcl_validity_get_recurrenceLen);
+ tmp->recurrenceLen = (int)jrecurrenceLen;
+
+ if (jrecurrenceLen > 0)
+ {
+ jvalue argv[1];
+ tmp->recurrences = (char**)OICCalloc(jrecurrenceLen, sizeof(char*));
+
+ for (int i = 0 ; i < jrecurrenceLen; i++)
+ {
+ argv[0].i = i;
+ jData = (jstring)env->CallObjectMethodA(element,
+ g_mid_OcOicSecAcl_validity_get_recurrences, argv);
+ if (!jData || env->ExceptionCheck())
+ {
+ return nullptr;
+ }
+ tmp->recurrences[i] = (char*)env->GetStringUTFChars(jData, 0);
+ }
+ }
+ if (NULL == valHead)
+ {
+ valHead = tmp;
+ }
+ else
+ {
+ OicSecValidity_t *ptr = valHead;
+ while(ptr->next != NULL) ptr = ptr->next;
+ ptr->next = tmp;
+ tmp->next = NULL;
+ }
+ env->DeleteLocalRef(element);
+ }
+ return valHead;
+}
+
+static OicSecRsrc_t * getResourcesList(JNIEnv *env, jobject resourceObject)
+{
+ jstring jData;
+
+ jobjectArray rescList = (jobjectArray)env->CallObjectMethod(resourceObject,
+ g_mid_OcOicSecCloudAcl_ace_get_resources);
+ if (!rescList || env->ExceptionCheck())
+ {
+ return nullptr;
+ }
+
+ int nr_resc = env->GetArrayLength(rescList);
+ OicSecRsrc_t *rescHead = NULL;
+
+ for (int i = 0 ; i < nr_resc; i++)
+ {
+ OicSecRsrc_t *tmp = (OicSecRsrc_t*)OICCalloc(1, sizeof(OicSecRsrc_t));
+ jobject element = env->GetObjectArrayElement(rescList, i);
+ if (!element || env->ExceptionCheck())
+ {
+ return nullptr;
+ }
+ jData = (jstring)env->CallObjectMethod(element, g_mid_OcOicSecAcl_resr_get_href);
+ if (!jData || env->ExceptionCheck())
+ {
+ return nullptr;
+ }
+ tmp->href = (char*)env->GetStringUTFChars(jData, 0);
+
+ jData = (jstring)env->CallObjectMethod(element, g_mid_OcOicSecAcl_resr_get_rel);
+ if (!jData || env->ExceptionCheck())
+ {
+ return nullptr;
+ }
+ tmp->rel = (char*)env->GetStringUTFChars(jData, 0);
+
+ jint len = (jint) env->CallIntMethod(element, g_mid_OcOicSecAcl_resr_get_typeLen);
+ tmp->typeLen = (int)len;
+ if (len > 0)
+ {
+ jvalue argv[1];
+ tmp->types = (char**)OICCalloc(len, sizeof(char*));
+
+ for (int i = 0 ; i < len; i++)
+ {
+ argv[0].i = i;
+ jData = (jstring)env->CallObjectMethodA(element,
+ g_mid_OcOicSecAcl_resr_get_types, argv);
+ if (!jData || env->ExceptionCheck())
+ {
+ return nullptr;
+ }
+ tmp->types[i] = (char*)env->GetStringUTFChars(jData, 0);
+ }
+ }
+
+ len = (jint) env->CallIntMethod(element, g_mid_OcOicSecAcl_resr_get_interfaceLen);
+ tmp->interfaceLen = len;
+ if (len > 0)
+ {
+ jvalue argv[1];
+ tmp->interfaces = (char**)OICCalloc(len, sizeof(char*));
+
+ for (int i = 0 ; i < len; i++)
+ {
+ argv[0].i = i;
+ jData = (jstring)env->CallObjectMethodA(element,
+ g_mid_OcOicSecAcl_resr_get_interfaces, argv);
+ if (!jData || env->ExceptionCheck())
+ {
+ return nullptr;
+ }
+ tmp->interfaces[i] = (char*)env->GetStringUTFChars(jData, 0);
+ }
+ }
+
+ if (NULL == rescHead)
+ {
+ rescHead = tmp;
+ }
+ else
+ {
+ OicSecRsrc_t *ptr = rescHead;
+ while(ptr->next != NULL) ptr = ptr->next;
+ ptr->next = tmp;
+ tmp->next = NULL;
+ }
+ env->DeleteLocalRef(element);
+ }
+ return rescHead;
+}
+
+cloudAce_t * ConvertJavaCloudAcestoOCAces(JNIEnv* env, jobjectArray jcloudAces)
+{
+ char *str;
+ jstring jData;
+ cloudAce_t *acesHead = NULL;
+ const jsize arrayLen = env->GetArrayLength(jcloudAces);
+
+ for (int i = 0 ; i < arrayLen; i++)
+ {
+ cloudAce_t *aces = (cloudAce_t*)OICCalloc(1, sizeof(cloudAce_t));
+ jobject element = env->GetObjectArrayElement(jcloudAces, i);
+ if (!element || env->ExceptionCheck())
+ {
+ return nullptr;
+ }
+ //get aclID
+ jData = (jstring) env->CallObjectMethod(element, g_mid_OcOicSecCloudAcl_ace_get_aclId);
+ if (!jData || env->ExceptionCheck())
+ {
+ return nullptr;
+ }
+ str = (char*) env->GetStringUTFChars(jData, 0);
+ aces->aceId = strdup(str);
+ env->ReleaseStringUTFChars(jData, str);
+
+ //get subjectID
+ jData = (jstring) env->CallObjectMethod(element, g_mid_OcOicSecCloudAcl_ace_get_subjectID);
+ if (!jData || env->ExceptionCheck())
+ {
+ return nullptr;
+ }
+ str = (char*) env->GetStringUTFChars(jData, 0);
+ if (OC_STACK_OK == ConvertStrToUuid(str, &aces->subjectuuid))
+ {
+ env->ReleaseStringUTFChars(jData, str);
+ }
+ else
+ {
+ return nullptr;
+ }
+ //get permission
+ jint permType = (jint)env->CallIntMethod(element, g_mid_OcOicSecCloudAcl_ace_get_permission);
+ aces->permission = (uint16_t)permType;
+ //get stype
+ permType = (jint)env->CallIntMethod(element, g_mid_OcOicSecCloudAcl_ace_get_stype);
+ aces->stype = (uint16_t)permType;
+ //get resources List
+ if (nullptr == (aces->resources = getResourcesList(env, element)))
+ {
+ return nullptr;
+ }
+ aces->validities = NULL;
+ //get validities
+ if (nullptr == (aces->validities = getValiditiesList(env, element)))
+ {
+ return nullptr;
+ }
+ // create list
+ if (NULL == acesHead)
+ {
+ acesHead = aces;
+ }
+ else
+ {
+ cloudAce_t *ptr = acesHead;
+ while(ptr->next != NULL) ptr = ptr->next;
+ ptr->next = aces;
+ aces->next = NULL;
+ }
+ }
+ return acesHead;
+}
+
+OCStackResult JniOcCloudProvisioning::updateIndividualACL(JNIEnv* env, jobject jListener,
+ std::string aclID, jobjectArray jcloudAces)
+{
+ JniOcCloudResultListener *resultListener = AddCloudResultListener(env, jListener);
+
+ cloudAce_t *aces = NULL;
+ aces = ConvertJavaCloudAcestoOCAces(env, jcloudAces);
+
+ ResponseCallBack responseCallBack = [resultListener](OCStackResult result, void *data)
+ {
+ resultListener->CloudResultListenerCB(result, data, ListenerFunc::UPDATE_IND_ACL);
+
+ };
+
+ return m_sharedCloudObject->updateIndividualACL(aces, aclID, responseCallBack);
+}
+
/*
* Class: org_iotivity_base_OcCloudProvisioning
* Method: requestCertificate
}
return;
}
+/*
+ * Class: org_iotivity_base_OcCloudProvisioning
+ * Method: updateIndividualACL
+ * Signature: (Ljava/lang/String;Ljava/lang/Object;Lorg/iotivity/base/OcCloudProvisioning/UpdateIndividualACLListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_updateIndividualACL0
+ (JNIEnv *env, jobject thiz, jstring jaclID, jobjectArray jcloudAces, jobject jListener)
+{
+ LOGD("OcCloudProvisioning_updateIndividualACL");
+ if (!jListener)
+ {
+ ThrowOcException(OC_STACK_INVALID_CALLBACK, "Listener cannot be null");
+ return;
+ }
+ if (!jaclID)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "aclID cannot be null");
+ return;
+ }
+
+ JniOcCloudProvisioning *cloud = JniOcCloudProvisioning::getJniOcCloudProvisioningPtr(env, thiz);
+ if (!cloud)
+ {
+ LOGD("OcCloudProvisioning_updateIndividualACL, No native object, creating now");
+ cloud = Create_native_object(env, thiz);
+ if (!cloud)
+ {
+ ThrowOcException(OC_STACK_ERROR, "OcCloudProvisioning_updateIndividualACL,"
+ "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->updateIndividualACL(env, jListener, aclID, jcloudAces);
+ if (OC_STACK_OK != result)
+ {
+ ThrowOcException(result, "OcCloudProvisioning_updateIndividualACL");
+ return;
+ }
+ }
+ catch (OCException& e)
+ {
+ LOGE("%s", e.reason().c_str());
+ ThrowOcException(e.code(), e.reason().c_str());
+ }
+ return;
+}
+
/*
* Class: org_iotivity_base_OcCloudProvisioning
OCStackResult postCRL(JNIEnv* env, const std::string& thisUpdate,
const std::string& nextUpdate, const OCByteString *crl,
const stringArray_t *serialNumbers, jobject jListener);
+ OCStackResult updateIndividualACL(JNIEnv* env, jobject jListener,
+ std::string aclID, jobjectArray jcloudAces);
private:
std::map<jobject, std::pair<JniOcCloudResultListener*, int>> resultMap;
/*
* Class: org_iotivity_base_OcCloudProvisioning
+ * Method: updateIndividualACL
+ * Signature: (Ljava/lang/String;Ljava/lang/Object;Lorg/iotivity/base/OcCloudProvisioning/UpdateIndividualACLListener;)V
+ */
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcCloudProvisioning_updateIndividualACL0
+ (JNIEnv *, jobject, jstring, jobjectArray, 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
*/
calledFunc = "postCRLListener";
}
break;
+ case ListenerFunc::UPDATE_IND_ACL:
+ {
+ calledFunc = "updateIndividualACLListener";
+ }
+ break;
default:
{
checkExAndRemoveListener(env);
REQUEST_CERTIFICATE = 1,
GET_ACLINFO,
GET_CRL,
- POST_CRL
+ POST_CRL,
+ UPDATE_IND_ACL
};
class JniOcCloudResultListener
jclass g_cls_OcAccountManager = nullptr;
#ifdef __WITH_TLS__
jclass g_cls_OcCloudProvisioning = nullptr;
+jclass g_cls_OcOicSecCloudAcl_ace = nullptr;
#endif
#endif
#ifdef WITH_CLOUD
#ifdef __WITH_TLS__
+jmethodID g_mid_OcOicSecCloudAcl_ace_get_aclId = nullptr;
+jmethodID g_mid_OcOicSecCloudAcl_ace_get_subjectID = nullptr;
+jmethodID g_mid_OcOicSecCloudAcl_ace_get_stype = nullptr;
+jmethodID g_mid_OcOicSecCloudAcl_ace_get_permission = nullptr;
+jmethodID g_mid_OcOicSecCloudAcl_ace_get_resources = nullptr;
+jmethodID g_mid_OcOicSecCloudAcl_ace_get_validities = nullptr;
+
jmethodID g_mid_OcCloudProvisioning_getIP = nullptr;
jmethodID g_mid_OcCloudProvisioning_getPort = nullptr;
#endif
#ifdef SECURED
#ifdef WITH_CLOUD
#ifdef __WITH_TLS__
+
+ //OicSecCloudAce
+ clazz = env->FindClass("org/iotivity/base/OicSecCloudAce");
+ VERIFY_VARIABLE_NULL(clazz);
+ g_cls_OcOicSecCloudAcl_ace = (jclass)env->NewGlobalRef(clazz);
+ env->DeleteLocalRef(clazz);
+
+ g_mid_OcOicSecCloudAcl_ace_get_aclId = env->GetMethodID(g_cls_OcOicSecCloudAcl_ace, "getSubjectID","()Ljava/lang/String;");
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecCloudAcl_ace_get_aclId);
+
+ g_mid_OcOicSecCloudAcl_ace_get_subjectID = env->GetMethodID(g_cls_OcOicSecCloudAcl_ace, "getSubjectID","()Ljava/lang/String;");
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecCloudAcl_ace_get_subjectID);
+
+ g_mid_OcOicSecCloudAcl_ace_get_stype = env->GetMethodID(g_cls_OcOicSecCloudAcl_ace, "getStype","()I");
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecCloudAcl_ace_get_stype);
+
+ g_mid_OcOicSecCloudAcl_ace_get_permission = env->GetMethodID(g_cls_OcOicSecCloudAcl_ace, "getPermission","()I");
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecCloudAcl_ace_get_permission);
+
+ g_mid_OcOicSecCloudAcl_ace_get_resources = env->GetMethodID(g_cls_OcOicSecCloudAcl_ace,
+ "getResources","()[Lorg/iotivity/base/OicSecResr;");
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecCloudAcl_ace_get_resources);
+
+ g_mid_OcOicSecCloudAcl_ace_get_validities = env->GetMethodID(g_cls_OcOicSecCloudAcl_ace,
+ "getValidities","()[Lorg/iotivity/base/OicSecValidity;");
+ VERIFY_VARIABLE_NULL(g_mid_OcOicSecCloudAcl_ace_get_validities);
+
+
//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;");
+ 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");
+ g_mid_OcCloudProvisioning_getPort = env->GetMethodID(g_cls_OcCloudProvisioning,
+ "getPort", "()I");
VERIFY_VARIABLE_NULL(g_mid_OcCloudProvisioning_getPort);
#endif
#endif
env->DeleteGlobalRef(g_cls_OcAccountManager);
#ifdef __WITH_TLS__
env->DeleteGlobalRef(g_cls_OcCloudProvisioning);
+ env->DeleteGlobalRef(g_cls_OcOicSecCloudAcl_ace);
#endif
#endif
env->DeleteGlobalRef(g_cls_OcOicSecAcl);
#endif
#ifdef __WITH_TLS__
extern jclass g_cls_OcCloudProvisioning;
+extern jclass g_cls_OcOicSecCloudAcl_ace;
#endif
extern jclass g_cls_OcOicSecAcl_ace;
#ifdef __WITH_TLS__
extern jmethodID g_mid_OcCloudProvisioning_getIP;
extern jmethodID g_mid_OcCloudProvisioning_getPort;
+extern jmethodID g_mid_OcOicSecCloudAcl_ace_get_aclId;
+extern jmethodID g_mid_OcOicSecCloudAcl_ace_get_subjectID;
+extern jmethodID g_mid_OcOicSecCloudAcl_ace_get_stype;
+extern jmethodID g_mid_OcOicSecCloudAcl_ace_get_permission;
+extern jmethodID g_mid_OcOicSecCloudAcl_ace_get_resources;
+extern jmethodID g_mid_OcOicSecCloudAcl_ace_get_validities;
#endif
extern jmethodID g_mid_OcOicSecAcl_get_rownerID;
OCStackResult getCRL(ResponseCallBack callback);
/**
+ * API for updation of Individual Acl
+ * @param aces is the list of Access control entities for updation.
+ * @param callback function called by the stack on completion of request
+ * @return ::OC_STACK_OK on Success and other values otherwise
+ */
+ OCStackResult updateIndividualACL(const cloudAce_t *aces, std::string &aclId,
+ ResponseCallBack callback);
+
+ /**
* API to post the certificate revocation list to cloud
* @param thisUpdate thisUpdate [mandatory param]
* @param nextUpdate nextUpdate [mandatory param]
return result;
}
+ OCStackResult OCCloudProvisioning::updateIndividualACL(const cloudAce_t *aces, std::string& aclId, ResponseCallBack callback)
+ {
+ if (!callback)
+ {
+ oclog() <<"Result callback can't be null";
+ return OC_STACK_INVALID_CALLBACK;
+ }
+ if (!aces)
+ {
+ oclog() <<"Aces List can not be empty";
+ return OC_STACK_INVALID_CALLBACK;
+ }
+ OCStackResult result;
+ auto cLock = OCPlatform_impl::Instance().csdkLock().lock();
+
+ if (cLock)
+ {
+ CloudProvisionContext *context = new CloudProvisionContext(callback);
+
+ std::lock_guard<std::recursive_mutex> lock(*cLock);
+ result = OCCloudAclIndividualAclUpdate(static_cast<void*>(context), aclId.c_str(),
+ aces, &m_devAddr, &OCCloudProvisioning::callbackWrapper);
+ }
+ else
+ {
+ oclog() <<"Mutex not found";
+ result = OC_STACK_ERROR;
+ }
+ return result;
+ }
+
OCStackResult OCCloudProvisioning::postCRL(const std::string& thisUpdate,
const std::string& nextUpdate,
const OCByteString *crl,