MCPcopy Create free account
hub / github.com/cedar-policy/cedar-java / policy_set_to_json_internal

Function policy_set_to_json_internal

CedarJavaFFI/src/interface.rs:630–646  ·  view source on GitHub ↗
(
    env: &mut JNIEnv<'a>,
    policy_set_jstr: JString<'a>,
)

Source from the content-addressed store, hash-verified

628}
629
630fn policy_set_to_json_internal<'a>(
631 env: &mut JNIEnv<'a>,
632 policy_set_jstr: JString<'a>,
633) -> Result<JValueOwned<'a>> {
634 if policy_set_jstr.is_null() {
635 raise_npe(env)
636 } else {
637 let policy_set_jstring = env.get_string(&policy_set_jstr)?;
638 let policy_set_string = String::from(policy_set_jstring);
639 let policy_set_ffi: PolicySetFFI = serde_json::from_str(&policy_set_string)?;
640 let policy_set = policy_set_ffi
641 .parse()
642 .map_err(|err| format!("Error parsing policy set: {:?}", err))?;
643 let policy_set_json = serde_json::to_string(&policy_set.to_json().unwrap())?;
644 Ok(JValueGen::Object(env.new_string(&policy_set_json)?.into()))
645 }
646}
647
648#[jni_fn("com.cedarpolicy.model.policy.PolicySet")]
649pub fn parsePoliciesJni<'a>(mut env: JNIEnv<'a>, _: JClass, policies_jstr: JString<'a>) -> jvalue {

Callers 3

policySetToJsonFunction · 0.85

Calls 3

raise_npeFunction · 0.85
ObjectInterface · 0.85
parseMethod · 0.45

Tested by 2