JacksonPolicyConfig
Loads a RoleBasedResourcePolicyResolver from JSON configuration.
The configuration is a JSON object keyed by resource name; each resource maps role names to an array of field policies. placeholder is optional. Parsing is eager and fail-fast — an invalid document or rule throws IhawuCoreException at load time, never at request time:
{
"employee": {
"MANAGER": [ { "field": "salary", "strategy": "REDACT", "placeholder": "***" } ],
"AUDITOR": [ { "field": "ssn", "strategy": "HIDE" } ]
}
}This lives in ihawu-jackson rather than ihawu-core so the core stays free of a serialization dependency; the parsed ResourcePolicy rules it produces are plain core types.
Samples
// The same rules expressed as JSON configuration: resource -> role -> field policies.
val config =
"""
{
"employee": {
"MANAGER": [ { "field": "salary", "strategy": "REDACT", "placeholder": "***" } ]
}
}
""".trimIndent()
val resolver = JacksonPolicyConfig.fromJson(config)
val principal = IhawuPrincipal("u1", roles = setOf("MANAGER"), attributes = emptyMap())
val policies = resolver.resolve(principal, "employee")
check(policies == listOf(FieldPolicy("salary", MaskingStrategy.REDACT, "***")))Functions
Builds a resolver from a JSON configuration InputStream (e.g. a classpath resource). See the class documentation for the schema. Parsing is eager and fail-fast.
Builds a resolver from a JSON configuration String. See the class documentation for the schema. Parsing is eager and fail-fast.