MCPcopy Index your code
hub / github.com/cedar-policy/cedar-java / parse_policies_internal

Function parse_policies_internal

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

Source from the content-addressed store, hash-verified

654}
655
656fn parse_policies_internal<'a>(
657 env: &mut JNIEnv<'a>,
658 policies_jstr: JString<'a>,
659) -> Result<JValueOwned<'a>> {
660 if policies_jstr.is_null() {
661 raise_npe(env)
662 } else {
663 // Parse the string into the Rust PolicySet
664 let policies_jstring = env.get_string(&policies_jstr)?;
665 let policies_string = String::from(policies_jstring);
666 let policy_set = PolicySet::from_str(&policies_string)?;
667
668 // Enumerate over the parsed policies
669 let mut policies_java_hash_set = Set::new(env)?;
670 for policy in policy_set.policies() {
671 let policy_id = format!("{}", policy.id());
672 let policy_text = format!("{}", policy);
673 let java_policy_object = JPolicy::new(
674 env,
675 &env.new_string(&policy_text)?,
676 &env.new_string(&policy_id)?,
677 )?;
678 let _ = policies_java_hash_set.add(env, java_policy_object);
679 }
680
681 let mut templates_java_hash_set = Set::new(env)?;
682 for template in policy_set.templates() {
683 let policy_id = format!("{}", template.id());
684 let policy_text = format!("{}", template);
685 let java_policy_object = JPolicy::new(
686 env,
687 &env.new_string(&policy_text)?,
688 &env.new_string(&policy_id)?,
689 )?;
690 let _ = templates_java_hash_set.add(env, java_policy_object);
691 }
692
693 let java_policy_set = create_java_policy_set(
694 env,
695 policies_java_hash_set.as_ref(),
696 templates_java_hash_set.as_ref(),
697 );
698
699 Ok(JValueGen::Object(java_policy_set))
700 }
701}
702
703fn create_java_policy_set<'a>(
704 env: &mut JNIEnv<'a>,

Callers 1

parsePoliciesJniFunction · 0.85

Calls 5

raise_npeFunction · 0.85
create_java_policy_setFunction · 0.85
ObjectInterface · 0.85
addMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected