001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2014-2015 ForgeRock AS 025 */ 026package org.forgerock.opendj.ldap.schema; 027 028import org.forgerock.util.Option; 029 030import static org.forgerock.opendj.ldap.schema.SchemaConstants.*; 031 032/** 033 * Common options for LDAP schemas. 034 * <p> 035 * For example you set schema option as you want when using a schema. 036 * 037 * <pre> 038 * // Retrieves options from builder. 039 * SchemaOptions options = new SchemaBuilder().getOptions(); 040 * // Creates a new option. 041 * Option myIntegerOption = options.set(Option.of(Integer.class, 0)); 042 * // Retrieves option value from SchemaOption 043 * boolean allowMalformedNamesAndOptions = options.get(SchemaOptions.ALLOW_MALFORMED_NAMES_AND_OPTIONS); 044 * </pre> 045 */ 046public final class SchemaOptions { 047 /** 048 * Specifies whether the schema should allow certain illegal 049 * characters in OIDs and attribute options. When this compatibility option 050 * is set to {@code true} the following illegal characters will be permitted 051 * in addition to those permitted in section 1.4 of RFC 4512: 052 * 053 * <pre> 054 * USCORE = %x5F ; underscore ("_") 055 * DOT = %x2E ; period (".") 056 * </pre> 057 * 058 * By default this compatibility option is set to {@code true} because these 059 * characters are often used for naming purposes (such as collation rules). 060 */ 061 public static final Option<Boolean> ALLOW_MALFORMED_NAMES_AND_OPTIONS = 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}