You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/07/31 18:52:56 UTC
svn commit: r427171 [4/5] - in /directory/trunks/apacheds: benchmarks/
benchmarks/src/ benchmarks/src/main/ benchmarks/src/main/java/
benchmarks/src/main/java/org/ benchmarks/src/main/java/org/apache/
benchmarks/src/main/java/org/apache/directory/ benc...
Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java (original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java Mon Jul 31 09:52:49 2006
@@ -36,10 +36,11 @@
import org.apache.directory.server.core.interceptor.NextInterceptor;
import org.apache.directory.server.core.invocation.Invocation;
import org.apache.directory.server.core.invocation.InvocationStack;
-import org.apache.directory.server.core.partition.DirectoryPartitionNexus;
+import org.apache.directory.server.core.partition.PartitionNexus;
import org.apache.directory.server.core.schema.global.GlobalRegistries;
import org.apache.directory.shared.ldap.exception.LdapAttributeInUseException;
import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeIdentifierException;
+import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
import org.apache.directory.shared.ldap.exception.LdapNamingException;
import org.apache.directory.shared.ldap.exception.LdapNoSuchAttributeException;
import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
@@ -50,6 +51,7 @@
import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.name.Rdn;
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.DITContentRule;
import org.apache.directory.shared.ldap.schema.DITStructureRule;
@@ -82,10 +84,13 @@
/** The LoggerFactory used by this Interceptor */
private static Logger log = LoggerFactory.getLogger( SchemaService.class );
+ /** Speedup for logs */
+ private static final boolean IS_DEBUG = log.isDebugEnabled();
+
/**
* the root nexus to all database partitions
*/
- private DirectoryPartitionNexus nexus;
+ private PartitionNexus nexus;
/**
* a binary attribute tranforming filter: String -> byte[]
@@ -122,11 +127,18 @@
startUpTimeStamp = DateUtils.getGeneralizedTime();
}
-
+ /**
+ * Initialize the Schema Service
+ *
+ * @param factoryCfg
+ * @param cfg
+ *
+ * @throws NamingException
+ */
public void init( DirectoryServiceConfiguration factoryCfg, InterceptorConfiguration cfg ) throws NamingException
{
- this.nexus = factoryCfg.getPartitionNexus();
- this.globalRegistries = factoryCfg.getGlobalRegistries();
+ nexus = factoryCfg.getPartitionNexus();
+ globalRegistries = factoryCfg.getGlobalRegistries();
binaryAttributeFilter = new BinaryAttributeFilter();
topFilter = new TopFilter();
filters.add( binaryAttributeFilter );
@@ -140,19 +152,26 @@
/**
- * @return Returns the binaries.
+ * Check if an attribute stores binary values.
+ *
+ * @return Returns true if the attribute is binary.
*/
public boolean isBinary( String id )
{
return binaries.contains( StringTools.lowerCase( StringTools.trim( id ) ) );
}
-
+ /**
+ * Destroy the Schema Service
+ */
public void destroy()
{
}
+ /**
+ *
+ */
public NamingEnumeration list( NextInterceptor nextInterceptor, LdapDN base ) throws NamingException
{
NamingEnumeration e = nextInterceptor.list( base );
@@ -161,6 +180,9 @@
}
+ /**
+ *
+ */
public NamingEnumeration search( NextInterceptor nextInterceptor, LdapDN base, Map env, ExprNode filter,
SearchControls searchCtls ) throws NamingException
{
@@ -214,6 +236,12 @@
}
+ /**
+ *
+ * @param ids
+ * @return
+ * @throws NamingException
+ */
private Attributes getSubschemaEntry( String[] ids ) throws NamingException
{
if ( ids == null )
@@ -350,14 +378,14 @@
if ( returnAllOperationalAttributes || set.contains( "creatorsname" ) )
{
attr = new LockableAttributeImpl( "creatorsName" );
- attr.add( DirectoryPartitionNexus.ADMIN_PRINCIPAL );
+ attr.add( PartitionNexus.ADMIN_PRINCIPAL );
attrs.put( attr );
}
if ( returnAllOperationalAttributes || set.contains( "modifiersname" ) )
{
attr = new LockableAttributeImpl( "modifiersName" );
- attr.add( DirectoryPartitionNexus.ADMIN_PRINCIPAL );
+ attr.add( PartitionNexus.ADMIN_PRINCIPAL );
attrs.put( attr );
}
@@ -394,6 +422,9 @@
}
+ /**
+ *
+ */
public Attributes lookup( NextInterceptor nextInterceptor, LdapDN name ) throws NamingException
{
Attributes result = nextInterceptor.lookup( name );
@@ -402,7 +433,9 @@
return result;
}
-
+ /**
+ *
+ */
public Attributes lookup( NextInterceptor nextInterceptor, LdapDN name, String[] attrIds ) throws NamingException
{
Attributes result = nextInterceptor.lookup( name, attrIds );
@@ -485,8 +518,15 @@
return changedEntryAttr.size() == 0;
}
-
- Attribute getResultantObjectClasses( int modOp, Attribute changes, Attribute existing ) throws NamingException
+ /**
+ *
+ * @param modOp
+ * @param changes
+ * @param existing
+ * @return
+ * @throws NamingException
+ */
+ private Attribute getResultantObjectClasses( int modOp, Attribute changes, Attribute existing ) throws NamingException
{
if ( changes == null && existing == null )
{
@@ -572,15 +612,46 @@
}
}
-
+ /**
+ * Check that the modify operations are allowed, and the conform to
+ * the schema.
+ *
+ * @param next The next interceptor to call when we are done with the local operation
+ * @param name The DN on which the modification is being done
+ * @param modOp The modification. One of :
+ * DirContext.ADD_ATTRIBUTE
+ * DirContext.REMOVE_ATTRIBUTE
+ * DirContext.REPLACE_ATTRIBUTE
+ * @param mods The modifications to check. Each operation is atomic, and should
+ * be applied to a copy of the entry, in order to check that the schema is not
+ * violated at the end. For instance, we can't delete an attribute that does
+ * not exist and add it later. The opposite is legal.
+ *
+ * @throws NamingException The generic exception we get if an illegal operation occurs
+ * @throws LdapNameNotFoundException If we don't find the entry, then this exception is thrown.
+ * @throws LdapInvalidAttributeIdentifierException The modified attribute is not known
+ * by the schema, or the Entry is not extensible.
+ * @throws LdapNoSuchAttributeException The modified Attribute does not exist in the
+ * current entry or is not added by a previous modification operation.
+ * @throws LdapSchemaViolationException Another schema violation occured.
+ */
public void modify( NextInterceptor next, LdapDN name, int modOp, Attributes mods ) throws NamingException
{
+ // First, we get the entry from the backend. If it does not exist, then we throw an exception
Attributes entry = nexus.lookup( name );
+
+ if ( entry == null )
+ {
+ log.error( "No entry with this name :{}", name );
+ throw new LdapNameNotFoundException( "The entry which name is " + name + " is not found." );
+ }
+
Attribute objectClass = getResultantObjectClasses( modOp, mods.get( "objectClass" ), entry.get( "objectClass" ) );
ObjectClassRegistry ocRegistry = this.globalRegistries.getObjectClassRegistry();
AttributeTypeRegistry atRegistry = this.globalRegistries.getAttributeTypeRegistry();
NamingEnumeration changes = mods.getIDs();
+
while ( changes.hasMore() )
{
String id = ( String ) changes.next();
@@ -642,6 +713,7 @@
}
}
break;
+
case ( DirContext.REMOVE_ATTRIBUTE ):
for ( int ii = 0; ii < alteredObjectClass.size(); ii++ )
{
@@ -651,6 +723,7 @@
}
}
break;
+
case ( DirContext.REPLACE_ATTRIBUTE ):
for ( int ii = 0; ii < alteredObjectClass.size(); ii++ )
{
@@ -660,7 +733,9 @@
}
}
break;
+
default:
+ break;
}
}
}
@@ -668,13 +743,29 @@
next.modify( name, modOp, mods );
}
-
public void modify( NextInterceptor next, LdapDN name, ModificationItem[] mods ) throws NamingException
{
+ // First, we get the entry from the backend. If it does not exist, then we throw an exception
Attributes entry = nexus.lookup( name );
+
+ if ( entry == null )
+ {
+ log.error( "No entry with this name :{}", name );
+ throw new LdapNameNotFoundException( "The entry which name is " + name + " is not found." );
+ }
+
+ // We will use this temporary entry to check that the modifications
+ // can be applied as atomic operations
+ Attributes tmpEntry = (Attributes)entry.clone();
+
Set modset = new HashSet();
ModificationItem objectClassMod = null;
-
+
+ // Check that we don't have two times the same modification.
+ // This is somehow useless, has modification operations are supposed to
+ // be atomic, so we may have a sucession of Add, DEL, ADD operations
+ // for the same attribute, and this will be legal.
+ // @TODO : check if we can remove this test.
for ( int ii = 0; ii < mods.length; ii++ )
{
if ( mods[ii].getAttribute().getID().equalsIgnoreCase( "objectclass" ) )
@@ -685,16 +776,20 @@
StringBuffer keybuf = new StringBuffer();
keybuf.append( mods[ii].getModificationOp() );
keybuf.append( mods[ii].getAttribute().getID() );
+
for ( int jj = 0; jj < mods[ii].getAttribute().size(); jj++ )
{
keybuf.append( mods[ii].getAttribute().get( jj ) );
}
+
if ( !modset.add( keybuf.toString() ) && mods[ii].getModificationOp() == DirContext.ADD_ATTRIBUTE )
{
throw new LdapAttributeInUseException( "found two copies of the following modification item: "
+ mods[ii] );
}
}
+
+ // Get the objectClass attribute.
Attribute objectClass;
if ( objectClassMod == null )
@@ -710,6 +805,8 @@
ObjectClassRegistry ocRegistry = this.globalRegistries.getObjectClassRegistry();
AttributeTypeRegistry atRegistry = this.globalRegistries.getAttributeTypeRegistry();
+ // Now, apply the modifications on the cloned entry before applyong it to the
+ // real object.
for ( int ii = 0; ii < mods.length; ii++ )
{
int modOp = mods[ii].getModificationOp();
@@ -720,29 +817,86 @@
throw new LdapInvalidAttributeIdentifierException();
}
- if ( modOp == DirContext.REMOVE_ATTRIBUTE && entry.get( change.getID() ) == null )
- {
- throw new LdapNoSuchAttributeException();
- }
-
- if ( modOp == DirContext.REMOVE_ATTRIBUTE )
+ switch ( modOp )
{
- // for required attributes we need to check if all values are removed
- // if so then we have a schema violation that must be thrown
- if ( isRequired( change.getID(), objectClass ) && isCompleteRemoval( change, entry ) )
- {
- throw new LdapSchemaViolationException( ResultCodeEnum.OBJECTCLASSVIOLATION );
- }
- SchemaChecker.preventRdnChangeOnModifyRemove( name, modOp, change,
- this.globalRegistries.getOidRegistry() );
- SchemaChecker
- .preventStructuralClassRemovalOnModifyRemove( ocRegistry, name, modOp, change, objectClass );
- }
+ case DirContext.ADD_ATTRIBUTE :
+ Attribute attr = tmpEntry.get( change.getID() );
+
+ if ( attr != null )
+ {
+ NamingEnumeration values = change.getAll();
+
+ while ( values.hasMoreElements() )
+ {
+ attr.add( values.nextElement() );
+ }
+ }
+ else
+ {
+ attr = new LockableAttributeImpl( change.getID() );
+ NamingEnumeration values = change.getAll();
+
+ while ( values.hasMoreElements() )
+ {
+ attr.add( values.nextElement() );
+ }
+
+ tmpEntry.put( attr );
+ }
+
+ break;
+
+ case DirContext.REMOVE_ATTRIBUTE :
+ if ( tmpEntry.get( change.getID() ) == null )
+ {
+ log.error( "Trying to remove an inexistant attribute" );
+ throw new LdapNoSuchAttributeException();
+ }
+
+ // for required attributes we need to check if all values are removed
+ // if so then we have a schema violation that must be thrown
+ if ( isRequired( change.getID(), objectClass ) && isCompleteRemoval( change, entry ) )
+ {
+ log.error( "Trying to remove a required attribute" );
+ throw new LdapSchemaViolationException( ResultCodeEnum.OBJECTCLASSVIOLATION );
+ }
+
+ tmpEntry.remove( change.getID() );
+
+ SchemaChecker.preventRdnChangeOnModifyRemove( name, modOp, change,
+ this.globalRegistries.getOidRegistry() );
+ SchemaChecker
+ .preventStructuralClassRemovalOnModifyRemove( ocRegistry, name, modOp, change, objectClass );
+ break;
+
+ case DirContext.REPLACE_ATTRIBUTE :
+ SchemaChecker.preventRdnChangeOnModifyReplace( name, modOp, change );
+ SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, modOp, change );
+
+ attr = tmpEntry.get( change.getID() );
+
+ if ( attr != null )
+ {
+ tmpEntry.remove( change.getID() );
+ }
+ else
+ {
+ attr = new LockableAttributeImpl( change.getID() );
+ }
+
+ NamingEnumeration values = change.getAll();
+
+ if ( values.hasMoreElements() )
+ {
+ while ( values.hasMoreElements() )
+ {
+ attr.add( values.nextElement() );
+ }
- if ( modOp == DirContext.REPLACE_ATTRIBUTE )
- {
- SchemaChecker.preventRdnChangeOnModifyReplace( name, modOp, change );
- SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, modOp, change );
+ tmpEntry.put( attr );
+ }
+
+ break;
}
}
@@ -756,6 +910,7 @@
if ( !alteredObjectClass.equals( objectClass ) )
{
Attribute ocMods = objectClassMod.getAttribute();
+
switch ( objectClassMod.getModificationOp() )
{
case ( DirContext.ADD_ATTRIBUTE ):
@@ -816,7 +971,7 @@
{
long t0 = -1;
- if ( log.isDebugEnabled() )
+ if ( IS_DEBUG )
{
t0 = System.currentTimeMillis();
log.debug( "Filtering entry " + AttributeUtils.toString( entry ) );
Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapOidRegistry.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapOidRegistry.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapOidRegistry.java (original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapOidRegistry.java Mon Jul 31 09:52:49 2006
@@ -29,6 +29,7 @@
import org.apache.directory.server.core.schema.OidRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.directory.shared.ldap.util.StringTools;
/**
@@ -53,20 +54,16 @@
*/
public String getOid( String name ) throws NamingException
{
- if ( name == null )
+ if ( StringTools.isEmpty( name ) )
{
- throw new NamingException( "name should not be null" );
+ throw new NamingException( "name should not be empty" );
}
/* If name is an OID than we return it back since inherently the
* OID is another name for the object referred to by OID and the
* caller does not know that the argument is an OID String.
*/
- if ( Character.isDigit( name.charAt( 0 ) ) )
+ if ( StringTools.isDigit( name.charAt( 0 ) ) )
{
- if ( log.isDebugEnabled() )
- {
- log.debug( "looked up OID with OID: " + name );
- }
return name;
}
Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java (original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/subtree/SubentryService.java Mon Jul 31 09:52:49 2006
@@ -26,7 +26,7 @@
import org.apache.directory.server.core.interceptor.NextInterceptor;
import org.apache.directory.server.core.invocation.Invocation;
import org.apache.directory.server.core.invocation.InvocationStack;
-import org.apache.directory.server.core.partition.DirectoryPartitionNexus;
+import org.apache.directory.server.core.partition.PartitionNexus;
import org.apache.directory.server.core.schema.AttributeTypeRegistry;
import org.apache.directory.server.core.schema.OidRegistry;
@@ -103,7 +103,7 @@
private DirectoryServiceConfiguration factoryCfg;
private SubtreeSpecificationParser ssParser;
private SubtreeEvaluator evaluator;
- private DirectoryPartitionNexus nexus;
+ private PartitionNexus nexus;
private AttributeTypeRegistry attrRegistry;
private OidRegistry oidRegistry;
@@ -130,7 +130,7 @@
{
return attrRegistry.getNormalizerMapping();
}
- });
+ }, attrRegistry.getNormalizerMapping() );
evaluator = new SubtreeEvaluator( factoryCfg.getGlobalRegistries().getOidRegistry() );
// prepare to find all subentries in all namingContexts
@@ -146,7 +146,7 @@
{
LdapDN suffix = new LdapDN( ( String ) suffixes.next() );
//suffix = LdapDN.normalize( suffix, registry.getNormalizerMapping() );
- suffix.normalize();
+ suffix.normalize( attrRegistry.getNormalizerMapping() );
NamingEnumeration subentries = nexus.search( suffix, factoryCfg.getEnvironment(), filter, controls );
while ( subentries.hasMore() )
{
@@ -168,7 +168,7 @@
LdapDN dnName = new LdapDN( dn );
//dnName = LdapDN.normalize( dnName, registry.getNormalizerMapping() );
- dnName.normalize();
+ dnName.normalize( attrRegistry.getNormalizerMapping() );
subtrees.put( dnName.toString(), ss );
}
}
@@ -396,7 +396,7 @@
}
catch ( Exception e )
{
- String msg = "Failed while parsing subtreeSpecification for " + normName.toUpName();
+ String msg = "Failed while parsing subtreeSpecification for " + normName.getUpName();
log.warn( msg );
throw new LdapInvalidAttributeValueException( msg, ResultCodeEnum.INVALIDATTRIBUTESYNTAX );
}
@@ -426,7 +426,7 @@
SearchResult result = ( SearchResult ) subentries.next();
Attributes candidate = result.getAttributes();
LdapDN dn = new LdapDN( result.getName() );
- dn.normalize();
+ dn.normalize( attrRegistry.getNormalizerMapping() );
if ( evaluator.evaluate( ss, apName, dn, candidate.get( "objectClass" ) ) )
{
@@ -562,7 +562,7 @@
SearchResult result = ( SearchResult ) subentries.next();
Attributes candidate = result.getAttributes();
LdapDN dn = new LdapDN( result.getName() );
- dn.normalize();
+ dn.normalize( attrRegistry.getNormalizerMapping() );
if ( evaluator.evaluate( ss, apName, dn, ServerUtils.getAttribute( objectClassType, candidate ) ) )
{
@@ -697,8 +697,8 @@
LdapDN rdn = new LdapDN( newRn );
newName.addAll( rdn );
- rdn.normalize();
- newName.normalize();
+ rdn.normalize( attrRegistry.getNormalizerMapping() );
+ newName.normalize( attrRegistry.getNormalizerMapping() );
subtrees.put( newName.toNormName(), ss );
next.modifyRn( name, newRn, deleteOldRn );
@@ -715,7 +715,7 @@
SearchResult result = ( SearchResult ) subentries.next();
Attributes candidate = result.getAttributes();
LdapDN dn = new LdapDN( result.getName() );
- dn.normalize();
+ dn.normalize( attrRegistry.getNormalizerMapping() );
if ( evaluator.evaluate( ss, apName, dn, ServerUtils.getAttribute( objectClassType, candidate ) ) )
{
@@ -738,7 +738,7 @@
LdapDN newName = ( LdapDN ) name.clone();
newName.remove( newName.size() - 1 );
newName.add( newRn );
- newName.normalize();
+ newName.normalize( attrRegistry.getNormalizerMapping() );
ModificationItem[] mods = getModsOnEntryRdnChange( name, newName, entry );
if ( mods.length > 0 )
@@ -767,8 +767,8 @@
LdapDN rdn = new LdapDN( newRn );
newName.addAll( rdn );
- rdn.normalize();
- newName.normalize();
+ rdn.normalize( attrRegistry.getNormalizerMapping() );
+ newName.normalize( attrRegistry.getNormalizerMapping() );
subtrees.put( newName.toNormName(), ss );
next.move( oriChildName, newParentName, newRn, deleteOldRn );
@@ -786,7 +786,7 @@
SearchResult result = ( SearchResult ) subentries.next();
Attributes candidate = result.getAttributes();
LdapDN dn = new LdapDN( result.getName() );
- dn.normalize();
+ dn.normalize( attrRegistry.getNormalizerMapping() );
if ( evaluator.evaluate( ss, apName, dn, ServerUtils.getAttribute( objectClassType, candidate ) ) )
{
@@ -809,7 +809,7 @@
// attributes contained within this regular entry with name changes
LdapDN newName = ( LdapDN ) newParentName.clone();
newName.add( newRn );
- newName.normalize();
+ newName.normalize( attrRegistry.getNormalizerMapping() );
ModificationItem[] mods = getModsOnEntryRdnChange( oriChildName, newName, entry );
if ( mods.length > 0 )
@@ -853,7 +853,7 @@
SearchResult result = ( SearchResult ) subentries.next();
Attributes candidate = result.getAttributes();
LdapDN dn = new LdapDN( result.getName() );
- dn.normalize();
+ dn.normalize( attrRegistry.getNormalizerMapping() );
if ( evaluator.evaluate( ss, apName, dn, candidate.get( "objectClass" ) ) )
{
@@ -930,7 +930,7 @@
SearchResult result = ( SearchResult ) subentries.next();
Attributes candidate = result.getAttributes();
LdapDN dn = new LdapDN( result.getName() );
- dn.normalize();
+ dn.normalize( attrRegistry.getNormalizerMapping() );
if ( evaluator.evaluate( ssOld, apName, dn, ServerUtils.getAttribute( objectClassType, candidate ) ) )
{
@@ -950,7 +950,7 @@
SearchResult result = ( SearchResult ) subentries.next();
Attributes candidate = result.getAttributes();
LdapDN dn = new LdapDN( result.getName() );
- dn.normalize();
+ dn.normalize( attrRegistry.getNormalizerMapping() );
if ( evaluator.evaluate( ssNew, apName, dn, ServerUtils.getAttribute( objectClassType, candidate ) ) )
{
@@ -1016,7 +1016,7 @@
SearchResult result = ( SearchResult ) subentries.next();
Attributes candidate = result.getAttributes();
LdapDN dn = new LdapDN( result.getName() );
- dn.normalize();
+ dn.normalize( attrRegistry.getNormalizerMapping() );
if ( evaluator.evaluate( ssOld, apName, dn, candidate.get( "objectClass" ) ) )
{
@@ -1036,7 +1036,7 @@
SearchResult result = ( SearchResult ) subentries.next();
Attributes candidate = result.getAttributes();
LdapDN dn = new LdapDN( result.getName() );
- dn.normalize();
+ dn.normalize( attrRegistry.getNormalizerMapping() );
if ( evaluator.evaluate( ssNew, apName, dn, candidate.get( "objectClass" ) ) )
{
@@ -1373,16 +1373,16 @@
if ( !result.isRelative() )
{
LdapDN ndn = new LdapDN( dn );
- ndn.normalize();
+ ndn.normalize( attrRegistry.getNormalizerMapping() );
String normalizedDn = ndn.toString();
return !subtrees.containsKey( normalizedDn );
}
LdapDN name = new LdapDN( invocation.getCaller().getNameInNamespace() );
- name.normalize();
+ name.normalize( attrRegistry.getNormalizerMapping() );
LdapDN rest = new LdapDN( result.getName() );
- rest.normalize();
+ rest.normalize( attrRegistry.getNormalizerMapping() );
name.addAll( rest );
return !subtrees.containsKey( name.toString() );
}
@@ -1434,15 +1434,15 @@
if ( !result.isRelative() )
{
LdapDN ndn = new LdapDN( dn );
- ndn.normalize();
+ ndn.normalize( attrRegistry.getNormalizerMapping() );
return subtrees.containsKey( ndn.toNormName() );
}
LdapDN name = new LdapDN( invocation.getCaller().getNameInNamespace() );
- name.normalize();
+ name.normalize( attrRegistry.getNormalizerMapping() );
LdapDN rest = new LdapDN( result.getName() );
- rest.normalize();
+ rest.normalize( attrRegistry.getNormalizerMapping() );
name.addAll( rest );
return subtrees.containsKey( name.toNormName() );
}
Modified: directory/trunks/apacheds/core/src/main/schema/system.schema
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/schema/system.schema?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/main/schema/system.schema (original)
+++ directory/trunks/apacheds/core/src/main/schema/system.schema Mon Jul 31 09:52:49 2006
@@ -248,6 +248,10 @@
EQUALITY caseExactMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
+attributetype ( 1.3.6.1.4.1.4203.1.3.5 NAME 'supportedFeatures'
+ EQUALITY objectIdentifierMatch
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.38
+ USAGE dSAOperation )
# ==============
# objectClasses
@@ -313,3 +317,4 @@
DESC 'RFC2589: Dynamic Object'
SUP top
AUXILIARY )
+
Modified: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java (original)
+++ directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java Mon Jul 31 09:52:49 2006
@@ -35,7 +35,7 @@
import org.apache.directory.server.core.DirectoryServiceConfiguration;
import org.apache.directory.server.core.DirectoryServiceListener;
import org.apache.directory.server.core.jndi.DeadContext;
-import org.apache.directory.server.core.partition.DirectoryPartitionNexusProxy;
+import org.apache.directory.server.core.partition.PartitionNexusProxy;
import org.apache.directory.shared.ldap.aci.ACITuple;
import org.apache.directory.shared.ldap.aci.AuthenticationLevel;
import org.apache.directory.shared.ldap.aci.ProtectedItem;
@@ -139,7 +139,7 @@
null, ENTRY_NAME, null, null, ENTRY, null ).size() );
}
- class MockProxy extends DirectoryPartitionNexusProxy
+ class MockProxy extends PartitionNexusProxy
{
final int count;
@@ -203,8 +203,8 @@
}
- public Context getJndiContext( String principal, byte[] credential, String authentication, String baseName )
- throws NamingException
+ public Context getJndiContext( LdapDN principalDn, String principal, byte[] credential,
+ String authentication, String baseName ) throws NamingException
{
return null; //To change body of implemented methods use File | Settings | File Templates.
}
Modified: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java (original)
+++ directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java Mon Jul 31 09:52:49 2006
@@ -22,13 +22,13 @@
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.DirectoryServiceConfiguration;
import org.apache.directory.server.core.DirectoryServiceListener;
-import org.apache.directory.server.core.configuration.DirectoryPartitionConfiguration;
+import org.apache.directory.server.core.configuration.PartitionConfiguration;
import org.apache.directory.server.core.configuration.InterceptorConfiguration;
import org.apache.directory.server.core.configuration.MutableInterceptorConfiguration;
import org.apache.directory.server.core.invocation.Invocation;
import org.apache.directory.server.core.invocation.InvocationStack;
import org.apache.directory.server.core.jndi.DeadContext;
-import org.apache.directory.server.core.partition.DirectoryPartitionNexusProxy;
+import org.apache.directory.server.core.partition.PartitionNexusProxy;
import org.apache.directory.shared.ldap.filter.ExprNode;
import org.apache.directory.shared.ldap.name.LdapDN;
@@ -82,7 +82,7 @@
LdapDN dn = new LdapDN( "ou=system" );
Context ctx = new DeadContext();
DirectoryService ds = new MockDirectoryService();
- DirectoryPartitionNexusProxy proxy = new DirectoryPartitionNexusProxy( ctx, ds );
+ PartitionNexusProxy proxy = new PartitionNexusProxy( ctx, ds );
Invocation i = new Invocation( proxy, ctx, "lookup", new Object[]
{ dn } );
InvocationStack.getInstance().push( i );
@@ -108,7 +108,7 @@
LdapDN dn = new LdapDN( "ou=system" );
Context ctx = new DeadContext();
DirectoryService ds = new MockDirectoryService();
- DirectoryPartitionNexusProxy proxy = new DirectoryPartitionNexusProxy( ctx, ds );
+ PartitionNexusProxy proxy = new PartitionNexusProxy( ctx, ds );
Invocation i = new Invocation( proxy, ctx, "lookup", new Object[]
{ dn }, Collections.singleton( "0" ) );
InvocationStack.getInstance().push( i );
@@ -138,7 +138,7 @@
LdapDN dn = new LdapDN( "ou=system" );
Context ctx = new DeadContext();
DirectoryService ds = new MockDirectoryService();
- DirectoryPartitionNexusProxy proxy = new DirectoryPartitionNexusProxy( ctx, ds );
+ PartitionNexusProxy proxy = new PartitionNexusProxy( ctx, ds );
Collection bypass = new HashSet();
bypass.add( "0" );
bypass.add( "1" );
@@ -172,7 +172,7 @@
LdapDN dn = new LdapDN( "ou=system" );
Context ctx = new DeadContext();
DirectoryService ds = new MockDirectoryService();
- DirectoryPartitionNexusProxy proxy = new DirectoryPartitionNexusProxy( ctx, ds );
+ PartitionNexusProxy proxy = new PartitionNexusProxy( ctx, ds );
Collection bypass = new HashSet();
bypass.add( "0" );
bypass.add( "4" );
@@ -202,7 +202,7 @@
LdapDN dn = new LdapDN( "ou=system" );
Context ctx = new DeadContext();
DirectoryService ds = new MockDirectoryService();
- DirectoryPartitionNexusProxy proxy = new DirectoryPartitionNexusProxy( ctx, ds );
+ PartitionNexusProxy proxy = new PartitionNexusProxy( ctx, ds );
Collection bypass = new HashSet();
bypass.add( "1" );
bypass.add( "3" );
@@ -232,9 +232,9 @@
LdapDN dn = new LdapDN( "ou=system" );
Context ctx = new DeadContext();
DirectoryService ds = new MockDirectoryService();
- DirectoryPartitionNexusProxy proxy = new DirectoryPartitionNexusProxy( ctx, ds );
+ PartitionNexusProxy proxy = new PartitionNexusProxy( ctx, ds );
Invocation i = new Invocation( proxy, ctx, "lookup", new Object[]
- { dn }, DirectoryPartitionNexusProxy.BYPASS_ALL_COLLECTION );
+ { dn }, PartitionNexusProxy.BYPASS_ALL_COLLECTION );
InvocationStack.getInstance().push( i );
try
@@ -304,7 +304,7 @@
}
- public void addContextPartition( NextInterceptor next, DirectoryPartitionConfiguration cfg )
+ public void addContextPartition( NextInterceptor next, PartitionConfiguration cfg )
throws NamingException
{
interceptors.add( this );
@@ -474,8 +474,8 @@
}
- public Context getJndiContext( String principal, byte[] credential, String authentication, String baseName )
- throws NamingException
+ public Context getJndiContext( LdapDN principalDn, String principal, byte[] credential,
+ String authentication, String baseName ) throws NamingException
{
return null; //To change body of implemented methods use File | Settings | File Templates.
}
Modified: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/jndi/RootDSETest.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/jndi/RootDSETest.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/jndi/RootDSETest.java (original)
+++ directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/jndi/RootDSETest.java Mon Jul 31 09:52:49 2006
@@ -161,7 +161,7 @@
Attributes attributes = ctx.getAttributes( "" );
// Added some objectClass attributes to the rootDSE
- assertEquals( 2, attributes.size() );
+ assertEquals( 1, attributes.size() );
}
Modified: directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/prefs/PreferencesUtilsTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/prefs/PreferencesUtilsTest.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/prefs/PreferencesUtilsTest.java (original)
+++ directory/trunks/apacheds/core/src/test/java/org/apache/directory/server/core/prefs/PreferencesUtilsTest.java Mon Jul 31 09:52:49 2006
@@ -47,7 +47,7 @@
LdapDN dn = ( LdapDN ) PreferencesUtils.toSysDn( test );
- assertEquals( dn.toUpName(), "prefNodeName=kerberos,prefNodeName=apache,prefNodeName=org,"
+ assertEquals( dn.getUpName(), "prefNodeName=kerberos,prefNodeName=apache,prefNodeName=org,"
+ PreferencesUtils.SYSPREF_BASE );
// simple test without trailing '/'
@@ -56,7 +56,7 @@
dn = ( LdapDN ) PreferencesUtils.toSysDn( test );
- assertEquals( dn.toUpName(), "prefNodeName=kerberos,prefNodeName=apache,prefNodeName=org,"
+ assertEquals( dn.getUpName(), "prefNodeName=kerberos,prefNodeName=apache,prefNodeName=org,"
+ PreferencesUtils.SYSPREF_BASE );
// basis condition tests
@@ -65,7 +65,7 @@
dn = ( LdapDN ) PreferencesUtils.toSysDn( test );
- assertEquals( dn.toUpName(), PreferencesUtils.SYSPREF_BASE );
+ assertEquals( dn.getUpName(), PreferencesUtils.SYSPREF_BASE );
// endpoint tests
@@ -73,7 +73,7 @@
dn = ( LdapDN ) PreferencesUtils.toSysDn( test );
- assertEquals( dn.toUpName(), PreferencesUtils.SYSPREF_BASE );
+ assertEquals( dn.getUpName(), PreferencesUtils.SYSPREF_BASE );
}
}
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java Mon Jul 31 09:52:49 2006
@@ -29,12 +29,14 @@
import org.apache.mina.filter.codec.asn1.Asn1CodecDecoder;
import org.apache.mina.filter.codec.asn1.Asn1CodecEncoder;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.ldap.support.AbandonHandler;
import org.apache.directory.server.ldap.support.AddHandler;
import org.apache.directory.server.ldap.support.BindHandler;
import org.apache.directory.server.ldap.support.CompareHandler;
import org.apache.directory.server.ldap.support.DeleteHandler;
import org.apache.directory.server.ldap.support.ExtendedHandler;
+import org.apache.directory.server.ldap.support.LdapMessageHandler;
import org.apache.directory.server.ldap.support.ModifyDnHandler;
import org.apache.directory.server.ldap.support.ModifyHandler;
import org.apache.directory.server.ldap.support.SearchHandler;
@@ -74,14 +76,12 @@
import org.apache.mina.common.IoFilterChain;
import org.apache.mina.common.IoHandler;
import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.LoggingFilter;
import org.apache.mina.filter.SSLFilter;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;
import org.apache.mina.handler.demux.DemuxingIoHandler;
-import org.apache.mina.handler.demux.MessageHandler;
import org.apache.mina.util.SessionLog;
@@ -100,6 +100,7 @@
private static final Map DEFAULT_HANDLERS;
/** a set of supported controls */
private static final Set SUPPORTED_CONTROLS;
+
static
{
@@ -171,7 +172,7 @@
* @param env environment properties used to configure the provider and
* underlying codec providers if any
*/
- public LdapProtocolProvider(Hashtable env) throws LdapNamingException
+ public LdapProtocolProvider( StartupConfiguration cfg, Hashtable env) throws LdapNamingException
{
Hashtable copy = ( Hashtable ) env.clone();
copy.put( Context.PROVIDER_URL, "" );
@@ -181,7 +182,7 @@
Iterator requestTypes = DEFAULT_HANDLERS.keySet().iterator();
while ( requestTypes.hasNext() )
{
- MessageHandler handler = null;
+ LdapMessageHandler handler = null;
String type = ( String ) requestTypes.next();
Class clazz = null;
@@ -209,7 +210,8 @@
try
{
Class typeClass = Class.forName( type );
- handler = ( MessageHandler ) clazz.newInstance();
+ handler = ( LdapMessageHandler ) clazz.newInstance();
+ handler.init( cfg );
this.handler.addMessageHandler( typeClass, handler );
}
catch ( Exception e )
@@ -227,44 +229,6 @@
}
- /**
- * Creates a MINA LDAP protocol provider.
- */
- public LdapProtocolProvider() throws LdapNamingException
- {
- SessionRegistry.releaseSingleton();
- new SessionRegistry( null );
-
- Iterator requestTypes = DEFAULT_HANDLERS.keySet().iterator();
- while ( requestTypes.hasNext() )
- {
- MessageHandler handler = null;
- String type = ( String ) requestTypes.next();
- Class clazz = null;
-
- clazz = ( Class ) DEFAULT_HANDLERS.get( type );
-
- try
- {
- Class typeClass = Class.forName( type );
- handler = ( MessageHandler ) clazz.newInstance();
- this.handler.addMessageHandler( typeClass, handler );
- }
- catch ( Exception e )
- {
- LdapNamingException lne;
- String msg = "failed to create handler instance of " + clazz;
- msg += " for processing " + type + " objects.";
- lne = new LdapNamingException( msg, ResultCodeEnum.OTHER );
- lne.setRootCause( e );
- throw lne;
- }
- }
-
- this.codecFactory = new ProtocolCodecFactoryImpl();
- }
-
-
// ------------------------------------------------------------------------
// ProtocolProvider Methods
// ------------------------------------------------------------------------
@@ -372,7 +336,11 @@
{
IoFilterChain filters = session.getFilterChain();
filters.addLast( "codec", new ProtocolCodecFilter( codecFactory ) );
- filters.addLast( "logger", new LoggingFilter() );
+
+ // TODO : The filter is logging too much information.
+ // Right now, I have commented it, but it may be
+ // used with some parameter to disable it
+ //filters.addLast( "logger", new LoggingFilter() );
}
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java Mon Jul 31 09:52:49 2006
@@ -118,7 +118,7 @@
*
* @return the registry environment
*/
- public Hashtable getEnvironment()
+ public Hashtable getEnvironmentByCopy()
{
return ( Hashtable ) env.clone();
}
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/OutstandingRequestsDialog.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/OutstandingRequestsDialog.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/OutstandingRequestsDialog.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/OutstandingRequestsDialog.java Mon Jul 31 09:52:49 2006
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.ldap.gui;
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/OutstandingRequestsModel.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/OutstandingRequestsModel.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/OutstandingRequestsModel.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/OutstandingRequestsModel.java Mon Jul 31 09:52:49 2006
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.ldap.gui;
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java Mon Jul 31 09:52:49 2006
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.ldap.gui;
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsModel.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsModel.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsModel.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsModel.java Mon Jul 31 09:52:49 2006
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.ldap.gui;
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/ShutdownDialog.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/ShutdownDialog.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/ShutdownDialog.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/ShutdownDialog.java Mon Jul 31 09:52:49 2006
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.ldap.gui;
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/ShutdownProgress.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/ShutdownProgress.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/ShutdownProgress.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/ShutdownProgress.java Mon Jul 31 09:52:49 2006
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.ldap.gui;
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java Mon Jul 31 09:52:49 2006
@@ -17,12 +17,13 @@
package org.apache.directory.server.ldap.support;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.message.AbandonRequest;
import org.apache.directory.shared.ldap.message.AbandonableRequest;
import org.apache.directory.shared.ldap.message.Request;
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,10 +34,12 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class AbandonHandler implements MessageHandler
+public class AbandonHandler implements LdapMessageHandler
{
private static final Logger log = LoggerFactory.getLogger( AbandonHandler.class );
+ /** Speedup for logs */
+ private static final boolean IS_DEBUG = log.isDebugEnabled();
public void messageReceived( IoSession session, Object request ) throws Exception
{
@@ -77,10 +80,15 @@
}
else
{
- if ( log.isDebugEnabled() )
+ if ( IS_DEBUG )
{
log.debug( "Abandoned request: " + req );
}
}
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java Mon Jul 31 09:52:49 2006
@@ -22,6 +22,7 @@
import javax.naming.ReferralException;
import javax.naming.ldap.LdapContext;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.message.AddRequest;
@@ -32,8 +33,8 @@
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.util.ExceptionUtils;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,18 +46,20 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class AddHandler implements MessageHandler
+public class AddHandler implements LdapMessageHandler
{
private static final Logger log = LoggerFactory.getLogger( AddHandler.class );
private static Control[] EMPTY_CONTROLS = new Control[0];
+ /** Speedup for logs */
+ private static final boolean IS_DEBUG = log.isDebugEnabled();
public void messageReceived( IoSession session, Object request ) throws Exception
{
AddRequest req = ( AddRequest ) request;
LdapResult result = req.getResultResponse().getLdapResult();
- if ( log.isDebugEnabled() )
+ if ( IS_DEBUG )
{
log.debug( "Received a Add message : " + req.toString() );
}
@@ -127,5 +130,10 @@
result.setResultCode( ResultCodeEnum.SUCCESS );
session.write( req.getResultResponse() );
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java Mon Jul 31 09:52:49 2006
@@ -25,6 +25,8 @@
import javax.naming.ldap.LdapContext;
import javax.naming.spi.InitialContextFactory;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
+import org.apache.directory.server.core.jndi.PropertyKeys;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.message.BindRequest;
@@ -34,8 +36,8 @@
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.util.ExceptionUtils;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,18 +48,20 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class BindHandler implements MessageHandler
+public class BindHandler implements LdapMessageHandler
{
private static final Logger log = LoggerFactory.getLogger( BindHandler.class );
private static final Control[] EMPTY = new Control[0];
+ /** Speedup for logs */
+ private static final boolean IS_DEBUG = log.isDebugEnabled();
public void messageReceived( IoSession session, Object request ) throws Exception
{
LdapContext ctx;
BindRequest req = ( BindRequest ) request;
LdapResult result = req.getResultResponse().getLdapResult();
- Hashtable env = SessionRegistry.getSingleton().getEnvironment();
+ Hashtable env = SessionRegistry.getSingleton().getEnvironmentByCopy();
// if the bind request is not simple then we freak: no strong auth yet
if ( !req.isSimple() )
@@ -70,26 +74,25 @@
// clone the environment first then add the required security settings
byte[] creds = req.getCredentials();
-
- Hashtable cloned = ( Hashtable ) env.clone();
- cloned.put( Context.SECURITY_PRINCIPAL, req.getName() );
- cloned.put( Context.SECURITY_CREDENTIALS, creds );
- cloned.put( Context.SECURITY_AUTHENTICATION, "simple" );
+ env.put( Context.SECURITY_PRINCIPAL, req.getName() );
+ env.put( Context.SECURITY_CREDENTIALS, creds );
+ env.put( Context.SECURITY_AUTHENTICATION, "simple" );
+ env.put( PropertyKeys.PARSED_BIND_DN, req.getName() );
if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
{
- cloned.put( Context.REFERRAL, "ignore" );
+ env.put( Context.REFERRAL, "ignore" );
}
else
{
- cloned.put( Context.REFERRAL, "throw" );
+ env.put( Context.REFERRAL, "throw" );
}
try
{
- if ( cloned.containsKey( "server.use.factory.instance" ) )
+ if ( env.containsKey( "server.use.factory.instance" ) )
{
- InitialContextFactory factory = ( InitialContextFactory ) cloned.get( "server.use.factory.instance" );
+ InitialContextFactory factory = ( InitialContextFactory ) env.get( "server.use.factory.instance" );
if ( factory == null )
{
@@ -97,12 +100,12 @@
}
// Bind is a special case where we have to use the referral property to deal
- ctx = ( LdapContext ) factory.getInitialContext( cloned );
+ ctx = ( LdapContext ) factory.getInitialContext( env );
}
else
{
Control[] connCtls = ( Control[] ) req.getControls().values().toArray( EMPTY );
- ctx = new InitialLdapContext( cloned, connCtls );
+ ctx = new InitialLdapContext( env, connCtls );
}
}
catch ( NamingException e )
@@ -121,7 +124,8 @@
}
String msg = "Bind failed";
- if ( log.isDebugEnabled() )
+
+ if ( IS_DEBUG )
{
msg += ":\n" + ExceptionUtils.getStackTrace( e );
msg += "\n\nBindRequest = \n" + req.toString();
@@ -142,5 +146,10 @@
SessionRegistry.getSingleton().setLdapContext( session, ctx );
result.setResultCode( ResultCodeEnum.SUCCESS );
session.write( req.getResultResponse() );
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java Mon Jul 31 09:52:49 2006
@@ -22,6 +22,7 @@
import javax.naming.ReferralException;
import javax.naming.ldap.LdapContext;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.core.jndi.ServerLdapContext;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.exception.LdapException;
@@ -33,8 +34,8 @@
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.util.ExceptionUtils;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,11 +47,13 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class CompareHandler implements MessageHandler
+public class CompareHandler implements LdapMessageHandler
{
private static final Logger log = LoggerFactory.getLogger( CompareHandler.class );
private static Control[] EMPTY_CONTROLS = new Control[0];
+ /** Speedup for logs */
+ private static final boolean IS_DEBUG = log.isDebugEnabled();
public void messageReceived( IoSession session, Object request ) throws Exception
{
@@ -103,7 +106,7 @@
{
String msg = "failed to compare entry " + req.getName();
- if ( log.isDebugEnabled() )
+ if ( IS_DEBUG )
{
msg += ":\n" + ExceptionUtils.getStackTrace( e );
}
@@ -140,5 +143,10 @@
result.setMatchedDn( req.getName() );
session.write( req.getResultResponse() );
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java Mon Jul 31 09:52:49 2006
@@ -22,6 +22,7 @@
import javax.naming.ReferralException;
import javax.naming.ldap.LdapContext;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.message.Control;
@@ -32,8 +33,8 @@
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.util.ExceptionUtils;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,11 +46,13 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class DeleteHandler implements MessageHandler
+public class DeleteHandler implements LdapMessageHandler
{
private static final Logger log = LoggerFactory.getLogger( DeleteHandler.class );
private static Control[] EMPTY_CONTROLS = new Control[0];
+ /** Speedup for logs */
+ private static final boolean IS_DEBUG = log.isDebugEnabled();
public void messageReceived( IoSession session, Object request ) throws Exception
{
@@ -90,7 +93,7 @@
{
String msg = "failed to delete entry " + req.getName();
- if ( log.isDebugEnabled() )
+ if ( IS_DEBUG )
{
msg += ":\n" + ExceptionUtils.getStackTrace( e );
}
@@ -120,5 +123,10 @@
result.setResultCode( ResultCodeEnum.SUCCESS );
session.write( req.getResultResponse() );
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java Mon Jul 31 09:52:49 2006
@@ -21,6 +21,7 @@
import java.util.HashMap;
import java.util.Map;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.ldap.ExtendedOperationHandler;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.message.ExtendedRequest;
@@ -28,8 +29,8 @@
import org.apache.directory.shared.ldap.message.LdapResult;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.util.ExceptionUtils;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
/**
@@ -38,7 +39,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class ExtendedHandler implements MessageHandler
+public class ExtendedHandler implements LdapMessageHandler
{
private Map handlers = new HashMap();
@@ -105,5 +106,10 @@
session.write( req.getResultResponse() );
}
}
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java Mon Jul 31 09:52:49 2006
@@ -16,12 +16,13 @@
*/
package org.apache.directory.server.ldap.support;
-
+
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.ReferralException;
import javax.naming.ldap.LdapContext;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.message.Control;
@@ -32,8 +33,8 @@
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.util.ExceptionUtils;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,20 +46,22 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class ModifyDnHandler implements MessageHandler
+public class ModifyDnHandler implements LdapMessageHandler
{
- private static final Logger LOG = LoggerFactory.getLogger( ModifyDnHandler.class );
+ private static final Logger log = LoggerFactory.getLogger( ModifyDnHandler.class );
private static Control[] EMPTY_CONTROLS = new Control[0];
+ /** Speedup for logs */
+ private static final boolean IS_DEBUG = log.isDebugEnabled();
public void messageReceived( IoSession session, Object request ) throws Exception
{
ModifyDnRequest req = ( ModifyDnRequest ) request;
LdapResult result = req.getResultResponse().getLdapResult();
- if ( LOG.isDebugEnabled() )
+ if ( IS_DEBUG )
{
- LOG.debug( "req.getName() == [" + req.getName() + "]" );
+ log.debug( "req.getName() == [" + req.getName() + "]" );
}
if ( req.getName().isEmpty() )
@@ -150,7 +153,8 @@
catch ( NamingException e )
{
String msg = "failed to modify DN of entry " + req.getName();
- if ( LOG.isDebugEnabled() )
+
+ if ( IS_DEBUG )
{
msg += ":\n" + ExceptionUtils.getStackTrace( e );
}
@@ -183,5 +187,10 @@
result.setResultCode( ResultCodeEnum.SUCCESS );
session.write( req.getResultResponse() );
}
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java Mon Jul 31 09:52:49 2006
@@ -23,6 +23,7 @@
import javax.naming.directory.ModificationItem;
import javax.naming.ldap.LdapContext;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.message.Control;
@@ -33,8 +34,8 @@
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.util.ExceptionUtils;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,12 +47,14 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class ModifyHandler implements MessageHandler
+public class ModifyHandler implements LdapMessageHandler
{
- private static final Logger LOG = LoggerFactory.getLogger( ModifyHandler.class );
+ private static final Logger log = LoggerFactory.getLogger( ModifyHandler.class );
private static final ModificationItem[] EMPTY = new ModificationItem[0];
private static Control[] EMPTY_CONTROLS = new Control[0];
+ /** Speedup for logs */
+ private static final boolean IS_DEBUG = log.isDebugEnabled();
public void messageReceived( IoSession session, Object request ) throws Exception
{
@@ -92,7 +95,8 @@
catch ( NamingException e )
{
String msg = "failed to modify entry " + req.getName();
- if ( LOG.isDebugEnabled() )
+
+ if ( IS_DEBUG )
{
msg += ":\n" + ExceptionUtils.getStackTrace( e );
}
@@ -124,5 +128,10 @@
result.setResultCode( ResultCodeEnum.SUCCESS );
session.write( req.getResultResponse() );
return;
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/PersistentSearchListener.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/PersistentSearchListener.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/PersistentSearchListener.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/PersistentSearchListener.java Mon Jul 31 09:52:49 2006
@@ -67,6 +67,8 @@
final SearchRequest req;
final PersistentSearchControl control;
+ /** Speedup for logs */
+ private static final boolean IS_DEBUG = log.isDebugEnabled();
PersistentSearchListener(ServerLdapContext ctx, IoSession session, SearchRequest req)
{
@@ -132,7 +134,7 @@
SessionRegistry.getSingleton().removeOutstandingRequest( session, new Integer( req.getMessageId() ) );
String msg = "failed on persistent search operation";
- if ( log.isDebugEnabled() )
+ if ( IS_DEBUG )
{
msg += ":\n" + req + ":\n" + ExceptionUtils.getStackTrace( evt.getException() );
}
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java Mon Jul 31 09:52:49 2006
@@ -28,9 +28,9 @@
import javax.naming.directory.SearchControls;
import javax.naming.ldap.LdapContext;
-import org.apache.directory.server.core.configuration.Configuration;
import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.core.jndi.ServerLdapContext;
+import org.apache.directory.server.core.partition.PartitionNexus;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.codec.util.LdapResultEnum;
import org.apache.directory.shared.ldap.exception.LdapException;
@@ -49,8 +49,8 @@
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.util.ArrayUtils;
import org.apache.directory.shared.ldap.util.ExceptionUtils;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,11 +62,14 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class SearchHandler implements MessageHandler
+public class SearchHandler implements LdapMessageHandler
{
private static final Logger log = LoggerFactory.getLogger( SearchHandler.class );
private static final String DEREFALIASES_KEY = "java.naming.ldap.derefAliases";
+ private StartupConfiguration cfg;
+ /** Speedup for logs */
+ private static final boolean IS_DEBUG = log.isDebugEnabled();
/**
* Builds the JNDI search controls for a SearchRequest.
@@ -75,12 +78,36 @@
* @param ids the ids to return
* @return the SearchControls to use with the ApacheDS server side JNDI provider
*/
- private static SearchControls getSearchControls( SearchRequest req, String[] ids )
+ private SearchControls getSearchControls( SearchRequest req, String[] ids, boolean isAdmin )
{
// prepare all the search controls
SearchControls controls = new SearchControls();
- controls.setCountLimit( req.getSizeLimit() );
- controls.setTimeLimit( req.getTimeLimit() );
+
+ // take the minimum of system limit with request specified value
+ if ( isAdmin )
+ {
+ controls.setCountLimit( req.getSizeLimit() );
+
+ // The setTimeLimit needs a number of milliseconds
+ // when the search control is expressed in seconds
+ int timeLimit = req.getTimeLimit();
+
+ // Just check that we are not exceeding the maximum for a long
+ if ( timeLimit > Integer.MAX_VALUE / 1000 )
+ {
+ timeLimit = 0;
+ }
+
+ // The maximum time we can wait is around 24 days ...
+ // Is it enough ? ;)
+ controls.setTimeLimit( timeLimit * 1000 );
+ }
+ else
+ {
+ controls.setCountLimit( Math.min( req.getSizeLimit(), cfg.getMaxSizeLimit() ) );
+ controls.setTimeLimit( ( int ) Math.min( req.getTimeLimit(), cfg.getMaxTimeLimit() ) );
+ }
+
controls.setSearchScope( req.getScope().getValue() );
controls.setReturningObjFlag( req.getTypesOnly() );
controls.setReturningAttributes( ids );
@@ -113,7 +140,12 @@
*/
public void messageReceived( IoSession session, Object request ) throws Exception
{
- ServerLdapContext ctx;
+ if ( IS_DEBUG )
+ {
+ log.debug( "Message received : " + request.toString() );
+ }
+
+ ServerLdapContext ctx;
SearchRequest req = ( SearchRequest ) request;
NamingEnumeration list = null;
String[] ids = null;
@@ -133,7 +165,6 @@
{
ids = ( String[] ) retAttrs.toArray( ArrayUtils.EMPTY_STRING_ARRAY );
}
- SearchControls controls = getSearchControls( req, ids );
try
{
@@ -182,7 +213,6 @@
// Handle annonymous binds
// ===============================================================
- StartupConfiguration cfg = ( StartupConfiguration ) Configuration.toConfiguration( ctx.getEnvironment() );
boolean allowAnonymousBinds = cfg.isAllowAnonymousAccess();
boolean isAnonymousUser = ( ( ServerLdapContext ) ctx ).getPrincipal().getName().trim().equals( "" );
@@ -196,6 +226,27 @@
return;
}
+
+ // ===============================================================
+ // Set search limits differently based on user's identity
+ // ===============================================================
+
+ SearchControls controls = null;
+ if ( isAnonymousUser )
+ {
+ controls = getSearchControls( req, ids, false );
+ }
+ else if ( ( ( ServerLdapContext ) ctx ).getPrincipal().getName()
+ .trim().equals( PartitionNexus.ADMIN_PRINCIPAL ) )
+ {
+ controls = getSearchControls( req, ids, true );
+ }
+ else
+ {
+ controls = getSearchControls( req, ids, false );
+ }
+
+
// ===============================================================
// Handle psearch differently
// ===============================================================
@@ -251,7 +302,6 @@
StringBuffer buf = new StringBuffer();
req.getFilter().printToBuffer( buf );
ctx.addNamingListener( req.getBase(), buf.toString(), controls, handler );
- SessionRegistry.getSingleton().addOutstandingRequest( session, req );
return;
}
@@ -376,5 +426,11 @@
}
}
}
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
+ this.cfg = cfg;
}
}
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java Mon Jul 31 09:52:49 2006
@@ -67,6 +67,8 @@
private Object prefetched;
private final int scope;
+ /** Speedup for logs */
+ private static final boolean IS_DEBUG = log.isDebugEnabled();
/**
* Creates a search response iterator for the resulting enumeration
@@ -399,7 +401,7 @@
{
String msg = "failed on search operation";
- if ( log.isDebugEnabled() )
+ if ( IS_DEBUG )
{
msg += ":\n" + req + ":\n" + ExceptionUtils.getStackTrace( e );
}
Modified: directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java?rev=427171&r1=427170&r2=427171&view=diff
==============================================================================
--- directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java (original)
+++ directory/trunks/apacheds/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java Mon Jul 31 09:52:49 2006
@@ -20,10 +20,11 @@
import javax.naming.NamingException;
import javax.naming.ldap.LdapContext;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.core.jndi.ServerLdapContext;
import org.apache.directory.server.ldap.SessionRegistry;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,7 +37,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class UnbindHandler implements MessageHandler
+public class UnbindHandler implements LdapMessageHandler
{
private static final Logger log = LoggerFactory.getLogger( UnbindHandler.class );
@@ -64,5 +65,10 @@
{
log.error( "failed to unbind session properly", e );
}
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}