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/Schema.java |   39 +++++++++++++++++++++++++++++++++++++--
 1 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java
index 2c460c8..ad4db1e 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java
@@ -85,6 +85,10 @@
             return true;
         }
 
+        public boolean allowMalformedJPEGPhotos() {
+            return true;
+        }
+
         public boolean allowZeroLengthDirectoryStrings() {
             return false;
         }
@@ -301,6 +305,8 @@
     private static interface Impl {
         boolean allowMalformedNamesAndOptions();
 
+        boolean allowMalformedJPEGPhotos();
+
         boolean allowNonStandardTelephoneNumbers();
 
         boolean allowZeroLengthDirectoryStrings();
@@ -393,6 +399,10 @@
             return strictImpl.allowMalformedNamesAndOptions();
         }
 
+        public boolean allowMalformedJPEGPhotos() {
+            return strictImpl.allowMalformedJPEGPhotos();
+        }
+
         public boolean allowNonStandardTelephoneNumbers() {
             return strictImpl.allowNonStandardTelephoneNumbers();
         }
@@ -651,6 +661,8 @@
 
         private final String schemaName;
 
+        private final boolean allowMalformedJPEGPhotos;
+
         private final boolean allowNonStandardTelephoneNumbers;
 
         private final boolean allowZeroLengthDirectoryStrings;
@@ -658,6 +670,7 @@
         private final boolean allowMalformedNamesAndOptions;
 
         StrictImpl(final String schemaName, final boolean allowMalformedNamesAndOptions,
+                final boolean allowMalformedJPEGPhotos,
                 final boolean allowNonStandardTelephoneNumbers,
                 final boolean allowZeroLengthDirectoryStrings,
                 final Map<String, Syntax> numericOID2Syntaxes,
@@ -680,6 +693,7 @@
                 final List<LocalizableMessage> warnings) {
             this.schemaName = schemaName;
             this.allowMalformedNamesAndOptions = allowMalformedNamesAndOptions;
+            this.allowMalformedJPEGPhotos = allowMalformedJPEGPhotos;
             this.allowNonStandardTelephoneNumbers = allowNonStandardTelephoneNumbers;
             this.allowZeroLengthDirectoryStrings = allowZeroLengthDirectoryStrings;
             this.numericOID2Syntaxes = Collections.unmodifiableMap(numericOID2Syntaxes);
@@ -707,6 +721,10 @@
             return allowMalformedNamesAndOptions;
         }
 
+        public boolean allowMalformedJPEGPhotos() {
+            return allowMalformedJPEGPhotos;
+        }
+
         public boolean allowNonStandardTelephoneNumbers() {
             return allowNonStandardTelephoneNumbers;
         }
@@ -1323,6 +1341,7 @@
     private final Impl impl;
 
     Schema(final String schemaName, final boolean allowMalformedNamesAndOptions,
+            final boolean allowMalformedJPEGPhotos,
             final boolean allowNonStandardTelephoneNumbers,
             final boolean allowZeroLengthDirectoryStrings,
             final Map<String, Syntax> numericOID2Syntaxes,
@@ -1345,8 +1364,9 @@
             final List<LocalizableMessage> warnings) {
         impl =
                 new StrictImpl(schemaName, allowMalformedNamesAndOptions,
-                        allowNonStandardTelephoneNumbers, allowZeroLengthDirectoryStrings,
-                        numericOID2Syntaxes, numericOID2MatchingRules, numericOID2MatchingRuleUses,
+                        allowMalformedJPEGPhotos, allowNonStandardTelephoneNumbers,
+                        allowZeroLengthDirectoryStrings, numericOID2Syntaxes,
+                        numericOID2MatchingRules, numericOID2MatchingRuleUses,
                         numericOID2AttributeTypes, numericOID2ObjectClasses, numericOID2NameForms,
                         numericOID2ContentRules, id2StructureRules, name2MatchingRules,
                         name2MatchingRuleUses, name2AttributeTypes, name2ObjectClasses,
@@ -1382,6 +1402,21 @@
     }
 
     /**
+     * Returns {@code true} if the JPEG Photo syntax defined for this
+     * schema allows values which do not conform to the JFIF or Exif
+     * specifications.
+     * <p>
+     * By default this compatibility option is set to {@code true}.
+     *
+     * @return {@code true} if the JPEG Photo syntax defined for this
+     *         schema allows values which do not conform to the JFIF
+     *         of Exit specifications.
+     */
+    public boolean allowMalformedJPEGPhotos() {
+        return impl.allowMalformedJPEGPhotos();
+    }
+
+    /**
      * Returns {@code true} if the Telephone Number syntax defined for this
      * schema allows values which do not conform to the E.123 international
      * telephone number format.

--
Gitblit v1.10.0