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/02/10 11:49:57 UTC
svn commit: r376623 [9/38] - in /directory/sandbox/akarasulu/rc1/apacheds:
core-plugin/src/main/java/org/apache/directory/server/core/tools/schema/
core-plugin/src/test/java/org/apache/directory/server/core/tools/schema/
core-shared/src/main/java/org/a...
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/JavaLdapSupport.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/JavaLdapSupport.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/JavaLdapSupport.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/JavaLdapSupport.java Fri Feb 10 02:48:07 2006
@@ -68,7 +68,6 @@
// Package Friendly & Private Utility Methods
// ------------------------------------------------------------------------
-
/**
* Resusitates an object from a serialized attribute in an entry that
* conforms to the specifications for representing Java Objects in an LDAP
@@ -85,14 +84,14 @@
try
{
- byte [] data = ( byte [] ) attributes.get( JSERIALDATA_ATTR ).get();
+ byte[] data = ( byte[] ) attributes.get( JSERIALDATA_ATTR ).get();
in = new ObjectInputStream( new ByteArrayInputStream( data ) );
return in.readObject();
}
catch ( Exception e )
{
- NamingException ne = new NamingException( "De-serialization of '"
- + className + "' instance failed:\n" + e.getMessage() );
+ NamingException ne = new NamingException( "De-serialization of '" + className + "' instance failed:\n"
+ + e.getMessage() );
ne.setRootCause( e );
throw ne;
}
@@ -109,7 +108,7 @@
}
}
-
+
/**
* Serializes an object into a byte array.
*
@@ -117,7 +116,7 @@
* @return the object's serialized byte array form
* @throws NamingException of the object cannot be serialized
*/
- static byte [] serialize( Object obj ) throws NamingException
+ static byte[] serialize( Object obj ) throws NamingException
{
ByteArrayOutputStream bytesOut = null;
ObjectOutputStream out = null;
@@ -131,8 +130,7 @@
}
catch ( Exception e )
{
- NamingException ne = new NamingException( "Serialization of '"
- + obj + "' failed:\n" + e.getMessage() );
+ NamingException ne = new NamingException( "Serialization of '" + obj + "' failed:\n" + e.getMessage() );
ne.setRootCause( e );
throw ne;
}
@@ -178,7 +176,7 @@
entry.put( JSERIALDATA_ATTR, serialize( obj ) );
// Add all the class names this object can be cast to:
- Class [] classes = obj.getClass().getClasses();
+ Class[] classes = obj.getClass().getClasses();
Attribute javaClassNames = new LockableAttributeImpl( JCLASSNAMES_ATTR );
for ( int ii = 0; ii < classes.length; ii++ )
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/LdapJndiProperties.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/LdapJndiProperties.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/LdapJndiProperties.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/LdapJndiProperties.java Fri Feb 10 02:48:07 2006
@@ -41,16 +41,16 @@
public class LdapJndiProperties
{
private static final String SASL_AUTHID = "java.naming.security.sasl.authorizationId";
-
+
private LdapName providerDn;
private LdapName bindDn;
private String saslAuthId;
private AuthenticationLevel level;
private List mechanisms = new ArrayList();
private byte[] credentials;
-
- public static AuthenticationLevel getAuthenticationLevel( Hashtable env ) throws NamingException
+
+ public static AuthenticationLevel getAuthenticationLevel( Hashtable env ) throws NamingException
{
AuthenticationLevel level;
Object credobj = env.get( Context.SECURITY_CREDENTIALS );
@@ -72,12 +72,12 @@
level = AuthenticationLevel.SIMPLE;
}
}
- else if ( ! ( authentication instanceof String ) )
+ else if ( !( authentication instanceof String ) )
{
throw new LdapConfigurationException( "Don't know how to interpret " + authentication.getClass()
+ " objects for environment property " + Context.SECURITY_AUTHENTICATION );
}
- else
+ else
{
if ( "none".equals( authentication ) )
{
@@ -92,28 +92,28 @@
level = AuthenticationLevel.STRONG;
}
}
-
+
return level;
}
-
-
+
+
public static LdapJndiProperties getLdapJndiProperties( Hashtable env ) throws NamingException
{
if ( env == null )
{
throw new LdapConfigurationException( "environment cannot be null" );
}
-
+
LdapJndiProperties props = new LdapJndiProperties();
Object principal = env.get( Context.SECURITY_PRINCIPAL );
Object credobj = env.get( Context.SECURITY_CREDENTIALS );
Object authentication = env.get( Context.SECURITY_AUTHENTICATION );
-
+
// -------------------------------------------------------------------
// check for the provider URL property
// -------------------------------------------------------------------
- if ( ! env.containsKey( Context.PROVIDER_URL ) )
+ if ( !env.containsKey( Context.PROVIDER_URL ) )
{
String msg = "Expected property " + Context.PROVIDER_URL;
msg += " but could not find it in env!";
@@ -155,12 +155,12 @@
props.mechanisms.add( "simple" );
}
}
- else if ( ! ( authentication instanceof String ) )
+ else if ( !( authentication instanceof String ) )
{
throw new LdapConfigurationException( "Don't know how to interpret " + authentication.getClass()
+ " objects for environment property " + Context.SECURITY_AUTHENTICATION );
}
- else
+ else
{
if ( "none".equals( authentication ) )
{
@@ -178,7 +178,7 @@
String[] mechList = ( ( String ) authentication ).trim().split( " " );
for ( int ii = 0; ii < mechList.length; ii++ )
{
- if ( ! mechList[ii].trim().equals( "" ) )
+ if ( !mechList[ii].trim().equals( "" ) )
{
props.mechanisms.add( mechList[ii] );
}
@@ -195,13 +195,12 @@
throw new LdapConfigurationException( Context.SECURITY_PRINCIPAL + " cannot be null." );
}
- if ( ! ( principal instanceof String ) )
+ if ( !( principal instanceof String ) )
{
throw new LdapConfigurationException( "Don't know how to interpret " + principal.getClass()
+ " objects for environment property " + Context.SECURITY_PRINCIPAL );
}
-
-
+
if ( ( ( String ) principal ).trim().equals( "" ) )
{
props.bindDn = LdapName.EMPTY_LDAP_NAME;
@@ -210,7 +209,7 @@
{
props.bindDn = new LdapName( ( String ) principal );
}
-
+
if ( env.get( SASL_AUTHID ) != null && props.level == AuthenticationLevel.STRONG )
{
Object obj = env.get( SASL_AUTHID );
@@ -218,14 +217,14 @@
{
props.saslAuthId = ( String ) obj;
}
- else
+ else
{
throw new LdapConfigurationException( "Don't know how to interpret " + obj.getClass()
+ " objects for environment property " + SASL_AUTHID );
}
props.saslAuthId = ( String ) principal;
}
-
+
// -------------------------------------------------------------------
// Figure out the credentials
// -------------------------------------------------------------------
@@ -250,22 +249,22 @@
+ " objects for environment property " + Context.SECURITY_CREDENTIALS );
}
}
-
+
return props;
}
-
+
public LdapName getBindDn()
{
return bindDn;
}
-
+
public LdapName getProviderDn()
{
return providerDn;
}
-
+
public String getSaslAuthId()
{
@@ -277,14 +276,14 @@
{
return level;
}
-
-
+
+
public List getAuthenticationMechanisms()
{
return Collections.unmodifiableList( mechanisms );
}
-
-
+
+
public byte[] getCredentials()
{
return credentials;
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java Fri Feb 10 02:48:07 2006
@@ -70,7 +70,7 @@
/** The directory service which owns this context **/
private final DirectoryService service;
-
+
/** The interceptor proxy to the backend nexus */
private final DirectoryPartitionNexus nexusProxy;
@@ -86,11 +86,11 @@
/** The Principal associated with this context */
private LdapPrincipal principal;
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
-
/**
* Must be called by all subclasses to initialize the nexus proxy and the
* environment settings to be used by this Context implementation. This
@@ -105,13 +105,13 @@
* @throws NamingException if the environment parameters are not set
* correctly.
*/
- protected ServerContext( DirectoryService service, Hashtable env ) throws NamingException
+ protected ServerContext(DirectoryService service, Hashtable env) throws NamingException
{
this.service = service;
-
+
// set references to cloned env and the proxy
this.nexusProxy = new DirectoryPartitionNexusProxy( this, service );
-
+
DirectoryServiceConfiguration cfg = service.getConfiguration();
this.env = ( Hashtable ) cfg.getEnvironment().clone();
this.env.putAll( env );
@@ -119,11 +119,12 @@
dn = props.getProviderDn();
// need to issue a bind operation here
- this.nexusProxy.bind( props.getBindDn(), props.getCredentials(),
- props.getAuthenticationMechanisms(), props.getSaslAuthId() );
+ this.nexusProxy.bind( props.getBindDn(), props.getCredentials(), props.getAuthenticationMechanisms(), props
+ .getSaslAuthId() );
- if ( dn.size() == 0 ) return;
- if ( ! nexusProxy.hasEntry( dn ) )
+ if ( dn.size() == 0 )
+ return;
+ if ( !nexusProxy.hasEntry( dn ) )
{
throw new NameNotFoundException( dn + " does not exist" );
}
@@ -140,14 +141,15 @@
* @param env the environment properties used by this context
* @param dn the distinguished name of this context
*/
- protected ServerContext( DirectoryService service, LdapPrincipal principal, Name dn ) throws NamingException
+ protected ServerContext(DirectoryService service, LdapPrincipal principal, Name dn) throws NamingException
{
this.service = service;
this.dn = ( LdapName ) dn.clone();
this.env = ( Hashtable ) service.getConfiguration().getEnvironment().clone();
this.env.put( PROVIDER_URL, dn.toString() );
- this.nexusProxy = new DirectoryPartitionNexusProxy( this, service );;
+ this.nexusProxy = new DirectoryPartitionNexusProxy( this, service );
+ ;
this.principal = principal;
}
@@ -164,6 +166,7 @@
return service;
}
+
/**
* Gets the principal of the authenticated user which also happens to own
*/
@@ -190,7 +193,6 @@
// Protected Accessor Methods
// ------------------------------------------------------------------------
-
/**
* Gets the RootNexus proxy.
*
@@ -198,7 +200,7 @@
*/
protected DirectoryPartitionNexus getNexusProxy()
{
- return nexusProxy ;
+ return nexusProxy;
}
@@ -217,7 +219,6 @@
// JNDI Context Interface Methods
// ------------------------------------------------------------------------
-
/**
* @see javax.naming.Context#close()
*/
@@ -226,8 +227,8 @@
Iterator list = listeners.iterator();
while ( list.hasNext() )
{
- ( ( DirectoryPartitionNexusProxy ) this.nexusProxy )
- .removeNamingListener( this, ( NamingListener ) list.next() );
+ ( ( DirectoryPartitionNexusProxy ) this.nexusProxy ).removeNamingListener( this, ( NamingListener ) list
+ .next() );
}
}
@@ -293,7 +294,7 @@
attributes.put( rdnAttribute, rdnValue );
attributes.put( JavaLdapSupport.OBJECTCLASS_ATTR, JavaLdapSupport.JCONTAINER_ATTR );
attributes.put( JavaLdapSupport.OBJECTCLASS_ATTR, JavaLdapSupport.TOP_ATTR );
-
+
/*
* Add the new context to the server which as a side effect adds
* operational attributes to the attributes refering instance which
@@ -337,7 +338,7 @@
{
bind( new LdapName( name ), obj );
}
-
+
/**
* @see javax.naming.Context#bind(javax.naming.Name, java.lang.Object)
@@ -435,7 +436,7 @@
String newRdn = newName.get( newName.size() - 1 );
String oldRdn = oldName.get( oldName.size() - 1 );
boolean delOldRdn = true;
-
+
/*
* Attempt to use the java.naming.ldap.deleteRDN environment property
* to get an override for the deleteOldRdn option to modifyRdn.
@@ -443,7 +444,7 @@
if ( null != env.get( DELETE_OLD_RDN_PROP ) )
{
String delOldRdnStr = ( String ) env.get( DELETE_OLD_RDN_PROP );
- delOldRdn = ! delOldRdnStr.equals( "false" );
+ delOldRdn = !delOldRdnStr.equals( "false" );
delOldRdn = delOldRdn || delOldRdnStr.equals( "no" );
delOldRdn = delOldRdn || delOldRdnStr.equals( "0" );
}
@@ -565,18 +566,18 @@
// Give back serialized object and not a context
return JavaLdapSupport.deserialize( attributes );
}
-
+
// Initialize and return a context since the entry is not a java object
ServerLdapContext ctx = new ServerLdapContext( service, principal, target );
-
+
// Need to add controls to propagate extended ldap operational env
- Control [] controls = ( ( ServerLdapContext ) this ).getRequestControls();
+ Control[] controls = ( ( ServerLdapContext ) this ).getRequestControls();
if ( null != controls )
- {
- ctx.setRequestControls( ( Control [] ) controls.clone() );
+ {
+ ctx.setRequestControls( ( Control[] ) controls.clone() );
}
-
+
return ctx;
}
@@ -664,7 +665,7 @@
PresenceNode filter = new PresenceNode( "objectClass" );
SearchControls ctls = new SearchControls();
ctls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
- return nexusProxy.search( base , getEnvironment(), filter, ctls );
+ return nexusProxy.search( base, getEnvironment(), filter, ctls );
}
@@ -703,11 +704,11 @@
* head of the prefix is found.
* 3). Return the remainder of the fqn or Dn after chewing off some
*/
-
+
// 1). Find the Dn for name and walk it from the head to tail
Name fqn = buildTarget( name );
String head = prefix.get( 0 );
-
+
// 2). Walk the fqn trying to match for the head of the prefix
while ( fqn.size() > 0 )
{
@@ -716,7 +717,8 @@
{
return fqn;
}
- else // 2). Remove name components from the Dn until a match
+ else
+ // 2). Remove name components from the Dn until a match
{
fqn.remove( 0 );
}
@@ -732,14 +734,13 @@
// EventContext implementations
// ------------------------------------------------------------------------
-
public void addNamingListener( Name name, int scope, NamingListener namingListener ) throws NamingException
{
ExprNode filter = new PresenceNode( "objectClass" );
SearchControls controls = new SearchControls();
controls.setSearchScope( scope );
- ( ( DirectoryPartitionNexusProxy ) this.nexusProxy )
- .addNamingListener( this, buildTarget( name ), filter, controls, namingListener );
+ ( ( DirectoryPartitionNexusProxy ) this.nexusProxy ).addNamingListener( this, buildTarget( name ), filter,
+ controls, namingListener );
listeners.add( namingListener );
}
@@ -777,8 +778,7 @@
// ------------------------------------------------------------------------
// Utility Methods to Reduce Code
// ------------------------------------------------------------------------
-
-
+
/**
* Clones this context's DN and adds the components of the name relative to
* this context to the left hand side of this context's cloned DN.
@@ -792,7 +792,7 @@
{
// Clone our DN or absolute path
LdapName target = ( LdapName ) dn.clone();
-
+
// Add to left hand side of cloned DN the relative name arg
target.addAll( target.size(), relativeName );
return target;
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java Fri Feb 10 02:48:07 2006
@@ -62,7 +62,7 @@
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
-
+
/**
* Creates a new ServerDirContext by reading the PROVIDER_URL to resolve the
* distinguished name for this context.
@@ -71,7 +71,7 @@
* @param env the environment used for this context
* @throws NamingException if something goes wrong
*/
- public ServerDirContext( DirectoryService service, Hashtable env ) throws NamingException
+ public ServerDirContext(DirectoryService service, Hashtable env) throws NamingException
{
super( service, env );
}
@@ -86,7 +86,7 @@
* @param env the environment properties used by this context
* @param dn the distinguished name of this context
*/
- protected ServerDirContext( DirectoryService service, LdapPrincipal principal, Name dn ) throws NamingException
+ protected ServerDirContext(DirectoryService service, LdapPrincipal principal, Name dn) throws NamingException
{
super( service, principal, dn );
}
@@ -96,7 +96,6 @@
// DirContext Implementations
// ------------------------------------------------------------------------
-
/**
* @see javax.naming.directory.DirContext#getAttributes(java.lang.String)
*/
@@ -104,7 +103,7 @@
{
return getAttributes( new LdapName( name ) );
}
-
+
/**
* @see javax.naming.directory.DirContext#getAttributes(javax.naming.Name)
@@ -133,7 +132,7 @@
{
return getNexusProxy().lookup( buildTarget( name ), attrIds );
}
-
+
/**
* @see javax.naming.directory.DirContext#modifyAttributes(java.lang.String,
@@ -173,7 +172,7 @@
{
getNexusProxy().modify( buildTarget( name ), mods );
}
-
+
/**
* @see javax.naming.directory.DirContext#bind(java.lang.String,
@@ -341,7 +340,7 @@
Attributes attributes = ( Attributes ) attrs.clone();
boolean doRdnPut = attributes.get( rdnAttribute ) == null;
doRdnPut = doRdnPut || attributes.get( rdnAttribute ).size() == 0;
- doRdnPut = doRdnPut || ! attributes.get( rdnAttribute ).contains( rdnValue );
+ doRdnPut = doRdnPut || !attributes.get( rdnAttribute ).contains( rdnValue );
if ( doRdnPut )
{
@@ -396,13 +395,11 @@
// Search Operation Implementations
// ------------------------------------------------------------------------
-
/**
* @see javax.naming.directory.DirContext#search(java.lang.String,
* javax.naming.directory.Attributes)
*/
- public NamingEnumeration search( String name, Attributes matchingAttributes )
- throws NamingException
+ public NamingEnumeration search( String name, Attributes matchingAttributes ) throws NamingException
{
return search( new LdapName( name ), matchingAttributes, null );
}
@@ -412,8 +409,7 @@
* @see javax.naming.directory.DirContext#search(javax.naming.Name,
* javax.naming.directory.Attributes)
*/
- public NamingEnumeration search( Name name, Attributes matchingAttributes )
- throws NamingException
+ public NamingEnumeration search( Name name, Attributes matchingAttributes ) throws NamingException
{
return search( name, matchingAttributes, null );
}
@@ -423,7 +419,8 @@
* @see javax.naming.directory.DirContext#search(java.lang.String,
* javax.naming.directory.Attributes, java.lang.String[])
*/
- public NamingEnumeration search( String name, Attributes matchingAttributes, String[] attributesToReturn ) throws NamingException
+ public NamingEnumeration search( String name, Attributes matchingAttributes, String[] attributesToReturn )
+ throws NamingException
{
return search( new LdapName( name ), matchingAttributes, attributesToReturn );
}
@@ -433,7 +430,8 @@
* @see javax.naming.directory.DirContext#search(javax.naming.Name,
* javax.naming.directory.Attributes, java.lang.String[])
*/
- public NamingEnumeration search( Name name, Attributes matchingAttributes, String[] attributesToReturn ) throws NamingException
+ public NamingEnumeration search( Name name, Attributes matchingAttributes, String[] attributesToReturn )
+ throws NamingException
{
SearchControls ctls = new SearchControls();
Name target = buildTarget( name );
@@ -442,13 +440,13 @@
if ( null != attributesToReturn )
{
ctls.setReturningAttributes( attributesToReturn );
- }
+ }
// If matchingAttributes is null/empty use a match for everything filter
if ( null == matchingAttributes || matchingAttributes.size() <= 0 )
{
PresenceNode filter = new PresenceNode( "objectClass" );
- return getNexusProxy().search( target , getEnvironment(), filter, ctls );
+ return getNexusProxy().search( target, getEnvironment(), filter, ctls );
}
/*
@@ -464,7 +462,7 @@
while ( list.hasMore() )
{
attr = ( Attribute ) list.next();
-
+
/*
* According to JNDI if an attribute in the matchingAttributes
* list does not have any values then we match for just the presence
@@ -475,7 +473,7 @@
filter.addNode( new PresenceNode( attr.getID() ) );
continue;
}
-
+
/*
* With 1 or more value we build a set of simple nodes and add them
* to the AND node - each attribute value pair is a simple AVA node.
@@ -483,7 +481,7 @@
for ( int ii = 0; ii < attr.size(); ii++ )
{
Object val = attr.get( ii );
-
+
// Add simpel AVA node if its value is a String
if ( val instanceof String )
{
@@ -493,7 +491,7 @@
}
}
- return getNexusProxy().search( target , getEnvironment(), filter, ctls );
+ return getNexusProxy().search( target, getEnvironment(), filter, ctls );
}
@@ -501,8 +499,7 @@
* @see javax.naming.directory.DirContext#search(java.lang.String,
* java.lang.String, javax.naming.directory.SearchControls)
*/
- public NamingEnumeration search( String name, String filter, SearchControls cons )
- throws NamingException
+ public NamingEnumeration search( String name, String filter, SearchControls cons ) throws NamingException
{
return search( new LdapName( name ), filter, cons );
}
@@ -522,8 +519,8 @@
public NamingEnumeration search( Name name, ExprNode filter, SearchControls cons ) throws NamingException
{
/*Name newName = new LdapDN( name.toString() );
- newName = LdapDN.oidToName( newName, DnOidContainer.getOids() );
- Name target = buildTarget( ((LdapDN)newName).toLdapName() );*/
+ newName = LdapDN.oidToName( newName, DnOidContainer.getOids() );
+ Name target = buildTarget( ((LdapDN)newName).toLdapName() );*/
Name target = buildTarget( name );
return getNexusProxy().search( target, getEnvironment(), filter, cons );
@@ -534,8 +531,7 @@
* @see javax.naming.directory.DirContext#search(javax.naming.Name,
* java.lang.String, javax.naming.directory.SearchControls)
*/
- public NamingEnumeration search( Name name, String filter, SearchControls cons )
- throws NamingException
+ public NamingEnumeration search( Name name, String filter, SearchControls cons ) throws NamingException
{
ExprNode filterNode;
Name target = buildTarget( name );
@@ -546,23 +542,19 @@
}
catch ( ParseException pe )
{
- InvalidSearchFilterException isfe =
- new InvalidSearchFilterException (
- "Encountered parse exception while parsing the filter: '"
- + filter + "'" );
+ InvalidSearchFilterException isfe = new InvalidSearchFilterException(
+ "Encountered parse exception while parsing the filter: '" + filter + "'" );
isfe.setRootCause( pe );
throw isfe;
}
catch ( IOException ioe )
{
- NamingException ne = new NamingException(
- "Parser failed with IO exception on filter: '"
- + filter + "'" );
+ NamingException ne = new NamingException( "Parser failed with IO exception on filter: '" + filter + "'" );
ne.setRootCause( ioe );
throw ne;
}
- return getNexusProxy().search( target , getEnvironment(), filterNode, cons );
+ return getNexusProxy().search( target, getEnvironment(), filterNode, cons );
}
@@ -571,8 +563,8 @@
* java.lang.String, java.lang.Object[],
* javax.naming.directory.SearchControls)
*/
- public NamingEnumeration search( String name, String filterExpr,
- Object[] filterArgs, SearchControls cons ) throws NamingException
+ public NamingEnumeration search( String name, String filterExpr, Object[] filterArgs, SearchControls cons )
+ throws NamingException
{
return search( new LdapName( name ), filterExpr, filterArgs, cons );
}
@@ -583,13 +575,14 @@
* java.lang.String, java.lang.Object[],
* javax.naming.directory.SearchControls)
*/
- public NamingEnumeration search( Name name, String filterExpr, Object[] filterArgs, SearchControls cons ) throws NamingException
+ public NamingEnumeration search( Name name, String filterExpr, Object[] filterArgs, SearchControls cons )
+ throws NamingException
{
int start;
int index;
StringBuffer buf = new StringBuffer( filterExpr );
-
+
// Scan until we hit the end of the string buffer
for ( int ii = 0; ii < buf.length(); ii++ )
{
@@ -600,46 +593,44 @@
{
ii++;
}
-
+
// Record start of variable at '{'
start = ii;
-
+
// Advance to the end of a variable at '}'
while ( '}' != buf.charAt( ii ) )
{
ii++;
}
}
- catch (IndexOutOfBoundsException e)
+ catch ( IndexOutOfBoundsException e )
{
// End of filter so done.
break;
}
-
+
// Parse index
- index = Integer.parseInt(buf.substring(start + 1, ii));
-
+ index = Integer.parseInt( buf.substring( start + 1, ii ) );
+
/*
* Replace the '{ i }' with the string representation of the value
* held in the filterArgs array at index index.
- */
+ */
buf.replace( start, ii + 1, filterArgs[index].toString() );
}
-
+
return search( name, buf.toString(), cons );
}
-
// ------------------------------------------------------------------------
// EventDirContext implementations
// ------------------------------------------------------------------------
-
FilterParserImpl filterParser = new FilterParserImpl();
+
public void addNamingListener( Name name, String filterStr, SearchControls searchControls,
- NamingListener namingListener )
- throws NamingException
+ NamingListener namingListener ) throws NamingException
{
ExprNode filter;
@@ -654,21 +645,21 @@
throw e2;
}
- ( ( DirectoryPartitionNexusProxy ) getNexusProxy() )
- .addNamingListener( this, buildTarget( name ), filter, searchControls, namingListener );
+ ( ( DirectoryPartitionNexusProxy ) getNexusProxy() ).addNamingListener( this, buildTarget( name ), filter,
+ searchControls, namingListener );
getListeners().add( namingListener );
}
- public void addNamingListener( String name, String filter, SearchControls searchControls, NamingListener namingListener )
- throws NamingException
+ public void addNamingListener( String name, String filter, SearchControls searchControls,
+ NamingListener namingListener ) throws NamingException
{
addNamingListener( new LdapName( name ), filter, searchControls, namingListener );
}
public void addNamingListener( Name name, String filterExpr, Object[] filterArgs, SearchControls searchControls,
- NamingListener namingListener ) throws NamingException
+ NamingListener namingListener ) throws NamingException
{
int start;
StringBuffer buf = new StringBuffer( filterExpr );
@@ -690,7 +681,7 @@
{
ii++;
}
-
+
/*
* Replace the '{ i }' with the string representation of the value
* held in the filterArgs array at index index.
@@ -703,7 +694,7 @@
public void addNamingListener( String name, String filter, Object[] objects, SearchControls searchControls,
- NamingListener namingListener ) throws NamingException
+ NamingListener namingListener ) throws NamingException
{
addNamingListener( new LdapName( name ), filter, objects, searchControls, namingListener );
}
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirObjectFactory.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirObjectFactory.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirObjectFactory.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirObjectFactory.java Fri Feb 10 02:48:07 2006
@@ -58,6 +58,7 @@
*/
String getObjectClassId();
+
/**
* Gets the Class instance associated with this ObjectFactory. Objects to
* be created by this ObjectFactory will be of this type, a subclass of
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirStateFactory.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirStateFactory.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirStateFactory.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerDirStateFactory.java Fri Feb 10 02:48:07 2006
@@ -52,6 +52,7 @@
*/
String getObjectClassId();
+
/**
* Gets the Class instance associated with this StateFactory. Objects to
* be persisted by this StateFactory must be of this type, a subclass of
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java Fri Feb 10 02:48:07 2006
@@ -56,7 +56,7 @@
* @param env the JNDI environment parameters
* @throws NamingException the context cannot be created
*/
- public ServerLdapContext( DirectoryService service, Hashtable env ) throws NamingException
+ public ServerLdapContext(DirectoryService service, Hashtable env) throws NamingException
{
super( service, env );
}
@@ -71,7 +71,7 @@
* @param env the environment properties used by this context
* @param dn the distinguished name of this context
*/
- ServerLdapContext( DirectoryService service, LdapPrincipal principal, Name dn ) throws NamingException
+ ServerLdapContext(DirectoryService service, LdapPrincipal principal, Name dn) throws NamingException
{
super( service, principal, dn );
}
@@ -91,8 +91,7 @@
* @see javax.naming.ldap.LdapContext#newInstance(
* javax.naming.ldap.Control[])
*/
- public LdapContext newInstance( Control[] requestControls )
- throws NamingException
+ public LdapContext newInstance( Control[] requestControls ) throws NamingException
{
ServerLdapContext ctx = new ServerLdapContext( getService(), getPrincipal(), getDn() );
ctx.setRequestControls( requestControls );
@@ -150,7 +149,6 @@
// Additional ApacheDS Specific JNDI Functionality
// ------------------------------------------------------------------------
-
/**
* Explicitly exposes an LDAP compare operation which JNDI does not
* directly provide. All normalization and schema checking etcetera
@@ -166,10 +164,10 @@
*/
public boolean compare( Name name, String oid, Object value ) throws NamingException
{
- return super.getNexusProxy().compare( name, oid, value );
+ return super.getNexusProxy().compare( name, oid, value );
}
-
-
+
+
/**
* Calling this method tunnels an unbind call down into the partition holding
* the bindDn. The bind() counter part is not exposed because it is automatically
@@ -183,17 +181,18 @@
String bindDn = ( String ) getEnvironment().get( Context.SECURITY_PRINCIPAL );
super.getNexusProxy().unbind( new LdapName( bindDn ) );
}
-
-
+
private transient ReferralService refService;
+
+
public boolean isReferral( String name ) throws NamingException
{
if ( refService == null )
{
- refService = ( ReferralService ) getService().getConfiguration().getInterceptorChain().
- get( ReferralService.NAME );
+ refService = ( ReferralService ) getService().getConfiguration().getInterceptorChain().get(
+ ReferralService.NAME );
}
-
+
return refService.isReferral( name );
}
}
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java Fri Feb 10 02:48:07 2006
@@ -73,15 +73,17 @@
}
- public void destroy() {}
+ public void destroy()
+ {
+ }
// ------------------------------------------------------------------------
// Normalize all Name based arguments for ContextPartition interface operations
// ------------------------------------------------------------------------
-
- public void add( NextInterceptor nextInterceptor, String upName, Name normName, Attributes attrs ) throws NamingException
+ public void add( NextInterceptor nextInterceptor, String upName, Name normName, Attributes attrs )
+ throws NamingException
{
normName = parser.parse( normName.toString() );
nextInterceptor.add( upName, normName, attrs );
@@ -95,7 +97,8 @@
}
- public void modify( NextInterceptor nextInterceptor, Name name, int modOp, Attributes attrs ) throws NamingException
+ public void modify( NextInterceptor nextInterceptor, Name name, int modOp, Attributes attrs )
+ throws NamingException
{
name = parser.parse( name.toString() );
nextInterceptor.modify( name, modOp, attrs );
@@ -109,7 +112,8 @@
}
- public void modifyRn( NextInterceptor nextInterceptor, Name name, String newRn, boolean deleteOldRn ) throws NamingException
+ public void modifyRn( NextInterceptor nextInterceptor, Name name, String newRn, boolean deleteOldRn )
+ throws NamingException
{
name = parser.parse( name.toString() );
nextInterceptor.modifyRn( name, newRn, deleteOldRn );
@@ -124,7 +128,8 @@
}
- public void move( NextInterceptor nextInterceptor, Name name, Name newParentName, String newRn, boolean deleteOldRn ) throws NamingException
+ public void move( NextInterceptor nextInterceptor, Name name, Name newParentName, String newRn, boolean deleteOldRn )
+ throws NamingException
{
name = parser.parse( name.toString() );
newParentName = parser.parse( newParentName.toString() );
@@ -132,16 +137,15 @@
}
- public NamingEnumeration search( NextInterceptor nextInterceptor,
- Name base, Map env, ExprNode filter,
- SearchControls searchCtls ) throws NamingException
+ public NamingEnumeration search( NextInterceptor nextInterceptor, Name base, Map env, ExprNode filter,
+ SearchControls searchCtls ) throws NamingException
{
base = parser.parse( base.toString() );
if ( filter.isLeaf() )
{
LeafNode ln = ( LeafNode ) filter;
- if ( ! registry.hasAttributeType( ln.getAttribute() ) )
+ if ( !registry.hasAttributeType( ln.getAttribute() ) )
{
StringBuffer buf = new StringBuffer();
buf.append( "undefined filter based on undefined attributeType '" );
@@ -155,14 +159,15 @@
filter.accept( visitor );
// check that after pruning we have valid branch node at the top
- if ( ! filter.isLeaf() )
+ if ( !filter.isLeaf() )
{
BranchNode child = ( BranchNode ) filter;
// if the remaining filter branch node has no children return an empty enumeration
if ( child.getChildren().size() == 0 )
{
- log.warn( "Undefined branchnode filter without child nodes not evaluted at all. Returning empty enumeration." );
+ log
+ .warn( "Undefined branchnode filter without child nodes not evaluted at all. Returning empty enumeration." );
return new EmptyEnumeration();
}
@@ -215,7 +220,6 @@
// Normalize all Name based arguments for other interface operations
// ------------------------------------------------------------------------
-
public Name getMatchedName( NextInterceptor nextInterceptor, Name name, boolean normalized ) throws NamingException
{
name = parser.parse( name.toString() );
@@ -236,7 +240,6 @@
return next.compare( name, oid, value );
}
-
/**
* A normalizer that normalizes each name component specifically according to
* the attribute type of the name component.
@@ -249,6 +252,7 @@
return ( String ) type.getEquality().getNormalizer().normalize( value );
}
+
public String normalizeByName( String name, byte[] value ) throws NamingException
{
AttributeType type = registry.lookup( name );
@@ -262,6 +266,7 @@
AttributeType type = registry.lookup( oid );
return ( String ) type.getEquality().getNormalizer().normalize( value );
}
+
public boolean isDefined( String id )
{
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/normalization/ValueNormalizingVisitor.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/normalization/ValueNormalizingVisitor.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/normalization/ValueNormalizingVisitor.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/normalization/ValueNormalizingVisitor.java Fri Feb 10 02:48:07 2006
@@ -55,7 +55,7 @@
private final NameComponentNormalizer ncn;
- public ValueNormalizingVisitor( NameComponentNormalizer ncn )
+ public ValueNormalizingVisitor(NameComponentNormalizer ncn)
{
this.ncn = ncn;
}
@@ -72,7 +72,7 @@
{
// still need this check here in case the top level is a leaf node
// with an undefined attributeType for its attribute
- if ( ! ncn.isDefined( snode.getAttribute() ) )
+ if ( !ncn.isDefined( snode.getAttribute() ) )
{
normalized = snode.getValue();
}
@@ -99,7 +99,7 @@
{
BranchNode bnode = ( BranchNode ) node;
StringBuffer buf = null;
- for ( int ii = 0; ii < bnode.getChildren().size() ; ii++ )
+ for ( int ii = 0; ii < bnode.getChildren().size(); ii++ )
{
// before visiting each node let's check to make sure non-branch children use
// attributes that are defined in the system, if undefined nodes are removed
@@ -107,7 +107,7 @@
if ( child.isLeaf() )
{
LeafNode ln = ( LeafNode ) child;
- if ( ! ncn.isDefined( ln.getAttribute() ) )
+ if ( !ncn.isDefined( ln.getAttribute() ) )
{
if ( buf == null )
{
@@ -136,7 +136,7 @@
// AND/OR with one or less children) and repair them by removing branch
// nodes without children and replacing branch nodes like AND/OR with
// their single child if other branch nodes do not remain.
- for ( int ii = 0; ii < bnode.getChildren().size() ; ii++ )
+ for ( int ii = 0; ii < bnode.getChildren().size(); ii++ )
{
ExprNode unknown = ( ExprNode ) bnode.getChildren().get( ii );
if ( !unknown.isLeaf() )
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeService.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeService.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeService.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeService.java Fri Feb 10 02:48:07 2006
@@ -65,7 +65,7 @@
private final SearchResultFilter SEARCH_FILTER = new SearchResultFilter()
{
public boolean accept( Invocation invocation, SearchResult result, SearchControls controls )
- throws NamingException
+ throws NamingException
{
if ( controls.getReturningAttributes() == null )
{
@@ -107,7 +107,8 @@
/**
* Adds extra operational attributes to the entry before it is added.
*/
- public void add( NextInterceptor nextInterceptor, String upName, Name normName, Attributes entry ) throws NamingException
+ public void add( NextInterceptor nextInterceptor, String upName, Name normName, Attributes entry )
+ throws NamingException
{
String principal = getPrincipal().getName();
@@ -123,10 +124,11 @@
}
- public void modify( NextInterceptor nextInterceptor, Name name, int modOp, Attributes attrs) throws NamingException
+ public void modify( NextInterceptor nextInterceptor, Name name, int modOp, Attributes attrs )
+ throws NamingException
{
nextInterceptor.modify( name, modOp, attrs );
-
+
// add operational attributes after call in case the operation fails
Attributes attributes = new BasicAttributes( true );
BasicAttribute attribute = new BasicAttribute( "modifiersName" );
@@ -159,10 +161,11 @@
}
- public void modifyRn( NextInterceptor nextInterceptor, Name name, String newRn, boolean deleteOldRn ) throws NamingException
+ public void modifyRn( NextInterceptor nextInterceptor, Name name, String newRn, boolean deleteOldRn )
+ throws NamingException
{
nextInterceptor.modifyRn( name, newRn, deleteOldRn );
-
+
// add operational attributes after call in case the operation fails
Attributes attributes = new BasicAttributes( true );
BasicAttribute attribute = new BasicAttribute( "modifiersName" );
@@ -196,7 +199,8 @@
}
- public void move( NextInterceptor nextInterceptor, Name name, Name newParentName, String newRn, boolean deleteOldRn ) throws NamingException
+ public void move( NextInterceptor nextInterceptor, Name name, Name newParentName, String newRn, boolean deleteOldRn )
+ throws NamingException
{
nextInterceptor.move( name, newParentName, newRn, deleteOldRn );
@@ -247,9 +251,8 @@
}
- public NamingEnumeration search( NextInterceptor nextInterceptor,
- Name base, Map env, ExprNode filter,
- SearchControls searchCtls ) throws NamingException
+ public NamingEnumeration search( NextInterceptor nextInterceptor, Name base, Map env, ExprNode filter,
+ SearchControls searchCtls ) throws NamingException
{
Invocation invocation = InvocationStack.getInstance().peek();
NamingEnumeration e = nextInterceptor.search( base, env, filter, searchCtls );
@@ -293,8 +296,7 @@
}
- private void filter( Name dn, Attributes entry, String[] ids )
- throws NamingException
+ private void filter( Name dn, Attributes entry, String[] ids ) throws NamingException
{
// still need to protect against returning op attrs when ids is null
if ( ids == null )
@@ -324,7 +326,7 @@
}
}
}
-
+
// do nothing past here since this explicity specifies which
// attributes to include - backends will automatically populate
// with right set of attributes using ids array
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/AbstractDirectoryPartition.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/AbstractDirectoryPartition.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/AbstractDirectoryPartition.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/AbstractDirectoryPartition.java Fri Feb 10 02:48:07 2006
@@ -16,6 +16,7 @@
*/
package org.apache.directory.server.core.partition;
+
import java.util.ArrayList;
import java.util.List;
@@ -32,6 +33,7 @@
import org.apache.directory.server.core.configuration.DirectoryPartitionConfiguration;
import org.apache.directory.shared.ldap.name.LdapName;
+
/**
* A {@link DirectoryPartition} that helps users to implement their own partition.
* Most methods are implemented by default. Please look at the description of
@@ -48,11 +50,13 @@
private DirectoryPartitionConfiguration cfg;
/** <tt>true</tt> if and only if this partition is initialized. */
private boolean initialized;
-
+
+
protected AbstractDirectoryPartition()
{
}
+
/**
* Sets up default properties(<tt>factoryConfiguration</tt> and <tt>configuration</tt>) and
* calls {@link #doInit()} where you have to put your initialization code in.
@@ -60,9 +64,10 @@
* without any errors. {@link #destroy()} is called automatically as a clean-up process
* if {@link #doInit()} throws an exception.
*/
- public final void init( DirectoryServiceConfiguration factoryCfg, DirectoryPartitionConfiguration cfg ) throws NamingException
+ public final void init( DirectoryServiceConfiguration factoryCfg, DirectoryPartitionConfiguration cfg )
+ throws NamingException
{
- if( initialized )
+ if ( initialized )
{
// Already initialized.
return;
@@ -70,26 +75,29 @@
this.factoryCfg = factoryCfg;
this.cfg = cfg;
- try{
+ try
+ {
doInit();
initialized = true;
}
finally
{
- if( !initialized )
+ if ( !initialized )
{
destroy();
}
}
}
+
/**
* Override this method to put your initialization code.
*/
protected void doInit() throws NamingException
{
}
-
+
+
/**
* Calls {@link #doDestroy()} where you have to put your destroy code in,
* and clears default properties. Once this method is invoked, {@link #isInitialized()}
@@ -97,7 +105,7 @@
*/
public final void destroy()
{
- if( cfg == null )
+ if ( cfg == null )
{
// Already destroyed.
return;
@@ -115,6 +123,7 @@
}
}
+
/**
* Override this method to put your initialization code.
*/
@@ -122,6 +131,7 @@
{
}
+
/**
* Returns <tt>true</tt> if this context partition is initialized successfully.
*/
@@ -130,6 +140,7 @@
return initialized;
}
+
/**
* Returns {@link DirectoryServiceConfiguration} that is provided from
* {@link #init(DirectoryServiceConfiguration, DirectoryPartitionConfiguration)}.
@@ -138,7 +149,8 @@
{
return factoryCfg;
}
-
+
+
/**
* Returns {@link DirectoryPartitionConfiguration} that is provided from
* {@link #init(DirectoryServiceConfiguration, DirectoryPartitionConfiguration)}.
@@ -148,12 +160,13 @@
return cfg;
}
+
public final Name getSuffix( boolean normalized ) throws NamingException
{
- if( normalized )
+ if ( normalized )
{
return getConfiguration().getNormalizedSuffix(
- getFactoryConfiguration().getGlobalRegistries().getMatchingRuleRegistry() );
+ getFactoryConfiguration().getGlobalRegistries().getMatchingRuleRegistry() );
}
else
{
@@ -161,18 +174,21 @@
}
}
+
public final boolean isSuffix( Name name ) throws NamingException
{
return getSuffix( true ).equals( name ) || getSuffix( false ).equals( name );
}
+
/**
* This method does nothing by default.
*/
public void sync() throws NamingException
{
}
-
+
+
/**
* This method calls {@link #lookup(Name)} and return <tt>true</tt>
* if it returns an entry by default. Please override this method if
@@ -184,12 +200,13 @@
{
return lookup( name ) != null;
}
- catch( NameNotFoundException e )
+ catch ( NameNotFoundException e )
{
return false;
}
}
+
/**
* This method calls {@link DirectoryPartition#lookup(Name, String[])}
* with null <tt>attributeIds</tt> by default. Please override
@@ -200,6 +217,7 @@
return lookup( name, null );
}
+
/**
* This method forwards the request to
* {@link DirectoryPartition#modify(Name, ModificationItem[])} after
@@ -211,16 +229,17 @@
{
List items = new ArrayList( mods.size() );
NamingEnumeration e = mods.getAll();
- while( e.hasMore() )
+ while ( e.hasMore() )
{
items.add( new ModificationItem( modOp, ( Attribute ) e.next() ) );
}
-
- ModificationItem[] itemsArray = new ModificationItem[ items.size() ];
+
+ ModificationItem[] itemsArray = new ModificationItem[items.size()];
itemsArray = ( ModificationItem[] ) items.toArray( itemsArray );
modify( name, itemsArray );
}
+
/**
* This method calls {@link DirectoryPartition#move(Name, Name)} and
* {@link DirectoryPartition#modifyRn(Name, String, boolean)} subsequently
@@ -234,6 +253,7 @@
move( oldName, newParentName );
modifyRn( newName, newRn, deleteOldRn );
}
+
/**
* This method throws {@link OperationNotSupportedException} by default.
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/DefaultDirectoryPartitionNexus.java Fri Feb 10 02:48:07 2006
@@ -71,7 +71,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
+
/**
* A nexus for partitions dedicated for storing entries specific to a naming
* context.
@@ -118,7 +118,7 @@
*
* @see <a href="http://www.faqs.org/rfcs/rfc3045.html">Vendor Information</a>
*/
- public DefaultDirectoryPartitionNexus( Attributes rootDSE )
+ public DefaultDirectoryPartitionNexus(Attributes rootDSE)
{
// setup that root DSE
this.rootDSE = rootDSE;
@@ -166,30 +166,31 @@
{
log.error( "failed to log version properties" );
}
-
+
attr = new LockableAttributeImpl( VENDORVERSION_ATTR );
attr.add( props.getProperty( "apacheds.version", "UNKNOWN" ) );
rootDSE.put( attr );
}
- public void init( DirectoryServiceConfiguration factoryCfg, DirectoryPartitionConfiguration cfg ) throws NamingException
+ public void init( DirectoryServiceConfiguration factoryCfg, DirectoryPartitionConfiguration cfg )
+ throws NamingException
{
// NOTE: We ignore ContextPartitionConfiguration parameter here.
- if( initialized )
+ if ( initialized )
{
return;
}
-
+
this.factoryCfg = factoryCfg;
-
+
List initializedPartitionCfgs = new ArrayList();
initializedPartitionCfgs.add( initializeSystemPartition() );
-
+
Iterator i = factoryCfg.getStartupConfiguration().getContextPartitionConfigurations().iterator();
try
{
- while( i.hasNext() )
+ while ( i.hasNext() )
{
DirectoryPartitionConfiguration c = ( DirectoryPartitionConfiguration ) i.next();
addContextPartition( c );
@@ -199,24 +200,21 @@
}
finally
{
- if( !initialized )
+ if ( !initialized )
{
i = initializedPartitionCfgs.iterator();
- while( i.hasNext() )
+ while ( i.hasNext() )
{
- DirectoryPartitionConfiguration partitionCfg =
- ( DirectoryPartitionConfiguration ) i.next();
+ DirectoryPartitionConfiguration partitionCfg = ( DirectoryPartitionConfiguration ) i.next();
DirectoryPartition partition = partitionCfg.getContextPartition();
i.remove();
try
{
partition.destroy();
}
- catch( Exception e )
+ catch ( Exception e )
{
- log.warn(
- "Failed to destroy a partition: " +
- partitionCfg.getSuffix(), e );
+ log.warn( "Failed to destroy a partition: " + partitionCfg.getSuffix(), e );
}
finally
{
@@ -236,7 +234,7 @@
systemCfg.setName( "system" );
systemCfg.setSuffix( DirectoryPartitionNexus.SYSTEM_PARTITION_SUFFIX );
systemCfg.setContextPartition( system );
-
+
// Add indexed attributes for system partition
Set indexedSystemAttrs = new HashSet();
indexedSystemAttrs.add( Oid.ALIAS );
@@ -247,31 +245,30 @@
indexedSystemAttrs.add( Oid.SUBALIAS );
indexedSystemAttrs.add( Oid.UPDN );
systemCfg.setIndexedAttributes( indexedSystemAttrs );
-
+
// Add context entry for system partition
Attributes systemEntry = new LockableAttributesImpl();
Attribute objectClassAttr = new LockableAttributeImpl( "objectClass" );
objectClassAttr.add( "top" );
objectClassAttr.add( "organizationalUnit" );
systemEntry.put( objectClassAttr );
- systemEntry.put( "creatorsName", DirectoryPartitionNexus.ADMIN_PRINCIPAL ) ;
- systemEntry.put( "createTimestamp", DateUtils.getGeneralizedTime() ) ;
- systemEntry.put(
- NamespaceTools.getRdnAttribute( DirectoryPartitionNexus.SYSTEM_PARTITION_SUFFIX ),
- NamespaceTools.getRdnValue( DirectoryPartitionNexus.SYSTEM_PARTITION_SUFFIX ) ) ;
+ systemEntry.put( "creatorsName", DirectoryPartitionNexus.ADMIN_PRINCIPAL );
+ systemEntry.put( "createTimestamp", DateUtils.getGeneralizedTime() );
+ systemEntry.put( NamespaceTools.getRdnAttribute( DirectoryPartitionNexus.SYSTEM_PARTITION_SUFFIX ),
+ NamespaceTools.getRdnValue( DirectoryPartitionNexus.SYSTEM_PARTITION_SUFFIX ) );
systemCfg.setContextEntry( systemEntry );
system.init( factoryCfg, systemCfg );
String key = system.getSuffix( true ).toString();
- if( partitions.containsKey( key ) )
+ if ( partitions.containsKey( key ) )
{
throw new ConfigurationException( "Duplicate partition suffix: " + key );
}
partitions.put( key, system );
-
+
Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR );
namingContexts.add( system.getSuffix( false ).toString() );
-
+
return systemCfg;
}
@@ -295,7 +292,7 @@
// have an attempt at closing down and synching their cached entries
while ( suffixes.hasNext() )
{
- String suffix = (String) suffixes.next();
+ String suffix = ( String ) suffixes.next();
try
{
removeContextPartition( new LdapName( suffix ) );
@@ -351,14 +348,13 @@
// ContextPartitionNexus Method Implementations
// ------------------------------------------------------------------------
-
public boolean compare( Name name, String oid, Object value ) throws NamingException
{
DirectoryPartition partition = getBackend( name );
AttributeTypeRegistry registry = factoryCfg.getGlobalRegistries().getAttributeTypeRegistry();
// complain if we do not recognize the attribute being compared
- if ( ! registry.hasAttributeType( oid ) )
+ if ( !registry.hasAttributeType( oid ) )
{
throw new LdapInvalidAttributeIdentifierException( oid + " not found within the attributeType registry" );
}
@@ -387,30 +383,30 @@
*/
Normalizer normalizer = attrType.getEquality().getNormalizer();
Object reqVal = normalizer.normalize( value );
-
+
for ( int ii = 0; ii < attr.size(); ii++ )
{
- Object attrValObj = normalizer.normalize( attr.get( ii ) );
- if ( attrValObj instanceof String )
- {
- String attrVal = ( String ) attrValObj;
- if ( ( reqVal instanceof String) && attrVal.equals( reqVal ) )
- {
- return true;
- }
- }
- else
- {
- byte[] attrVal = (byte[])attrValObj;
- if ( reqVal instanceof byte[] )
- {
- return Arrays.equals( attrVal, (byte[])reqVal );
- }
- else if ( reqVal instanceof String )
- {
- return Arrays.equals( attrVal, StringTools.getBytesUtf8( (String)reqVal ) );
- }
- }
+ Object attrValObj = normalizer.normalize( attr.get( ii ) );
+ if ( attrValObj instanceof String )
+ {
+ String attrVal = ( String ) attrValObj;
+ if ( ( reqVal instanceof String ) && attrVal.equals( reqVal ) )
+ {
+ return true;
+ }
+ }
+ else
+ {
+ byte[] attrVal = ( byte[] ) attrValObj;
+ if ( reqVal instanceof byte[] )
+ {
+ return Arrays.equals( attrVal, ( byte[] ) reqVal );
+ }
+ else if ( reqVal instanceof String )
+ {
+ return Arrays.equals( attrVal, StringTools.getBytesUtf8( ( String ) reqVal ) );
+ }
+ }
}
return false;
@@ -423,14 +419,14 @@
// Turn on default indices
String key = config.getSuffix();
- if( partitions.containsKey( key ) )
+ if ( partitions.containsKey( key ) )
{
throw new ConfigurationException( "Duplicate partition suffix: " + key );
}
partition.init( factoryCfg, config );
partitions.put( partition.getSuffix( true ).toString(), partition );
-
+
Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR );
namingContexts.add( partition.getSuffix( false ).toString() );
}
@@ -439,12 +435,12 @@
public synchronized void removeContextPartition( Name suffix ) throws NamingException
{
String key = suffix.toString();
- DirectoryPartition partition = (DirectoryPartition) partitions.get( key );
- if( partition == null )
+ DirectoryPartition partition = ( DirectoryPartition ) partitions.get( key );
+ if ( partition == null )
{
throw new NameNotFoundException( "No partition with suffix: " + key );
}
-
+
Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR );
namingContexts.remove( partition.getSuffix( false ).toString() );
partitions.remove( key );
@@ -452,16 +448,18 @@
partition.sync();
partition.destroy();
}
-
+
+
public DirectoryPartition getSystemPartition()
{
return system;
}
+
/**
* @see DirectoryPartitionNexus#getLdapContext()
*/
- public LdapContext getLdapContext()
+ public LdapContext getLdapContext()
{
throw new NotImplementedException();
}
@@ -512,7 +510,7 @@
}
- public Attributes getRootDSE()
+ public Attributes getRootDSE()
{
return rootDSE;
}
@@ -541,8 +539,7 @@
// ------------------------------------------------------------------------
// DirectoryPartition Interface Method Implementations
// ------------------------------------------------------------------------
-
-
+
public void bind( Name bindDn, byte[] credentials, List mechanisms, String saslAuthId ) throws NamingException
{
DirectoryPartition partition = getBackend( bindDn );
@@ -556,7 +553,7 @@
partition.unbind( bindDn );
}
-
+
/**
* @see DirectoryPartition#delete(javax.naming.Name)
*/
@@ -603,7 +600,7 @@
backend.modify( dn, mods );
}
-
+
/**
* @see DirectoryPartition#list(javax.naming.Name)
*/
@@ -612,13 +609,13 @@
DirectoryPartition backend = getBackend( base );
return backend.list( base );
}
-
+
/**
* @see DirectoryPartition#search(Name, Map, ExprNode, SearchControls)
*/
public NamingEnumeration search( Name base, Map env, ExprNode filter, SearchControls searchCtls )
- throws NamingException
+ throws NamingException
{
if ( base.size() == 0 )
@@ -675,7 +672,7 @@
/**
* @see DirectoryPartition#lookup(javax.naming.Name)
*/
- public Attributes lookup( Name dn ) throws NamingException
+ public Attributes lookup( Name dn ) throws NamingException
{
if ( dn.size() == 0 )
{
@@ -690,7 +687,7 @@
/**
* @see org.apache.directory.server.core.partition.DirectoryPartition#lookup(javax.naming.Name, String[])
*/
- public Attributes lookup( Name dn, String[] attrIds ) throws NamingException
+ public Attributes lookup( Name dn, String[] attrIds ) throws NamingException
{
if ( dn.size() == 0 )
{
@@ -719,7 +716,7 @@
{
log.debug( "Check if DN '" + dn + "' exists." );
}
-
+
if ( dn.size() == 0 )
{
return true;
@@ -729,7 +726,7 @@
return backend.hasEntry( dn );
}
-
+
/**
* @see DirectoryPartition#isSuffix(javax.naming.Name)
*/
@@ -738,7 +735,7 @@
return partitions.containsKey( dn.toString() );
}
-
+
/**
* @see DirectoryPartition#modifyRn(Name, String, boolean)
*/
@@ -747,8 +744,8 @@
DirectoryPartition backend = getBackend( dn );
backend.modifyRn( dn, newRdn, deleteOldRdn );
}
-
-
+
+
/**
* @see DirectoryPartition#move(Name, Name)
*/
@@ -757,25 +754,23 @@
DirectoryPartition backend = getBackend( oriChildName );
backend.move( oriChildName, newParentName );
}
-
-
+
+
/**
* @see DirectoryPartition#move(javax.naming.Name,
* javax.naming.Name, java.lang.String, boolean)
*/
- public void move( Name oldChildDn, Name newParentDn, String newRdn,
- boolean deleteOldRdn ) throws NamingException
+ public void move( Name oldChildDn, Name newParentDn, String newRdn, boolean deleteOldRdn ) throws NamingException
{
DirectoryPartition backend = getBackend( oldChildDn );
backend.move( oldChildDn, newParentDn, newRdn, deleteOldRdn );
}
-
+
// ------------------------------------------------------------------------
// Private Methods
// ------------------------------------------------------------------------
-
/**
* Gets the backend partition associated with a normalized dn.
*
@@ -792,7 +787,7 @@
{
return ( DirectoryPartition ) partitions.get( clonedDn.toString() );
}
-
+
clonedDn.remove( clonedDn.size() - 1 );
}
throw new NameNotFoundException( dn.toString() );
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/DirectoryPartition.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/DirectoryPartition.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/DirectoryPartition.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/DirectoryPartition.java Fri Feb 10 02:48:07 2006
@@ -53,31 +53,34 @@
/**
* The aliased Dn attribute name: aliasedObjectName for LDAP and
* aliasedEntryName or X.500.
- */
+ */
String ALIAS_ATTRIBUTE = "aliasedObjectName";
+
/**
* Initializes this partition.
*/
void init( DirectoryServiceConfiguration factoryCfg, DirectoryPartitionConfiguration cfg ) throws NamingException;
-
-
+
+
/**
* Deinitialized this partition.
*/
void destroy();
+
/**
* Checks to see if this partition is initialized or not.
*/
boolean isInitialized();
+
/**
* Flushes any changes made to this partition now.
*/
void sync() throws NamingException;
-
+
/**
* Gets the distinguished/absolute name of the suffix for all entries
* stored within this ContextPartition.
@@ -90,7 +93,7 @@
*/
Name getSuffix( boolean normalized ) throws NamingException;
-
+
/**
* Deletes a leaf entry from this ContextPartition: non-leaf entries cannot be
* deleted until this operation has been applied to their children.
@@ -98,9 +101,10 @@
* @param name the normalized distinguished/absolute name of the entry to
* delete from this ContextPartition.
* @throws NamingException if there are any problems
- */
+ */
void delete( Name name ) throws NamingException;
+
/**
* Adds an entry to this ContextPartition.
*
@@ -111,6 +115,7 @@
*/
void add( String userProvidedName, Name normalizedName, Attributes entry ) throws NamingException;
+
/**
* Modifies an entry by adding, removing or replacing a set of attributes.
*
@@ -129,6 +134,7 @@
*/
void modify( Name name, int modOp, Attributes attributes ) throws NamingException;
+
/**
* Modifies an entry by using a combination of adds, removes or replace
* operations using a set of ModificationItems.
@@ -138,7 +144,8 @@
* @throws NamingException if there are any problems
* @see ModificationItem
*/
- void modify( Name name, ModificationItem [] items ) throws NamingException;
+ void modify( Name name, ModificationItem[] items ) throws NamingException;
+
/**
* A specialized form of one level search used to return a minimal set of
@@ -151,7 +158,8 @@
* @throws NamingException if there are any problems
*/
NamingEnumeration list( Name baseName ) throws NamingException;
-
+
+
/**
* Conducts a search against this ContextPartition. Namespace specific
* parameters for search are contained within the environment using
@@ -169,8 +177,9 @@
* <a href="http://java.sun.com/j2se/1.4.2/docs/api/
* javax/naming/directory/SearchResult.html">SearchResult</a>.
*/
- NamingEnumeration search( Name baseName, Map environment, ExprNode filter,
- SearchControls searchControls ) throws NamingException;
+ NamingEnumeration search( Name baseName, Map environment, ExprNode filter, SearchControls searchControls )
+ throws NamingException;
+
/**
* Looks up an entry by distinguished/absolute name. This is a simplified
@@ -183,6 +192,7 @@
*/
Attributes lookup( Name name ) throws NamingException;
+
/**
* Looks up an entry by distinguished/absolute name. This is a simplified
* version of the search operation used to point read an entry used for
@@ -194,7 +204,8 @@
* @return an Attributes object representing the entry
* @throws NamingException if there are any problems
*/
- Attributes lookup( Name name, String [] attrIds ) throws NamingException;
+ Attributes lookup( Name name, String[] attrIds ) throws NamingException;
+
/**
* Fast operation to check and see if a particular entry exists.
@@ -206,6 +217,7 @@
*/
boolean hasEntry( Name name ) throws NamingException;
+
/**
* Checks to see if name is a context suffix.
*
@@ -215,6 +227,7 @@
*/
boolean isSuffix( Name name ) throws NamingException;
+
/**
* Modifies an entry by changing its relative name. Optionally attributes
* associated with the old relative name can be removed from the entry.
@@ -228,8 +241,8 @@
* from the entry if set to true, and has no affect if set to false
* @throws NamingException if there are any problems
*/
- void modifyRn( Name name, String newRn, boolean deleteOldRn )
- throws NamingException;
+ void modifyRn( Name name, String newRn, boolean deleteOldRn ) throws NamingException;
+
/**
* Transplants a child entry, to a position in the namespace under a new
@@ -243,6 +256,7 @@
*/
void move( Name oldName, Name newParentName ) throws NamingException;
+
/**
* Transplants a child entry, to a position in the namespace under a new
* parent entry and changes the RN of the child entry which can optionally
@@ -260,9 +274,9 @@
* from the entry if set to true, and has no affect if set to false
* @throws NamingException if there are any problems
*/
- void move( Name oldName, Name newParentName, String newRn,
- boolean deleteOldRn ) throws NamingException;
-
+ void move( Name oldName, Name newParentName, String newRn, boolean deleteOldRn ) throws NamingException;
+
+
/**
* Represents a bind operation issued to authenticate a client. Partitions
* need not support this operation. This operation is here to enable those
@@ -276,6 +290,7 @@
* @throws NamingException if something goes wrong
*/
void bind( Name bindDn, byte[] credentials, List mechanisms, String saslAuthId ) throws NamingException;
+
/**
* Represents an unbind operation issued by an authenticated client. Partitions
Modified: directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/DirectoryPartitionNexus.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/DirectoryPartitionNexus.java?rev=376623&r1=376622&r2=376623&view=diff
==============================================================================
--- directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/DirectoryPartitionNexus.java (original)
+++ directory/sandbox/akarasulu/rc1/apacheds/core/src/main/java/org/apache/directory/server/core/partition/DirectoryPartitionNexus.java Fri Feb 10 02:48:07 2006
@@ -57,7 +57,8 @@
* building the name. Note that what ever the SUFFIX equals it should be
* both the normalized and the user provided form.
*/
- public static final String SYSTEM_PARTITION_SUFFIX = "ou=system" ;
+ public static final String SYSTEM_PARTITION_SUFFIX = "ou=system";
+
/**
* Gets the DN for the admin user.
@@ -66,7 +67,7 @@
public static final Name getAdminName()
{
Name adminDn = null;
-
+
try
{
adminDn = new LdapName( ADMIN_PRINCIPAL );
@@ -75,10 +76,11 @@
{
throw new InternalError();
}
-
+
return adminDn;
}
+
/**
* Gets the DN for the base entry under which all groups reside.
* A new Name instance is created and returned every time.
@@ -87,7 +89,7 @@
public static final Name getGroupsBaseName()
{
Name groupsBaseDn = null;
-
+
try
{
groupsBaseDn = new LdapName( GROUPS_BASE_NAME );
@@ -96,10 +98,11 @@
{
throw new InternalError();
}
-
+
return groupsBaseDn;
}
+
/**
* Gets the DN for the base entry under which all non-admin users reside.
* A new Name instance is created and returned every time.
@@ -108,7 +111,7 @@
public static final Name getUsersBaseName()
{
Name usersBaseDn = null;
-
+
try
{
usersBaseDn = new LdapName( USERS_BASE_NAME );
@@ -117,10 +120,11 @@
{
throw new InternalError();
}
-
+
return usersBaseDn;
}
+
/**
* Gets the LdapContext associated with the calling thread.
*
@@ -129,6 +133,7 @@
*/
public abstract LdapContext getLdapContext();
+
/**
* Get's the RootDSE entry for the DSA.
*
@@ -136,6 +141,7 @@
*/
public abstract Attributes getRootDSE() throws NamingException;
+
/**
* Performs a comparison check to see if an attribute of an entry has
* a specified value.
@@ -148,12 +154,16 @@
*/
public abstract boolean compare( Name name, String oid, Object value ) throws NamingException;
+
public abstract void addContextPartition( DirectoryPartitionConfiguration config ) throws NamingException;
-
+
+
public abstract void removeContextPartition( Name suffix ) throws NamingException;
+
public abstract DirectoryPartition getSystemPartition();
-
+
+
/**
* Get's the partition corresponding to a distinguished name. This
* name need not be the name of the partition suffix. When used in
@@ -166,6 +176,7 @@
*/
public abstract DirectoryPartition getPartition( Name dn ) throws NamingException;
+
/**
* Gets the most significant Dn that exists within the server for any Dn.
*
@@ -180,6 +191,7 @@
*/
public abstract Name getMatchedName( Name name, boolean normalized ) throws NamingException;
+
/**
* Gets the distinguished name of the suffix that would hold an entry with
* the supplied distinguished name parameter. If the DN argument does not
@@ -195,6 +207,7 @@
*/
public abstract Name getSuffix( Name name, boolean normalized ) throws NamingException;
+
/**
* Gets an iteration over the Name suffixes of the partitions managed by this
* {@link DirectoryPartitionNexus}.
@@ -206,6 +219,7 @@
* @throws NamingException if there are any problems
*/
public abstract Iterator listSuffixes( boolean normalized ) throws NamingException;
+
/**
* Adds a set of supportedExtension (OID Strings) to the RootDSE.