Class JsonSchema
- java.lang.Object
-
- org.forgerock.opendj.rest2ldap.schema.JsonSchema
-
public final class JsonSchema extends Object
Utility methods for obtaining JSON syntaxes and matching rules. See the package documentation for more detail.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJsonSchema.ValidationPolicyJSON value validation policies.
-
Field Summary
Fields Modifier and Type Field Description static org.forgerock.util.Option<Boolean>CASE_SENSITIVE_STRINGSMatching rule option controlling whether JSON string comparisons should be case-sensitive.static org.forgerock.util.Option<Boolean>IGNORE_WHITE_SPACEMatching rule option controlling whether JSON string comparisons should ignore white-space.static org.forgerock.util.Option<Collection<String>>INDEXED_FIELD_PATTERNSMatching rule option controlling which JSON fields should be indexed by the matching rule.static org.forgerock.util.Option<JsonSchema.ValidationPolicy>VALIDATION_POLICYSchema option controlling syntax validation for JSON based attributes.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SchemaBuilderaddJsonSyntaxesAndMatchingRulesToSchema(SchemaBuilder builder)Adds the syntaxes and matching rules required by for JSON attribute support to the provided schema builder.static org.forgerock.util.Function<ByteString,Object,org.forgerock.i18n.LocalizedIllegalArgumentException>byteStringToJson()Returns a function which parsesJSONvalues.static MatchingRulegetCaseExactJsonQueryMatchingRule()Returns thejsonQueryMatchmatching rule having the OID 1.3.6.1.4.1.36733.2.1.4.2.static MatchingRulegetCaseIgnoreJsonQueryMatchingRule()Returns thejsonQueryMatchmatching rule having the OID 1.3.6.1.4.1.36733.2.1.4.1.static SyntaxgetJsonQuerySyntax()Returns the JSON Query attribute syntax having the OID 1.3.6.1.4.1.36733.2.1.3.2.static SyntaxgetJsonSyntax()Returns the JSON attribute syntax having the OID 1.3.6.1.4.1.36733.2.1.3.1.static org.forgerock.util.Function<Object,ByteString,com.fasterxml.jackson.core.JsonProcessingException>jsonToByteString()Returns a function which converts a JSONObjectto aByteString.static MatchingRuleImplnewJsonQueryEqualityMatchingRuleImpl(String matchingRuleName, org.forgerock.util.Options options)Creates a new custom JSON query equality matching rule implementation with the provided matching rule name and options.
-
-
-
Field Detail
-
VALIDATION_POLICY
public static final org.forgerock.util.Option<JsonSchema.ValidationPolicy> VALIDATION_POLICY
Schema option controlling syntax validation for JSON based attributes. By default this compatibility option is set toJsonSchema.ValidationPolicy.STRICT.
-
CASE_SENSITIVE_STRINGS
public static final org.forgerock.util.Option<Boolean> CASE_SENSITIVE_STRINGS
Matching rule option controlling whether JSON string comparisons should be case-sensitive. By default this compatibility option is set tofalsemeaning that case will be ignored.This option must be provided when constructing a JSON matching rule using
newJsonQueryEqualityMatchingRuleImpl(java.lang.String, org.forgerock.util.Options), and cannot be overridden at the schema level.
-
IGNORE_WHITE_SPACE
public static final org.forgerock.util.Option<Boolean> IGNORE_WHITE_SPACE
Matching rule option controlling whether JSON string comparisons should ignore white-space. By default this compatibility option is set totruemeaning that leading and trailing white-space will be ignored and intermediate white-space will be reduced to a single white-space character.This option must be provided when constructing a JSON matching rule using
newJsonQueryEqualityMatchingRuleImpl(java.lang.String, org.forgerock.util.Options), and cannot be overridden at the schema level.
-
INDEXED_FIELD_PATTERNS
public static final org.forgerock.util.Option<Collection<String>> INDEXED_FIELD_PATTERNS
Matching rule option controlling which JSON fields should be indexed by the matching rule. By default all fields will be indexed. To restrict the set of indexed fields specify a list whose values are wild-card patterns for matching against JSON pointers. Patterns are JSON pointers where "*" represents zero or more characters in a single path element, and "**" represents any number of path elements. For example:JSON pointer pattern matching examples Pattern Matches Doesn't match /aaa/bbb/ccc /aaa/bbb/ccc /aaa/bbb/ccc/ddd
/aaa/bbb/cccc/aaa/b*/ccc /aaa/bbb/ccc
/aaa/bxx/ccc/aaa/xxx/ccc
/aaa/bbb/aaa/**/ddd /aaa/ddd
/aaa/xxx/yyy/ddd/aaa/bbb/ccc /aaa/** /aaa
/aaa/bbb
/aaa/bbb/ccc/aa
-
-
Method Detail
-
getJsonSyntax
public static Syntax getJsonSyntax()
Returns the JSON attribute syntax having the OID 1.3.6.1.4.1.36733.2.1.3.1. Attribute values of this syntax must be valid JSON. Use theVALIDATION_POLICYschema option to control the degree of syntax enforcement. By default JSON attributes will support equality matching using thejsonQueryMatchmatching rule, although this may be overridden when defining individual attribute types.- Returns:
- The JSON attribute syntax having the OID 1.3.6.1.4.1.36733.2.1.3.1.
-
getJsonQuerySyntax
public static Syntax getJsonQuerySyntax()
Returns the JSON Query attribute syntax having the OID 1.3.6.1.4.1.36733.2.1.3.2. Attribute values of this syntax must be valid CREST JSONquery filterstrings as defined inQueryFilterParser.- Returns:
- The JSON Query attribute syntax having the OID 1.3.6.1.4.1.36733.2.1.3.2.
-
getCaseIgnoreJsonQueryMatchingRule
public static MatchingRule getCaseIgnoreJsonQueryMatchingRule()
Returns thejsonQueryMatchmatching rule having the OID 1.3.6.1.4.1.36733.2.1.4.1. The matching rule's assertion syntax is aCREST JSON query filter. This matching rule will ignore case when comparing JSON strings as well as ignoring white-space. In addition, all JSON fields will be indexed if indexing is enabled.- Returns:
- The @code jsonQueryMatch} matching rule having the OID 1.3.6.1.4.1.36733.2.1.4.1.
-
getCaseExactJsonQueryMatchingRule
public static MatchingRule getCaseExactJsonQueryMatchingRule()
Returns thejsonQueryMatchmatching rule having the OID 1.3.6.1.4.1.36733.2.1.4.2. The matching rule's assertion syntax is aCREST JSON query filter. This matching rule will ignore case when comparing JSON strings as well as ignoring white-space. In addition, all JSON fields will be indexed if indexing is enabled.- Returns:
- The @code jsonQueryMatch} matching rule having the OID 1.3.6.1.4.1.36733.2.1.4.2.
-
newJsonQueryEqualityMatchingRuleImpl
public static MatchingRuleImpl newJsonQueryEqualityMatchingRuleImpl(String matchingRuleName, org.forgerock.util.Options options)
Creates a new custom JSON query equality matching rule implementation with the provided matching rule name and options. This method should be used when creating custom JSON matching rules whose behavior differs fromgetCaseIgnoreJsonQueryMatchingRule().- Parameters:
matchingRuleName- The name of the matching rule. This will be used as the index ID in attribute indexes so it must not collide with other indexes identifiers.options- The options controlling the behavior of the matching rule.- Returns:
- The new custom JSON query equality matching rule implementation.
- See Also:
CASE_SENSITIVE_STRINGS,IGNORE_WHITE_SPACE
-
addJsonSyntaxesAndMatchingRulesToSchema
public static SchemaBuilder addJsonSyntaxesAndMatchingRulesToSchema(SchemaBuilder builder)
Adds the syntaxes and matching rules required by for JSON attribute support to the provided schema builder.- Parameters:
builder- The schema builder to which the schema elements should be added.- Returns:
- The schema builder.
-
byteStringToJson
public static org.forgerock.util.Function<ByteString,Object,org.forgerock.i18n.LocalizedIllegalArgumentException> byteStringToJson()
Returns a function which parsesJSONvalues. Invalid values will result in aLocalizedIllegalArgumentException.- Returns:
- A function which parses
JSONvalues.
-
jsonToByteString
public static org.forgerock.util.Function<Object,ByteString,com.fasterxml.jackson.core.JsonProcessingException> jsonToByteString()
Returns a function which converts a JSONObjectto aByteString.- Returns:
- A function which converts a JSON
Objectto aByteString.
-
-