Ejemplo n.º 1
0
//export Java_io_v_impl_google_rpc_ServerRPCHelper_nativeGoAuthorizer
func Java_io_v_impl_google_rpc_ServerRPCHelper_nativeGoAuthorizer(jenv *C.JNIEnv, jServerRPCHelper C.jclass, jAuthorizer C.jobject) C.jlong {
	env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
	auth, err := jsecurity.GoAuthorizer(env, jutil.Object(uintptr(unsafe.Pointer(jAuthorizer))))
	if err != nil {
		jutil.JThrowV(env, err)
		return C.jlong(0)
	}
	ref := jutil.GoNewRef(&auth) // Un-refed when the Go authorizer is returned to the Go runtime
	return C.jlong(ref)
}
Ejemplo n.º 2
0
func getAuthorizer(env jutil.Env, obj jutil.Object, field string) (security.Authorizer, error) {
	jAuthorizer, err := jutil.JObjectField(env, obj, field, authorizerSign)
	if err != nil {
		return nil, err
	}

	if !jAuthorizer.IsNull() {
		auth, err := jsecurity.GoAuthorizer(env, jAuthorizer)
		if err != nil {
			return nil, err
		}
		return auth, nil
	}
	return nil, nil
}