You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2009/10/06 12:51:09 UTC

svn commit: r822212 - in /directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core: BrowserCorePreferencesInitializer.java OIDDescriptions.properties model/schema/Schema.java

Author: seelmann
Date: Tue Oct  6 10:51:08 2009
New Revision: 822212

URL: http://svn.apache.org/viewvc?rev=822212&view=rev
Log:
DIRSTUDIO-434, DIRSTUDIO-527:
o added MS AD attributes and syntaxes (objectGUID, objectSid, 2.5.5.10) to the list of binary attributes and syntaxes
o assume all syntaxes and matching rules in attribute types received from a directory server as valid, create a pseudo schema object in that case
o added some MS AD OID descriptions
o use human readable OID descriptions for syntaxes
o mark unknown attribute type as user modifiable

Modified:
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferencesInitializer.java
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/OIDDescriptions.properties
    directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/Schema.java

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferencesInitializer.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferencesInitializer.java?rev=822212&r1=822211&r2=822212&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferencesInitializer.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/BrowserCorePreferencesInitializer.java Tue Oct  6 10:51:08 2009
@@ -81,6 +81,8 @@
                 new BinaryAttribute( "2.5.4.39" ), // certificateRevocationList //$NON-NLS-1$
                 new BinaryAttribute( "2.5.4.40" ), // crossCertificatePair //$NON-NLS-1$
                 new BinaryAttribute( "2.5.4.45" ), // x500UniqueIdentifier //$NON-NLS-1$
+                new BinaryAttribute( "1.2.840.113556.1.4.2" ), // objectGUID //$NON-NLS-1$
+                new BinaryAttribute( "1.2.840.113556.1.4.146" ), // objectSid //$NON-NLS-1$
             };
         BrowserCorePlugin.getDefault().getCorePreferences().setDefaultBinaryAttributes( defaultBinaryAttributes );
 
@@ -95,6 +97,7 @@
                 new BinarySyntax( "1.3.6.1.4.1.1466.115.121.1.40" ), // Octet String //$NON-NLS-1$
                 new BinarySyntax( "1.3.6.1.4.1.1466.115.121.1.49" ), // Supported Algorithm //$NON-NLS-1$
                 new BinarySyntax( "1.3.6.1.1.16.1" ), // UUID //$NON-NLS-1$
+                new BinarySyntax( "2.5.5.10" ), // MS-specific: Octet,Replica-Link //$NON-NLS-1$
             };
         BrowserCorePlugin.getDefault().getCorePreferences().setDefaultBinarySyntaxes( defaultBinarySyntaxes );
     }

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/OIDDescriptions.properties
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/OIDDescriptions.properties?rev=822212&r1=822211&r2=822212&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/OIDDescriptions.properties (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/OIDDescriptions.properties Tue Oct  6 10:51:08 2009
@@ -567,3 +567,9 @@
 # RFC 2798: object class
 2.16.840.1.113730.3.2.2=inetOrgPerson
 
+# Microsoft Active Directory: attribute types
+1.2.840.113556.1.4.2=objectGUID
+1.2.840.113556.1.4.146=objectSid
+
+# Microsoft Active Directory: syntaxes
+2.5.5.10=Octet,Replica-Link

Modified: directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/Schema.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/Schema.java?rev=822212&r1=822211&r2=822212&view=diff
==============================================================================
--- directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/Schema.java (original)
+++ directory/studio/trunk/ldapbrowser-core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/schema/Schema.java Tue Oct  6 10:51:08 2009
@@ -34,6 +34,7 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.UsageEnum;
@@ -48,6 +49,7 @@
 import org.apache.directory.shared.ldap.schema.parsers.ObjectClassDescription;
 import org.apache.directory.shared.ldap.schema.parsers.ObjectClassDescriptionSchemaParser;
 import org.apache.directory.studio.ldapbrowser.core.model.AttributeDescription;
+import org.apache.directory.studio.ldapbrowser.core.utils.Utils;
 import org.apache.directory.studio.ldifparser.LdifFormatParameters;
 import org.apache.directory.studio.ldifparser.model.LdifEnumeration;
 import org.apache.directory.studio.ldifparser.model.container.LdifContainer;
@@ -235,6 +237,17 @@
         setSchemaRecord( schemaRecord );
         setDn( new LdapDN( schemaRecord.getDnLine().getValueAsString() ) );
 
+        ObjectClassDescriptionSchemaParser ocdPparser = new ObjectClassDescriptionSchemaParser();
+        ocdPparser.setQuirksMode( true );
+        AttributeTypeDescriptionSchemaParser atdParser = new AttributeTypeDescriptionSchemaParser();
+        atdParser.setQuirksMode( true );
+        LdapSyntaxDescriptionSchemaParser lsdParser = new LdapSyntaxDescriptionSchemaParser();
+        lsdParser.setQuirksMode( true );
+        MatchingRuleDescriptionSchemaParser mrdParser = new MatchingRuleDescriptionSchemaParser();
+        mrdParser.setQuirksMode( true );
+        MatchingRuleUseDescriptionSchemaParser mrudParser = new MatchingRuleUseDescriptionSchemaParser();
+        mrudParser.setQuirksMode( true );
+
         LdifAttrValLine[] lines = schemaRecord.getAttrVals();
         for ( int i = 0; i < lines.length; i++ )
         {
@@ -248,49 +261,44 @@
             {
                 if ( attributeName.equalsIgnoreCase( SchemaConstants.OBJECT_CLASSES_AT ) )
                 {
-                    ObjectClassDescriptionSchemaParser parser = new ObjectClassDescriptionSchemaParser();
-                    parser.setQuirksMode( true );
-                    ObjectClassDescription ocd = parser.parseObjectClassDescription( value );
+                    ObjectClassDescription ocd = ocdPparser.parseObjectClassDescription( value );
                     ocd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                     addObjectClassDescription( ocd );
                 }
                 else if ( attributeName.equalsIgnoreCase( SchemaConstants.ATTRIBUTE_TYPES_AT ) )
                 {
-                    AttributeTypeDescriptionSchemaParser parser = new AttributeTypeDescriptionSchemaParser();
-                    parser.setQuirksMode( true );
-                    AttributeTypeDescription atd = parser.parseAttributeTypeDescription( value );
+                    AttributeTypeDescription atd = atdParser.parseAttributeTypeDescription( value );
                     atd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                     addAttributeTypeDescription( atd );
                 }
                 else if ( attributeName.equalsIgnoreCase( SchemaConstants.LDAP_SYNTAXES_AT ) )
                 {
-                    LdapSyntaxDescriptionSchemaParser parser = new LdapSyntaxDescriptionSchemaParser();
-                    parser.setQuirksMode( true );
-                    LdapSyntaxDescription lsd = parser.parseLdapSyntaxDescription( value );
+                    LdapSyntaxDescription lsd = lsdParser.parseLdapSyntaxDescription( value );
+                    if ( StringUtils.isEmpty( lsd.getDescription() )
+                        && Utils.getOidDescription( lsd.getNumericOid() ) != null )
+                    {
+                        lsd.setDescription( Utils.getOidDescription( lsd.getNumericOid() ) );
+                    }
                     lsd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                     addLdapSyntaxDescription( lsd );
                 }
                 else if ( attributeName.equalsIgnoreCase( SchemaConstants.MATCHING_RULES_AT ) )
                 {
-                    MatchingRuleDescriptionSchemaParser parser = new MatchingRuleDescriptionSchemaParser();
-                    parser.setQuirksMode( true );
-                    MatchingRuleDescription mrd = parser.parseMatchingRuleDescription( value );
+                    MatchingRuleDescription mrd = mrdParser.parseMatchingRuleDescription( value );
                     mrd.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                     addMatchingRuleDescription( mrd );
                 }
                 else if ( attributeName.equalsIgnoreCase( SchemaConstants.MATCHING_RULE_USE_AT ) )
                 {
-                    MatchingRuleUseDescriptionSchemaParser parser = new MatchingRuleUseDescriptionSchemaParser();
-                    parser.setQuirksMode( true );
-                    MatchingRuleUseDescription mrud = parser.parseMatchingRuleUseDescription( value );
+                    MatchingRuleUseDescription mrud = mrudParser.parseMatchingRuleUseDescription( value );
                     mrud.addExtension( RAW_SCHEMA_DEFINITION_LDIF_VALUE, ldifValues );
                     addMatchingRuleUseDescription( mrud );
                 }
-                else if ( attributeName.equalsIgnoreCase(  SchemaConstants.CREATE_TIMESTAMP_AT ) )
+                else if ( attributeName.equalsIgnoreCase( SchemaConstants.CREATE_TIMESTAMP_AT ) )
                 {
                     setCreateTimestamp( value );
                 }
-                else if ( attributeName.equalsIgnoreCase(  SchemaConstants.MODIFY_TIMESTAMP_AT ) )
+                else if ( attributeName.equalsIgnoreCase( SchemaConstants.MODIFY_TIMESTAMP_AT ) )
                 {
                     setModifyTimestamp( value );
                 }
@@ -303,6 +311,25 @@
             }
         }
 
+        for ( AttributeTypeDescription atd : getAttributeTypeDescriptions() )
+        {
+            // assume all received syntaxes in attributes are valid -> create pseudo syntaxes if missing
+            String syntaxOid = atd.getSyntax();
+            if ( syntaxOid != null && !hasLdapSyntaxDescription( syntaxOid ) )
+            {
+                LdapSyntaxDescription lsd = new LdapSyntaxDescription();
+                lsd.setNumericOid( syntaxOid );
+                lsd.setDescription( Utils.getOidDescription( syntaxOid ) );
+                addLdapSyntaxDescription( lsd );
+            }
+
+            // assume all received matching rules in attributes are valid -> create pseudo matching rules if missing
+            String emr = atd.getEqualityMatchingRule();
+            String omr = atd.getOrderingMatchingRule();
+            String smr = atd.getSubstringsMatchingRule();
+            checkMatchingRules( emr, omr, smr );
+        }
+
         // set extensibleObject may attributes
         ObjectClassDescription extensibleObjectOcd = this
             .getObjectClassDescription( SchemaConstants.EXTENSIBLE_OBJECT_OC );
@@ -313,6 +340,21 @@
     }
 
 
+    private void checkMatchingRules( String... matchingRules )
+    {
+        for ( String matchingRule : matchingRules )
+        {
+            if ( matchingRule != null && !hasMatchingRuleDescription( matchingRule ) )
+            {
+                MatchingRuleDescription mrd = new MatchingRuleDescription();
+                mrd.setNumericOid( matchingRule );
+                mrd.getNames().add( matchingRule );
+                addMatchingRuleDescription( mrd );
+            }
+        }
+    }
+
+
     /**
      * Gets the schema record.
      * 
@@ -563,7 +605,7 @@
             AttributeTypeDescription atd = new AttributeTypeDescription();
             atd.setNumericOid( attributeType );
             atd.setNames( attributeTypes );
-            atd.setUserModifiable( false );
+            atd.setUserModifiable( true );
             atd.setUsage( UsageEnum.USER_APPLICATIONS );
             atd.setExtensions( DUMMY_EXTENSIONS );
             return atd;