From 0eb671e7cb4324437780e64a9d23cd66baf6b3ff Mon Sep 17 00:00:00 2001
From: Chris Ridd <chris.ridd@forgerock.com>
Date: Wed, 08 Aug 2012 16:30:08 +0000
Subject: [PATCH] Fix OPENDJ-558 Validation for JPEGSyntax values

---
 opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java
index 4308e87..33e9ae8 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java
@@ -172,6 +172,8 @@
 
     private boolean allowMalformedNamesAndOptions;
 
+    private boolean allowMalformedJPEGPhotos;
+
     // A schema which should be copied into this builder on any mutation.
     private Schema copyOnWriteSchema = null;
 
@@ -2247,6 +2249,26 @@
     }
 
     /**
+     * Specifies whether or not the JPEG Photo syntax should allow values
+     * which do not conform to the JFIF or Exif specifications.
+     * <p>
+     * By default this compatibility option is set to {@code true}.
+     *
+     * @param allowMalformedJPEGPhotos
+     *            {@code true} if the JPEG Photo syntax should allow
+     *            values which do not conform to the JFIF or Exif
+     *            specifications.
+     * @return A reference to this {@code SchemaBuilder}.
+     */
+    public SchemaBuilder allowMalformedJPEGPhotos(
+            final boolean allowMalformedJPEGPhotos) {
+        lazyInitBuilder();
+
+        this.allowMalformedJPEGPhotos = allowMalformedJPEGPhotos;
+        return this;
+    }
+
+    /**
      * Specifies whether or not the Telephone Number syntax should allow values
      * which do not conform to the E.123 international telephone number format.
      * <p>
@@ -2508,8 +2530,9 @@
 
         final Schema schema =
                 new Schema(localSchemaName, allowMalformedNamesAndOptions,
-                        allowNonStandardTelephoneNumbers, allowZeroLengthDirectoryStrings,
-                        numericOID2Syntaxes, numericOID2MatchingRules, numericOID2MatchingRuleUses,
+                        allowMalformedJPEGPhotos, allowNonStandardTelephoneNumbers,
+                        allowZeroLengthDirectoryStrings, numericOID2Syntaxes,
+                        numericOID2MatchingRules, numericOID2MatchingRuleUses,
                         numericOID2AttributeTypes, numericOID2ObjectClasses, numericOID2NameForms,
                         numericOID2ContentRules, id2StructureRules, name2MatchingRules,
                         name2MatchingRuleUses, name2AttributeTypes, name2ObjectClasses,
@@ -2784,6 +2807,7 @@
         // Lazy initialization.
         if (numericOID2Syntaxes == null) {
             allowMalformedNamesAndOptions = true;
+            allowMalformedJPEGPhotos = true;
             allowNonStandardTelephoneNumbers = true;
             allowZeroLengthDirectoryStrings = false;
 
@@ -2814,6 +2838,7 @@
             addSchema0(copyOnWriteSchema, true);
 
             allowMalformedNamesAndOptions = copyOnWriteSchema.allowMalformedNamesAndOptions();
+            allowMalformedJPEGPhotos = copyOnWriteSchema.allowMalformedJPEGPhotos();
             allowNonStandardTelephoneNumbers = copyOnWriteSchema.allowNonStandardTelephoneNumbers();
             allowZeroLengthDirectoryStrings = copyOnWriteSchema.allowZeroLengthDirectoryStrings();
 
@@ -2826,6 +2851,7 @@
         this.copyOnWriteSchema = copyOnWriteSchema;
 
         this.allowMalformedNamesAndOptions = true;
+        this.allowMalformedJPEGPhotos = true;
         this.allowNonStandardTelephoneNumbers = true;
         this.allowZeroLengthDirectoryStrings = false;
 

--
Gitblit v1.10.0