コード例 #1
0
ファイル: jni.go プロジェクト: vanadium/go.jni
//export Java_io_v_v23_security_access_AccessList_nativeIncludes
func Java_io_v_v23_security_access_AccessList_nativeIncludes(jenv *C.JNIEnv, jAccessList C.jobject, goRef C.jlong, jBlessings C.jobjectArray) C.jboolean {
	env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
	blessings, err := jutil.GoStringArray(env, jutil.Object(uintptr(unsafe.Pointer(jBlessings))))
	if err != nil {
		jutil.JThrowV(env, err)
		return C.JNI_FALSE
	}
	ok := (*(*access.AccessList)(jutil.GoRefValue(jutil.Ref(goRef)))).Includes(blessings...)
	if ok {
		return C.JNI_TRUE
	}
	return C.JNI_FALSE
}
コード例 #2
0
ファイル: jni.go プロジェクト: vanadium/go.jni
//export Java_io_v_v23_security_BlessingPattern_nativeIsMatchedBy
func Java_io_v_v23_security_BlessingPattern_nativeIsMatchedBy(jenv *C.JNIEnv, jBlessingPattern C.jobject, goRef C.jlong, jBlessings C.jobjectArray) C.jboolean {
	env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
	blessings, err := jutil.GoStringArray(env, jutil.Object(uintptr(unsafe.Pointer(jBlessings))))
	if err != nil {
		jutil.JThrowV(env, err)
		return C.JNI_FALSE
	}

	matched := (*(*security.BlessingPattern)(jutil.GoRefValue(jutil.Ref(goRef)))).MatchedBy(blessings...)
	if matched {
		return C.JNI_TRUE
	}
	return C.JNI_FALSE
}
コード例 #3
0
ファイル: jni.go プロジェクト: vanadium/go.jni
//export Java_io_v_v23_security_BlessingStoreImpl_nativeForPeer
func Java_io_v_v23_security_BlessingStoreImpl_nativeForPeer(jenv *C.JNIEnv, jBlessingStoreImpl C.jobject, goRef C.jlong, jPeerBlessings C.jobjectArray) C.jobject {
	env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
	peerBlessings, err := jutil.GoStringArray(env, jutil.Object(uintptr(unsafe.Pointer(jPeerBlessings))))
	if err != nil {
		jutil.JThrowV(env, err)
		return nil
	}
	blessings := (*(*security.BlessingStore)(jutil.GoRefValue(jutil.Ref(goRef)))).ForPeer(peerBlessings...)
	jBlessings, err := JavaBlessings(env, blessings)
	if err != nil {
		jutil.JThrowV(env, err)
		return nil
	}
	return C.jobject(unsafe.Pointer(jBlessings))
}
コード例 #4
0
ファイル: jni.go プロジェクト: vanadium/go.jni
//export Java_io_v_v23_i18n_Catalog_nativeFormatParams
func Java_io_v_v23_i18n_Catalog_nativeFormatParams(jenv *C.JNIEnv, jCatalog C.jclass, jFormat C.jstring, jParams C.jobjectArray) C.jstring {
	env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
	format := jutil.GoString(env, jutil.Object(uintptr(unsafe.Pointer(jFormat))))
	strParams, err := jutil.GoStringArray(env, jutil.Object(uintptr(unsafe.Pointer(jParams))))
	if err != nil {
		jutil.JThrowV(env, err)
		return nil
	}
	params := make([]interface{}, len(strParams))
	for i, strParam := range strParams {
		params[i] = strParam
	}
	result := i18n.FormatParams(format, params...)
	jRet := jutil.JString(env, result)
	return C.jstring(unsafe.Pointer(jRet))
}