# build android_api
jdk_env = Environment(ENV=os.environ)
-jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + os.getcwd()+'/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED), emitter = ensure_libs)
+jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + os.getcwd()+'/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s -DSECURE=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED, ANDROID_SECURED), emitter = ensure_libs)
jdk_env['BUILD_DIR'] = env.get('BUILD_DIR')
cmdBuildApi=jdk_env.Gradle(target="base/objs", source="base/src/main/java/org/iotivity/base/OcResource.java")
-jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'android/examples/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED))
+jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + 'android/examples/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s -PSECURED=%s -DSECURE=%s --stacktrace' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE, ANDROID_SECURED, ANDROID_SECURED))
cmdBuildExamples=jdk_env.Gradle(target="../examples/devicediscoveryclient/apk", source="../examples/devicediscoveryclient/src/main/java/org/iotivity/base/examples/DeviceDiscoveryClient.java")
# android examples require android api to be built before being invoked
LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/ocsocket/include\r
LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/oc_logger/include\r
LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/../extlibs/boost/boost_1_58_0\r
+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/oxm/\r
LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/provisioning/include/internal\r
LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/security/include\r
LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/connectivity/api\r
+LOCAL_C_INCLUDES += $(OIC_SRC_PATH)/csdk/connectivity/lib/libcoap-4.1.1\r
include $(BUILD_SHARED_LIBRARY)\r
jmethodID g_mid_OcOicSecAcl_get_periods_cnt = nullptr;
jmethodID g_mid_OcOicSecAcl_get_periods = nullptr;
jmethodID g_mid_OcOicSecAcl_get_recurrences = nullptr;
-jmethodID g_mid_OcOicSecAcl_get_owners_cnt = nullptr;
-jmethodID g_mid_OcOicSecAcl_get_owners = nullptr;
+jmethodID g_mid_OcOicSecAcl_get_rownerID = nullptr;
jobject getOcException(JNIEnv* env, const char* file, const char* functionName,
const int line, const int code, const char* message)
g_mid_OcOicSecAcl_get_recurrences = env->GetMethodID(g_cls_OcOicSecAcl, "getRecurrences", "(I)Ljava/lang/String;");
if (!g_mid_OcOicSecAcl_get_recurrences) return JNI_ERR;
- g_mid_OcOicSecAcl_get_owners_cnt = env->GetMethodID(g_cls_OcOicSecAcl, "getOwnersCount", "()I");
- if (!g_mid_OcOicSecAcl_get_owners_cnt) return JNI_ERR;
-
- g_mid_OcOicSecAcl_get_owners = env->GetMethodID(g_cls_OcOicSecAcl, "getOwners", "(I)Ljava/lang/String;");
- if (!g_mid_OcOicSecAcl_get_owners) return JNI_ERR;
+ g_mid_OcOicSecAcl_get_rownerID = env->GetMethodID(g_cls_OcOicSecAcl, "getRownerID", "()Ljava/lang/String;");
+ if (!g_mid_OcOicSecAcl_get_rownerID) return JNI_ERR;
return JNI_CURRENT_VERSION;
}
extern jmethodID g_mid_OcOicSecAcl_get_periods_cnt;
extern jmethodID g_mid_OcOicSecAcl_get_periods;
extern jmethodID g_mid_OcOicSecAcl_get_recurrences;
-extern jmethodID g_mid_OcOicSecAcl_get_owners_cnt;
-extern jmethodID g_mid_OcOicSecAcl_get_owners;
+extern jmethodID g_mid_OcOicSecAcl_get_rownerID;
typedef void(*RemoveListenerCallback)(JNIEnv* env, jobject jListener);
#include "JniSecureUtils.h"
#include "JniOcSecureResource.h"
+#include "srmutility.h"
#include "base64.h"
jobject JniSecureUtils::convertProvisionresultVectorToJavaList(JNIEnv *env, const OC::PMResultList_t *result)
return deviceId.str();
}
-void JniSecureUtils::convertStrToUUID(char *str, OicUuid_t &uuid)
-{
- unsigned char base64Buff[sizeof(((OicUuid_t*)0)->id)] = {};
- uint32_t outLen = 0;
- B64Result b64Ret = B64_OK;
-
- b64Ret = b64Decode(str, strlen(str), base64Buff, sizeof(base64Buff), &outLen);
- memcpy(uuid.id, base64Buff, outLen);
-}
-
jobject JniSecureUtils::convertUUIDVectorToJavaStrList(JNIEnv *env, UuidList_t &vector)
{
jobject jList = env->NewObject(g_cls_LinkedList, g_mid_LinkedList_ctor);
}
char *str = (char*) env->GetStringUTFChars(jData, 0);
- convertStrToUUID(str, acl->subject);
- env->ReleaseStringUTFChars(jData, str);
+ if (OC_STACK_OK == ConvertStrToUuid(str, &acl->subject))
+ {
+ env->ReleaseStringUTFChars(jData, str);
+ }
+ else
+ {
+ return OC_STACK_ERROR;
+ }
jint jCount = (jint) env->CallIntMethod(in, g_mid_OcOicSecAcl_get_resources_cnt);
if (!jCount || env->ExceptionCheck())
acl->recurrences[i] = (char*) env->GetStringUTFChars(jData, 0);
}
- jCount = (jint) env->CallIntMethod(in, g_mid_OcOicSecAcl_get_owners_cnt);
- if (!jCount || env->ExceptionCheck())
+ jData = (jstring) env->CallObjectMethod(in, g_mid_OcOicSecAcl_get_rownerID);
+ if (!jData || env->ExceptionCheck())
{
return OC_STACK_ERROR;
}
- acl->ownersLen = jCount;
- acl->owners = new OicUuid_t[acl->ownersLen];
- if (!acl->owners)
- {
- return OC_STACK_ERROR;
- }
+ str = (char*) env->GetStringUTFChars(jData, 0);
- for (jint i = 0; i < jCount; ++i)
+ if (OC_STACK_OK == ConvertStrToUuid(str, &acl->rownerID))
{
- args[0].i = i;
- jData = (jstring) env->CallObjectMethodA(in, g_mid_OcOicSecAcl_get_owners, args);
- if (!jData || env->ExceptionCheck())
- {
- return OC_STACK_ERROR;
- }
-
- str = (char*) env->GetStringUTFChars(jData, 0);
- convertStrToUUID(str, acl->owners[i]);
env->ReleaseStringUTFChars(jData, str);
}
+ else
+ {
+ return OC_STACK_ERROR;
+ }
+
return OC_STACK_OK;
}
System.loadLibrary("octbstack");
System.loadLibrary("connectivity_abstraction");
System.loadLibrary("oc");
- System.loadLibrary("ocprovision");
+ //System.loadLibrary("ocprovision");
System.loadLibrary("ocstack-jni");
}
private List<String> resources;
private List<String> periods;
private List<String> recurrences;
- private List<String> owners;
+ private String rownerID;
public OicSecAcl(String subject, List<String> recurrences, List<String> periods, int permission,
- List<String> resources, List<String> owners) {
+ List<String> resources, String rownerID) {
this.subject = subject;
this.recurrences = recurrences;
this.periods = periods;
this.permission = permission;
this.resources = resources;
- this.owners = owners;
+ this.rownerID = rownerID;
}
public String getSubject() {
this.subject = subject;
}
- public List<String> getOwners() {
- return owners;
- }
- public void setOwners(List<String> owners) {
- this.owners = owners;
+ public void setRownerID(String rownerID) {
+ this.rownerID = rownerID;
}
public List<String> getRecurrences() {
return this.recurrences.get(i);
}
- public int getOwnersCount() {
- return this.owners.size();
- }
-
- public String getOwners(int i) {
- return this.owners.get(i);
+ public String getRownerID() {
+ return this.rownerID;
}
}
"if": ""\r
},\r
{\r
- "href": "/oic/sec/acl",\r
+ "href": "/oic/sec/amacl",\r
"rel": "",\r
"rt": "",\r
"if": ""\r
"rel": "",\r
"rt": "",\r
"if": ""\r
- } ,\r
+ },\r
{\r
"href": "/oic/sec/pstat",\r
"rel": "",\r
"rt": "",\r
"if": ""\r
- }\r
+ } \r
],\r
"permission": 2\r
}\r
]\r
},\r
- "rowneruuid" : "61646d69-6e44-6576-6963-655555494430"\r
- },\r
+ "rowneruuid" : "61646D69-6E44-6576-6963-655575696430"\r
+ }, \r
"pstat": {\r
"isop": true,\r
- "deviceuuid": "61646d69-6e44-6576-6963-655555494430",\r
- "rowneruuid": "61646d69-6e44-6576-6963-655555494430",\r
- "cm": 0,\r
+ "cm": 2,\r
"tm": 0,\r
"om": 3,\r
- "sm": 3\r
- },\r
+ "sm": 3,\r
+ "deviceuuid": "61646D69-6E44-6576-6963-655575696430",\r
+ "rowneruuid": "61646D69-6E44-6576-6963-655575696430"\r
+ },\r
"doxm": {\r
"oxms": [0],\r
"oxmsel": 0,\r
"sct": 1,\r
"owned": true,\r
- "deviceuuid": "61646d69-6e44-6576-6963-655555494430",\r
- "devowneruuid": "61646d69-6e44-6576-6963-655555494430",\r
- "rowneruuid": "61646d69-6e44-6576-6963-655555494430",\r
- "dpc": false\r
+ "deviceuuid": "61646D69-6E44-6576-6963-655575696430",\r
+ "dpc": false,\r
+ "devowneruuid": "61646D69-6E44-6576-6963-655575696430",\r
+ "rowneruuid": "61646D69-6E44-6576-6963-655575696430"\r
}\r
-}
\ No newline at end of file
+}\r
newSecureResource = ownedDeviceList.get(0);
OcSecureResource newSecureResource2 = ownedDeviceList.get(1);
List<String> resources = new ArrayList<String>();
- List<String> owners = new ArrayList<String>();
List<String> periods = new ArrayList<String>();
List<String> recurrences = new ArrayList<String>();
+ String rownerID= "61646d69-6e44-6576-6963-655555494430";
recurrences.add("Daily");
resources.add("*");
- owners.add("adminDeviceUUID0");
+ //owners.add("adminDeviceUUID0");
periods.add("01-01-15");
OicSecAcl acl1 = new OicSecAcl(newSecureResource.getDeviceID(), recurrences, periods,
- 31, resources, owners);
+ 31, resources, rownerID);
OicSecAcl acl2 = new OicSecAcl(newSecureResource2.getDeviceID(), recurrences, periods,
- 31, resources, owners);
+ 31, resources, rownerID);
newSecureResource.provisionPairwiseDevices(EnumSet.of(CredType.SYMMETRIC_PAIR_WISE_KEY),
KeySize.OWNER_PSK_LENGTH_128, acl1, newSecureResource2, acl2, this);
} catch (Exception e) {
OcSecureResource ocSecureResourceDest = ownedDeviceList.get(1);
publishProgress(TAG + "ACL Provision for " + ocSecureResource.getDeviceID());
List<String> resources = new ArrayList<String>();
- List<String> owners = new ArrayList<String>();
+
List<String> periods = new ArrayList<String>();
List<String> recurrences = new ArrayList<String>();
+
+ String rownerID="61646d69-6e44-6576-6963-655555494430";
+
recurrences.add("Daily");
resources.add("*");
- owners.add("adminDeviceUUID0");
+
periods.add("01-01-15");
OicSecAcl aclObject = new OicSecAcl(ocSecureResourceDest.getDeviceID(),
- recurrences, periods, 31, resources, owners);
+ recurrences, periods, 31, resources, rownerID);
ocSecureResource.provisionACL(aclObject, provisionAclListener);
} else {
publishProgress(TAG + "No Owned devices present");
public static final int DISCOVERY_TIMEOUT_10 = 10;
public static final int DISCOVERY_TIMEOUT_20 = 20;
public static final int ERROR_CODE = 1;
- public static final String OIC_CLIENT_JSON_DB_FILE = "oic_svr_db_client.json";
+ public static final String OIC_CLIENT_JSON_DB_FILE = "oic_svr_db_client.dat";
public static final String MESSAGE = "message";
public static final String OIC_SQL_DB_FILE = "Pdm.db";
public static final int CREDENTIAL_TYPE=1;
-include ':simpleserver', ':simpleclient', ':fridgeserver', ':fridgeclient', ':guiclient', ':provisioningclient', ':presenceserver', ':presenceclient', ':devicediscoveryclient', ':devicediscoveryserver', ':groupclient', ':groupserver', ':fridgegroupclient', ':fridgegroupserver'
+include ':simpleserver', ':simpleclient', ':fridgeserver', ':fridgeclient', ':guiclient', ':presenceserver', ':presenceclient', ':devicediscoveryclient', ':devicediscoveryserver', ':groupclient', ':groupserver', ':fridgegroupclient', ':fridgegroupserver'
+SECURED=System.getProperty('SECURE')
+if(SECURED== "1"){
+ include ':provisioningclient'
+}
'../csdk/security/include',
'../csdk/security/provisioning/include',
'../csdk/security/provisioning/include/oxm',
- '../csdk/security/provisioning/include/internal'
+ '../csdk/security/provisioning/include/internal',
+ '../csdk/connectivity/lib/libcoap-4.1.1/',
+ '../../extlibs/cjson/'
])
target_os = env.get('TARGET_OS')
* *****************************************************************/
#include "ocstack.h"
+#include "srmutility.h"
#include "base64.h"
#include "OCProvisioningManager.h"
std::string OCSecureResource::getDeviceID()
{
- char base64Buff[B64ENCODE_OUT_SAFESIZE(sizeof(((OicUuid_t*)0)->id)) + 1] = {0,};
- uint32_t outLen = 0;
- B64Result b64Ret = B64_OK;
std::ostringstream deviceId("");
+ char *devID = nullptr;
validateSecureResource();
- b64Ret = b64Encode(devPtr->doxm->deviceID.id, sizeof(devPtr->doxm->deviceID.id), base64Buff,
- sizeof(base64Buff), &outLen);
- if (B64_OK == b64Ret)
+ if (OC_STACK_OK == ConvertUuidToStr(&(devPtr->doxm->deviceID), &devID))
{
- deviceId << base64Buff;
+ deviceId << devID;
+ }
+ else
+ {
+ oclog() <<"Can not convert uuid to struuid";
}
return deviceId.str();
}