directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1021639 - in /directory: apacheds-manuals/trunk/src/basic-user-guide/ apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/ apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/ apacheds/trunk/core/src/m...
Date Tue, 12 Oct 2010 06:41:17 GMT
Author: elecharny
Date: Tue Oct 12 06:41:16 2010
New Revision: 1021639

URL: http://svn.apache.org/viewvc?rev=1021639&view=rev
Log:
o Reverted the removal of the HiddePassword parameter
o Added the DirectoryService bean
o Added a test for AttributeType parsing with spaces in the DESC element

Added:
    directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/DirectoryServiceBean.java
Modified:
    directory/apacheds-manuals/trunk/src/basic-user-guide/chapter-configuring-apacheds.xml
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java
    directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/MockDirectoryService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
    directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
    directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigSchemaConstants.java
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=adsconfig/ou=attributetypes/m-oid=1.3.6.1.4.1.18060.0.4.1.2.104.ldif
    directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=adsconfig/ou=objectclasses/m-oid=1.3.6.1.4.1.18060.0.4.1.3.100.ldif
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java

Modified: directory/apacheds-manuals/trunk/src/basic-user-guide/chapter-configuring-apacheds.xml
URL: http://svn.apache.org/viewvc/directory/apacheds-manuals/trunk/src/basic-user-guide/chapter-configuring-apacheds.xml?rev=1021639&r1=1021638&r2=1021639&view=diff
==============================================================================
--- directory/apacheds-manuals/trunk/src/basic-user-guide/chapter-configuring-apacheds.xml
(original)
+++ directory/apacheds-manuals/trunk/src/basic-user-guide/chapter-configuring-apacheds.xml
Tue Oct 12 06:41:16 2010
@@ -138,6 +138,9 @@
           the encoded bytes representing the request).</emphasis></para>
         </listitem>
         <listitem>
+          <para><emphasis role="bold">passwordHidden</emphasis><subscript>(boolean,
true)</subscript> : <emphasis>Tells if the password is hidden or not.</emphasis></para>
+        </listitem>
+        <listitem>
           <para><emphasis role="bold">testEntries</emphasis><subscript>(LDIF)</subscript>
: <emphasis>The set of entries to inject at startup</emphasis></para>
         </listitem>
         <listitem>

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java?rev=1021639&r1=1021638&r2=1021639&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java
Tue Oct 12 06:41:16 2010
@@ -268,6 +268,23 @@ public interface DirectoryService extend
 
 
     /**
+     * Returns <tt>true</tt> if the service requires the userPassword attribute
+     * to be masked. It's an option in the server.xml file.
+     *
+     * @return true if the service requires that the userPassword is to be hidden
+     */
+    boolean isPasswordHidden();
+
+
+    /**
+     * Sets whether the userPassword attribute is readable, or hidden.
+     *
+     * @param passwordHidden true to enable hide the userPassword attribute, false otherwise
+     */
+    void setPasswordHidden( boolean passwordHidden );
+
+
+    /**
      * Sets whether to allow anonymous access to entries other than the RootDSE.  If the
      * access control subsystem is enabled then access to some entries may not be allowed
      * even when full anonymous access is enabled.

Modified: directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/MockDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/MockDirectoryService.java?rev=1021639&r1=1021638&r2=1021639&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/MockDirectoryService.java
(original)
+++ directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/MockDirectoryService.java
Tue Oct 12 06:41:16 2010
@@ -406,6 +406,17 @@ public class MockDirectoryService implem
     }
     
     
+    public boolean isPasswordHidden()
+    {
+        return false;
+    }
+         
+    
+    public void setPasswordHidden( boolean passwordHidden )
+    {
+    }
+
+    
     public int getMaxPDUSize()
     {
         return Integer.MAX_VALUE;

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=1021639&r1=1021638&r2=1021639&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
Tue Oct 12 06:41:16 2010
@@ -155,6 +155,9 @@ public class DefaultDirectoryService imp
     /** The referral manager */
     private ReferralManager referralManager;
 
+    /** A flag to tell if the userPassword attribute's value must be hidden */
+    private boolean passwordHidden = false;
+
     /** The service's CSN factory */
     private CsnFactory csnFactory;
 
@@ -1608,6 +1611,24 @@ public class DefaultDirectoryService imp
 
 
     /**
+     * {@inheritDoc}
+     */
+    public boolean isPasswordHidden()
+    {
+        return passwordHidden;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setPasswordHidden( boolean passwordHidden )
+    {
+        this.passwordHidden = passwordHidden;
+    }
+
+
+    /**
      * @return The maximum allowed size for an incoming PDU
      */
     public int getMaxPDUSize()

Modified: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java?rev=1021639&r1=1021638&r2=1021639&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
(original)
+++ directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
Tue Oct 12 06:41:16 2010
@@ -892,7 +892,146 @@ public class ConfigPartitionReader
 
 
     /**
-     * 
+     * instantiates a DirectoryService based on the configuration present in the partition

+     *
+     * @throws Exception
+     *
+    public DirectoryServiceBean readDirectoryService() throws Exception
+    {
+        AttributeType adsDirectoryServiceidAt = schemaManager.getAttributeType( ConfigSchemaConstants.ADS_DIRECTORYSERVICE_ID
);
+        PresenceNode filter = new PresenceNode( adsDirectoryServiceidAt );
+        SearchControls controls = new SearchControls();
+        controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+
+        IndexCursor<Long, Entry, Long> cursor = se.cursor( configPartition.getSuffix(),
+            AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls );
+
+        if ( !cursor.next() )
+        {
+            // the DirectoryService is mandatory so throwing exception
+            throw new Exception( "No directoryService instance was configured under the DN
"
+                + configPartition.getSuffix() );
+        }
+
+        ForwardIndexEntry<Long, Entry, Long> forwardEntry = ( ForwardIndexEntry<Long,
Entry, Long> ) cursor
+            .get();
+        cursor.close();
+
+        Entry dsEntry = configPartition.lookup( forwardEntry.getId() );
+
+        LOG.debug( "directory service entry {}", dsEntry );
+
+        DirectoryServiceBean dirServicebean = new DirectoryServiceBean();
+        
+        // MUST attributes
+        dirServicebean.setInstanceId( getString( ConfigSchemaConstants.ADS_DIRECTORYSERVICE_ID,
dsEntry ) );
+        dirServicebean.setReplicaId( getInt( ConfigSchemaConstants.ADS_DS_REPLICA_ID, dsEntry
) );
+
+        Set<InterceptorBean> interceptors = readInterceptors( dsEntry.getDn() );
+        dirServicebean.setInterceptors( interceptors );
+        
+        AuthenticationInterceptor authnInterceptor = ( AuthenticationInterceptor ) dirServicebean.getInterceptor(
AuthenticationInterceptor.class.getName() );
+        authnInterceptor.setPwdPolicyConfig( createPwdPolicyConfig( dsEntry.getDn() ) );
+
+        Map<String, Partition> partitions = createPartitions( dsEntry.getDn() );
+
+        Partition systemPartition = partitions.remove( "system" );
+
+        if ( systemPartition == null )
+        {
+            throw new Exception( I18n.err( I18n.ERR_505 ) );
+        }
+
+        dirServicebean.setSystemPartition( systemPartition );
+        dirServicebean.setPartitions( new HashSet<Partition>( partitions.values() )
);
+
+        // MAY attributes
+        EntryAttribute acEnabledAttr = dsEntry.get( ConfigSchemaConstants.ADS_DS_ACCESSCONTROL_ENABLED
);
+
+        if ( acEnabledAttr != null )
+        {
+            dirServicebean.setAccessControlEnabled( Boolean.parseBoolean( acEnabledAttr.getString()
) );
+        }
+
+        EntryAttribute anonAccessAttr = dsEntry.get( ConfigSchemaConstants.ADS_DS_ALLOW_ANONYMOUS_ACCESS
);
+
+        if ( anonAccessAttr != null )
+        {
+            dirServicebean.setAllowAnonymousAccess( Boolean.parseBoolean( anonAccessAttr.getString()
) );
+        }
+
+        EntryAttribute changeLogAttr = dsEntry.get( ConfigSchemaConstants.ADS_DSCHANGELOG
);
+
+        if ( changeLogAttr != null )
+        {
+            DN clDN = new DN( changeLogAttr.getString(), schemaManager );
+            ChangeLog cl = createChangeLog( clDN );
+            dirServicebean.setChangeLog( cl );
+        }
+
+        EntryAttribute denormAttr = dsEntry.get( ConfigSchemaConstants.ADS_DS_DENORMALIZE_OPATTRS_ENABLED
);
+
+        if ( denormAttr != null )
+        {
+            dirServicebean.setDenormalizeOpAttrsEnabled( Boolean.parseBoolean( denormAttr.getString()
) );
+        }
+
+        EntryAttribute journalAttr = dsEntry.get( ConfigSchemaConstants.ADS_DSJOURNAL );
+
+        if ( journalAttr != null )
+        {
+            DN journalDN = new DN( journalAttr.getString(), schemaManager );
+            dirServicebean.setJournal( createJournal( journalDN ) );
+        }
+
+        EntryAttribute maxPduAttr = dsEntry.get( ConfigSchemaConstants.ADS_DS_MAXPDU_SIZE
);
+
+        if ( maxPduAttr != null )
+        {
+            dirServicebean.setMaxPDUSize( Integer.parseInt( maxPduAttr.getString() ) );
+        }
+
+        EntryAttribute passwordHidAttr = dsEntry.get( ConfigSchemaConstants.ADS_DS_PASSWORD_HIDDEN
);
+
+        if ( passwordHidAttr != null )
+        {
+            dirServicebean.setPasswordHidden( Boolean.parseBoolean( passwordHidAttr.getString()
) );
+        }
+
+        EntryAttribute replAttr = dsEntry.get( ConfigSchemaConstants.ADS_DS_REPLICATION );
+
+        if ( replAttr != null )
+        {
+            // configure replication
+        }
+
+        EntryAttribute syncPeriodAttr = dsEntry.get( ConfigSchemaConstants.ADS_DS_SYNCPERIOD_MILLIS
);
+
+        if ( syncPeriodAttr != null )
+        {
+            dirServicebean.setSyncPeriodMillis( Long.parseLong( syncPeriodAttr.getString()
) );
+        }
+
+        EntryAttribute testEntryAttr = dsEntry.get( ConfigSchemaConstants.ADS_DS_TEST_ENTRIES
);
+
+        if ( testEntryAttr != null )
+        {
+            String entryFilePath = testEntryAttr.getString();
+            dirServicebean.setTestEntries( readTestEntries( entryFilePath ) );
+        }
+
+        if ( !isEnabled( dsEntry ) )
+        {
+            // will only be useful if we ever allow more than one DS to be configured and
+            // switch between them
+            // decide which one to use based on this flag
+        }
+
+        return dirServicebean;
+    }
+    
+    
+    /**
      * instantiates a DirectoryService based on the configuration present in the partition

      *
      * @throws Exception
@@ -991,6 +1130,13 @@ public class ConfigPartitionReader
             dirService.setMaxPDUSize( Integer.parseInt( maxPduAttr.getString() ) );
         }
 
+        EntryAttribute passwordHidAttr = dsEntry.get( ConfigSchemaConstants.ADS_DS_PASSWORD_HIDDEN
);
+
+        if ( passwordHidAttr != null )
+        {
+            dirService.setPasswordHidden( Boolean.parseBoolean( passwordHidAttr.getString()
) );
+        }
+
         EntryAttribute replAttr = dsEntry.get( ConfigSchemaConstants.ADS_DS_REPLICATION );
 
         if ( replAttr != null )

Modified: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigSchemaConstants.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigSchemaConstants.java?rev=1021639&r1=1021638&r2=1021639&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigSchemaConstants.java
(original)
+++ directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigSchemaConstants.java
Tue Oct 12 06:41:16 2010
@@ -92,8 +92,7 @@ public interface ConfigSchemaConstants
 
     String ADS_DS_MAXPDU_SIZE = "ads-dsMaxPDUSize";
 
-    // this AT is no longer in use, can be renamed for reuse
-    //String ADS_DS_PASSWORD_HIDDEN = "ads-dsPasswordHidden";
+    String ADS_DS_PASSWORD_HIDDEN = "ads-dsPasswordHidden";
 
     String ADS_DS_REPLICATION = "ads-dsReplication";
 

Added: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/DirectoryServiceBean.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/DirectoryServiceBean.java?rev=1021639&view=auto
==============================================================================
--- directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/DirectoryServiceBean.java
(added)
+++ directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/DirectoryServiceBean.java
Tue Oct 12 06:41:16 2010
@@ -0,0 +1,114 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+package org.apache.directory.server.config.beans;
+
+import java.util.Set;
+
+
+
+/**
+ * A class used to store the DirectoryService configuration.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DirectoryServiceBean
+{
+    /** The DS instance Id */
+    private String instanceId;
+
+    /** The directory instance replication ID */
+    private int replicaId;
+
+    /** The list of declared interceptors */
+    private Set<InterceptorBean> interceptors;
+
+    /**
+     * Create a new DnsServerBean instance
+     */
+    public DirectoryServiceBean()
+    {
+    }
+
+
+    /**
+     * Sets the Instance ID for this DirectoryService
+     * @param instanceId The instance ID
+     */
+    public void setInstanceId( String instanceId )
+    {
+        this.instanceId = instanceId;
+    }
+
+
+    /**
+     * @return The DirectoryService instanceId
+     */
+    public String getInstanceId()
+    {
+        return instanceId;
+    }
+
+
+    /**
+     * @return the replicaId
+     */
+    public int getReplicaId()
+    {
+        return replicaId;
+    }
+
+
+    /**
+     * @param replicaId the replicaId to set
+     */
+    public void setReplicaId( int replicaId )
+    {
+        if ( ( replicaId < 0 ) || ( replicaId > 999 ) )
+        {
+            this.replicaId = 0;
+        }
+        else
+        {
+            this.replicaId = replicaId;
+        }
+    }
+
+
+    /**
+     * Returns interceptors in the server.
+     *
+     * @return the interceptors in the server.
+     */
+    public Set<InterceptorBean> getInterceptors()
+    {
+        return interceptors;
+    }
+
+
+    /**
+     * Sets the interceptors in the server.
+     *
+     * @param interceptors the interceptors to be used in the server.
+     */
+    public void setInterceptors( Set<InterceptorBean> interceptors )
+    {
+        this.interceptors = interceptors;
+    }
+}

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=adsconfig/ou=attributetypes/m-oid=1.3.6.1.4.1.18060.0.4.1.2.104.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dadsconfig/ou%3Dattributetypes/m-oid%3D1.3.6.1.4.1.18060.0.4.1.2.104.ldif?rev=1021639&r1=1021638&r2=1021639&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=adsconfig/ou=attributetypes/m-oid=1.3.6.1.4.1.18060.0.4.1.2.104.ldif
(original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=adsconfig/ou=attributetypes/m-oid=1.3.6.1.4.1.18060.0.4.1.2.104.ldif
Tue Oct 12 06:41:16 2010
@@ -1,4 +1,3 @@
-# this AT is no longer in use, can be renamed for reuse
 version: 1
 dn: m-oid=1.3.6.1.4.1.18060.0.4.1.2.104, ou=attributeTypes, cn=adsconfig, ou=sch
  ema

Modified: directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=adsconfig/ou=objectclasses/m-oid=1.3.6.1.4.1.18060.0.4.1.3.100.ldif
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/resources/schema/ou%3Dschema/cn%3Dadsconfig/ou%3Dobjectclasses/m-oid%3D1.3.6.1.4.1.18060.0.4.1.3.100.ldif?rev=1021639&r1=1021638&r2=1021639&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=adsconfig/ou=objectclasses/m-oid=1.3.6.1.4.1.18060.0.4.1.3.100.ldif
(original)
+++ directory/shared/trunk/ldap-schema/src/main/resources/schema/ou=schema/cn=adsconfig/ou=objectclasses/m-oid=1.3.6.1.4.1.18060.0.4.1.3.100.ldif
Tue Oct 12 06:41:16 2010
@@ -17,7 +17,7 @@ m-may: ads-dsChangeLog
 m-may: ads-dsDenormalizeOpAttrsEnabled
 m-may: ads-dsJournal
 m-may: ads-dsMaxPDUSize
-m-may: ads-dsReplication
+m-may: ads-dsPasswordHiddenm-may: ads-dsReplication
 m-may: ads-dsSyncPeriodMillis
 m-may: ads-dsTestEntries
 m-may: ads-enabled

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java?rev=1021639&r1=1021638&r2=1021639&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java
Tue Oct 12 06:41:16 2010
@@ -1095,4 +1095,29 @@ public class AttributeTypeDescriptionSch
         assertEquals( UsageEnum.USER_APPLICATIONS, attributeType.getUsage() );
         assertEquals( 0, attributeType.getExtensions().size() );
     }
+
+
+    /**
+     * Tests with spaces in DESC
+     * 
+     * @throws ParseException
+     */
+    @Test
+    public void testATWithSpacesInDesc() throws ParseException
+    {
+        String value = "( 1.3.18.0.2.4.216 NAME 'SAFDfpDataClass' DESC '  ' " +
+            "EQUALITY 2.5.13.2 SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )";
+        AttributeType attributeType = parser.parseAttributeTypeDescription( value );
+
+        assertEquals( "1.3.18.0.2.4.216", attributeType.getOid() );
+        assertEquals( 1, attributeType.getNames().size() );
+        assertEquals( "SAFDfpDataClass", attributeType.getNames().get( 0 ) );
+        assertEquals( "  ", attributeType.getDescription() );
+        assertNull( attributeType.getSuperiorOid() );
+        assertEquals( "2.5.13.2", attributeType.getEqualityOid() );
+        assertEquals( "1.3.6.1.4.1.1466.115.121.1.15", attributeType.getSyntaxOid() );
+        assertEquals( UsageEnum.USER_APPLICATIONS, attributeType.getUsage() );
+        assertTrue( attributeType.isSingleValued() );
+        assertEquals( 0, attributeType.getExtensions().size() );
+    }
 }



Mime
View raw message