001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2014-2016 ForgeRock AS. 015 */ 016package org.forgerock.opendj.ldap.schema; 017 018import org.forgerock.util.Option; 019 020import static org.forgerock.opendj.ldap.schema.SchemaConstants.*; 021 022/** 023 * Common options for LDAP schemas. 024 * <p> 025 * For example you set schema option as you want when using a schema. 026 * 027 * <pre> 028 * // Retrieves options from builder. 029 * SchemaOptions options = new SchemaBuilder().getOptions(); 030 * // Creates a new option. 031 * Option myIntegerOption = options.set(Option.of(Integer.class, 0)); 032 * // Retrieves option value from SchemaOption 033 * boolean allowMalformedNamesAndOptions = options.get(SchemaOptions.ALLOW_MALFORMED_NAMES_AND_OPTIONS); 034 * </pre> 035 */ 036public final class SchemaOptions { 037 /** 038 * Specifies whether the schema should allow certain illegal 039 * characters in OIDs and attribute options. When this compatibility option 040 * is set to {@code true} the following illegal characters will be permitted 041 * in addition to those permitted in section 1.4 of RFC 4512: 042 * 043 * <pre> 044 * USCORE = %x5F ; underscore ("_") 045 * DOT = %x2E ; period (".") 046 * </pre> 047 * 048 * By default this compatibility option is set to {@code true} because these 049 * characters are often used for naming purposes (such as collation rules). 050 */ 051 public static final Option<Boolean> ALLOW_MALFORMED_NAMES_AND_OPTIONS = Option.withDefault(true); 052 053 /** 054 * Specifies whether the schema should allow attribute type definitions that do not declare a superior attribute 055 * type or syntax. When this compatibility option is set to {@code true} invalid attribute type definitions will 056 * use the default syntax specifed by the {@link #DEFAULT_SYNTAX_OID} option. 057 * <p> 058 * By default this compatibility option is set to {@code true} in order to remain compatible with previous 059 * versions of OpenDJ. 060 */ 061 public static final Option<Boolean> ALLOW_ATTRIBUTE_TYPES_WITH_NO_SUP_OR_SYNTAX = Option.withDefault(true); 062 063 /** 064 * Specifies whether the JPEG Photo syntax should allow values which 065 * do not conform to the JFIF or Exif specifications. 066 * <p> 067 * By default this compatibility option is set to {@code true}. 068 */ 069 public static final Option<Boolean> ALLOW_MALFORMED_JPEG_PHOTOS = Option.withDefault(true); 070 071 /** 072 * Specifies whether the Certificate syntax should allow values which 073 * do not conform to the X.509 specifications. 074 * <p> 075 * By default this compatibility option is set to {@code true}. 076 */ 077 public static final Option<Boolean> ALLOW_MALFORMED_CERTIFICATES = Option.withDefault(true); 078 079 /** 080 * Specifies whether the Telephone Number syntax should allow values 081 * which do not conform to the E.123 international telephone number format. 082 * <p> 083 * By default this compatibility option is set to {@code true}. 084 */ 085 public static final Option<Boolean> ALLOW_NON_STANDARD_TELEPHONE_NUMBERS = Option.withDefault(true); 086 087 /** 088 * Specifies whether zero-length values will be allowed by the 089 * Directory String syntax. This is technically forbidden by the LDAP 090 * specification, but it was allowed in earlier versions of the server, and 091 * the discussion of the directory string syntax in RFC 2252 does not 092 * explicitly state that they are not allowed. 093 * <p> 094 * By default this compatibility option is set to {@code false}. 095 */ 096 public static final Option<Boolean> ALLOW_ZERO_LENGTH_DIRECTORY_STRINGS = Option.withDefault(false); 097 098 /** 099 * Specifies the OID of the default syntax which will be used when parsing 100 * unrecognized attributes. 101 * <p> 102 * By default the {@link SchemaConstants#SYNTAX_OCTET_STRING_OID OctetString} 103 * syntax will be used. 104 */ 105 public static final Option<String> DEFAULT_SYNTAX_OID = Option.of(String.class, SYNTAX_OCTET_STRING_OID); 106 107 /** 108 * Specifies the OID of the default matching rule which will be used when 109 * parsing unrecognized attributes. 110 * <p> 111 * By default the {@link SchemaConstants#EMR_OCTET_STRING_OID OctetString} 112 * matching rule will be used. 113 */ 114 public static final Option<String> DEFAULT_MATCHING_RULE_OID = Option.of(String.class, EMR_OCTET_STRING_OID); 115 116 /** 117 * Indicates whether country code values are required to strictly 118 * comply with the standard definition for this syntax. 119 * <p> 120 * When set to false, country codes will not be validated and, as a result 121 * any string containing 2 characters will be acceptable. 122 * By default this compatibility option is set to {@code true}. 123 */ 124 public static final Option<Boolean> STRICT_FORMAT_FOR_COUNTRY_STRINGS = Option.withDefault(true); 125 126 /** 127 * Indicates whether the minimum upper bound value should be stripped from 128 * the Attribute Type Syntax Description. 129 * <p> 130 * By default this compatibility option is set to {@code false}. 131 */ 132 public static final Option<Boolean> STRIP_UPPER_BOUND_FOR_ATTRIBUTE_TYPE = Option.withDefault(false); 133 134 private SchemaOptions() { } 135}