| 601 | } |
| 602 | |
| 603 | fn parse_policy_internal<'a>( |
| 604 | env: &mut JNIEnv<'a>, |
| 605 | policy_jstr: JString<'a>, |
| 606 | ) -> Result<JValueOwned<'a>> { |
| 607 | if policy_jstr.is_null() { |
| 608 | raise_npe(env) |
| 609 | } else { |
| 610 | let policy_jstring = env.get_string(&policy_jstr)?; |
| 611 | let policy_string = String::from(policy_jstring); |
| 612 | match Policy::from_str(&policy_string) { |
| 613 | Err(e) => Err(Box::new(e)), |
| 614 | Ok(p) => { |
| 615 | let policy_text = format!("{}", p); |
| 616 | Ok(JValueGen::Object(env.new_string(&policy_text)?.into())) |
| 617 | } |
| 618 | } |
| 619 | } |
| 620 | } |
| 621 | |
| 622 | #[jni_fn("com.cedarpolicy.model.policy.PolicySet")] |
| 623 | pub fn policySetToJson<'a>(mut env: JNIEnv<'a>, _: JClass, policies_jstr: JString<'a>) -> jvalue { |