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

Function validate_entities

CedarJavaFFI/src/interface.rs:494–522  ·  view source on GitHub ↗

public string-based JSON interface to be invoked by FFIs. Takes in a `ValidateEntityCall` and (if successful) returns unit value () which is null value when serialized to json.

(input: &str)

Source from the content-addressed store, hash-verified

492/// public string-based JSON interface to be invoked by FFIs. Takes in a `ValidateEntityCall` and (if successful)
493/// returns unit value () which is null value when serialized to json.
494pub fn validate_entities(input: &str) -> serde_json::Result<Answer> {
495 let validate_entity_call = from_str::<ValidateEntityCall>(&input)?;
496 let schema = match validate_entity_call.schema {
497 Value::String(cedarschema_str) => match Schema::from_cedarschema_str(&cedarschema_str) {
498 Ok(s) => s.0,
499 Err(e) => return Ok(Answer::fail_bad_request(vec![e.to_string()])),
500 },
501 cedarschema_json_obj => match Schema::from_json_value(cedarschema_json_obj) {
502 Ok(s) => s,
503 Err(e) => return Ok(Answer::fail_bad_request(vec![e.to_string()])),
504 },
505 };
506
507 match CedarEntities::from_json_value(validate_entity_call.entities, Some(&schema)) {
508 Err(error) => {
509 let err_message = match error {
510 EntitiesError::Serialization(err) => err.to_string(),
511 EntitiesError::Deserialization(err) => err.to_string(),
512 EntitiesError::Duplicate(err) => err.to_string(),
513 EntitiesError::TransitiveClosureError(err) => err.to_string(),
514 EntitiesError::InvalidEntity(err) => err.to_string(),
515 };
516 Ok(Answer::fail_bad_request(vec![err_message]))
517 }
518 Ok(_entities) => Ok(Answer::Success {
519 result: "null".to_string(),
520 }),
521 }
522}
523
524#[derive(Debug, Serialize, Deserialize)]
525struct JavaInterfaceCall {

Callers 1

json_validate_entitiesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected