You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2007/12/09 00:10:24 UTC
svn commit: r602574 - in /directory:
apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/
apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/
apacheds/branches/bigbang/core-in...
Author: elecharny
Date: Sat Dec 8 15:10:21 2007
New Revision: 602574
URL: http://svn.apache.org/viewvc?rev=602574&view=rev
Log:
o Used an enum to store the encyption algorithms
o Created a constant for "ou=system" : ServerDNConstants.SYSTEM_DN
o Created a constant for "uid=admin,ou=system" : ServerDNConstants.ADMIN_SYSTEM_DN
o Added a Modification, ServerModification and ModificationOperation class, Enul and interface
o Lot of small modification in shared-ldap ServerEntry and in core-entry
o Deleted the useless fastITests
Added:
directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerModification.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ModificationOperation.java
Removed:
directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerFastTest.java
directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/FastAddITest.java
directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/FastDelITest.java
directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/FastSearchTest.java
Modified:
directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/BasicServerAttribute.java
directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ObjectClassAttribute.java
directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java
directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStreamedValue.java
directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java
directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java
directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/authz/AutzIntegUtils.java
directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexus.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/checksum/RsaMd5Checksum.java
directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/DesCbcMd5Encryption.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultBindHandler.java
directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java
directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/DIRSERVER951ITest.java
directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/NegationOperatorITest.java
directory/shared/branches/bigbang/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/LdapSecurityConstants.java
directory/shared/branches/bigbang/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/ServerDNConstants.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StreamedValue.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java
directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java
Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/BasicServerAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/BasicServerAttribute.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/BasicServerAttribute.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/BasicServerAttribute.java Sat Dec 8 15:10:21 2007
@@ -238,7 +238,7 @@
return false;
}
- for ( ServerValue value : values )
+ for ( ServerValue<?> value : values )
{
if ( ! value.isValid() )
{
Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ObjectClassAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ObjectClassAttribute.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ObjectClassAttribute.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ObjectClassAttribute.java Sat Dec 8 15:10:21 2007
@@ -22,7 +22,6 @@
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.ObjectClass;
-import org.apache.directory.shared.ldap.schema.ObjectClassTypeEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,13 +40,16 @@
*/
public class ObjectClassAttribute implements ServerAttribute
{
- @SuppressWarnings ( { "UnusedDeclaration" } )
+ /** A logger */
private static final Logger LOG = LoggerFactory.getLogger( ObjectClassAttribute.class );
+ /** An unordered set storing the values */
private HashSet<ServerValue<?>> values = new HashSet<ServerValue<?>>();
- @SuppressWarnings ( { "FieldCanBeLocal", "UnusedDeclaration" } )
- private Registries registries;
+
+ /** The associated Attribute Type */
private AttributeType attributeType;
+
+ /** The attribute User Provided ID */
private String upId;
// Sets dealing with objectClass operations
@@ -63,18 +65,29 @@
// maybe have some additional convenience constructors which take
// an initial value as a string or a byte[]
-
-
+
+ /**
+ * Creates a new ObjectClassAttribute with a null ID
+ *
+ * @param registries The server registries to use
+ */
public ObjectClassAttribute( Registries registries ) throws NamingException
{
this( null, registries );
}
+ /**
+ * Creates a new instance of ObjectClassAttribute.
+ *
+ * @param upId The ObjectClass ID
+ * @param registries The registries to use to initialize this object
+ * @throws NamingException If something went wrong
+ */
public ObjectClassAttribute( String upId, Registries registries ) throws NamingException
{
setAttributeTypeAndRegistries( registries );
- setUpId( upId, attributeType );
+ setUpId( upId );
}
@@ -115,7 +128,7 @@
values.add( val );
}
- setUpId( upId, attributeType );
+ setUpId( upId );
}
@@ -128,6 +141,7 @@
public ObjectClassAttribute( String upId, Registries registries, String val ) throws NamingException
{
setAttributeTypeAndRegistries( registries );
+
if ( val == null )
{
values.add( new ServerStringValue( attributeType ) );
@@ -137,22 +151,48 @@
values.add( new ServerStringValue( attributeType, val ) );
}
- setUpId( upId, attributeType );
+ setUpId( upId );
}
-
+
+ /**
+ * Initialize the ObjectClass attributeType, using the ObjectClass' OID.
+ *
+ * TODO This is a strange method : we _know_ that the ObjectClass' attributeType
+ * will always be the same, but we can't initialize it to its default value,
+ * unless the server is already started, or if we call this method only once,
+ * but then we need to synchronize this class, which can be a burden.
+ *
+ * This is was seems the best anyway...
+ *
+ * @param registries The registries used to extract the AttributeType
+ *
+ * @throws NamingException If something went wrong (very unlikely)
+ */
private void setAttributeTypeAndRegistries( Registries registries ) throws NamingException
{
- this.registries = registries;
- attributeType = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT_OID );
+ synchronized ( attributeType )
+ {
+ if ( attributeType == null )
+ {
+ attributeType = registries.getAttributeTypeRegistry().lookup( SchemaConstants.OBJECT_CLASS_AT_OID );
+ }
+ }
}
- private void setUpId( String upId, AttributeType attributeType )
+ /**
+ * Set the user provided value for this objectClass.
+ *
+ * @param upId The user provided ID
+ * @param attributeType
+ */
+ private void setUpId( String upId )
{
if ( upId == null )
{
String name = attributeType.getName();
+
if ( name == null )
{
this.upId = attributeType.getOid();
@@ -162,6 +202,10 @@
this.upId = name;
}
}
+ else
+ {
+ this.upId = upId;
+ }
}
@@ -177,7 +221,8 @@
}
ObjectClass[] superClasses = descendant.getSuperClasses();
- if ( superClasses == null || superClasses.length == 0 )
+
+ if ( ( superClasses == null ) || ( superClasses.length == 0 ) )
{
return ancestors;
}
@@ -204,20 +249,24 @@
Set<ObjectClass> ancestors = addAncestors( objectClass, new HashSet<ObjectClass>() );
ancestors.add( objectClass );
+
// now create sets of the different kinds of objectClasses
for ( ObjectClass oc : ancestors )
{
- switch ( oc.getType().getValue() )
+ switch ( oc.getType() )
{
- case( ObjectClassTypeEnum.STRUCTURAL_VAL ):
+ case STRUCTURAL :
structuralObjectClasses.add( oc );
break;
- case( ObjectClassTypeEnum.AUXILIARY_VAL ):
+
+ case AUXILIARY :
auxiliaryObjectClasses.add( oc );
break;
- case( ObjectClassTypeEnum.ABSTRACT_VAL ):
+
+ case ABSTRACT :
abstractObjectClasses.add( oc );
break;
+
default:
throw new IllegalStateException( "Unrecognized objectClass type value: " + oc.getType() );
}
@@ -332,7 +381,7 @@
*/
public boolean isValid() throws NamingException
{
- for ( ServerValue value : values )
+ for ( ServerValue<?> value:values )
{
if ( ! value.isValid() )
{
@@ -344,6 +393,9 @@
}
+ /**
+ * Add a value to the current objectClass
+ */
public boolean add( ServerValue<?> val )
{
return values.add( val );
Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerBinaryValue.java Sat Dec 8 15:10:21 2007
@@ -46,7 +46,6 @@
private static final Logger LOG = LoggerFactory.getLogger( ServerBinaryValue.class );
/** used to dynamically lookup the attributeType when/if deserializing */
- @SuppressWarnings ( { "UnusedDeclaration", "FieldCanBeLocal" } )
private final String oid;
/** reference to the attributeType which is not serialized */
@@ -118,9 +117,14 @@
{
// Why should we invalidate the normalized value if it's we're setting the
// wrapper to it's current value?
- if ( Arrays.equals( wrapped, get() ) )
+ byte[] value = getUnsafe();
+
+ if ( value != null )
{
- return;
+ if ( Arrays.equals( wrapped, value ) )
+ {
+ return;
+ }
}
normalizedValue = null;
@@ -146,7 +150,7 @@
*/
public byte[] getNormalizedValue() throws NamingException
{
- if ( get() == null )
+ if ( isNull() )
{
return null;
}
@@ -185,7 +189,7 @@
return valid;
}
- valid = attributeType.getSyntax().getSyntaxChecker().isValidSyntax( get() );
+ valid = attributeType.getSyntax().getSyntaxChecker().isValidSyntax( getUnsafe() );
return valid;
}
@@ -197,33 +201,32 @@
*/
public int compareTo( ServerValue<byte[]> value )
{
- if ( value == null && get() == null )
+ if ( isNull() )
{
- return 0;
- }
-
- if ( value != null && get() == null )
- {
- if ( value.get() == null )
+ if ( ( value == null ) || value.isNull() )
{
return 0;
}
- return -1;
+ else
+ {
+ return -1;
+ }
}
-
- if ( value == null )
+ else
{
- return 1;
+ if ( ( value == null ) || value.isNull() )
+ {
+ return 1;
+ }
}
-
+
try
{
- //noinspection unchecked
return getComparator().compare( getNormalizedValue(), value.getNormalizedValue() );
}
catch ( NamingException e )
{
- String msg = "Failed to compare normalized values for " + Arrays.toString( get() )
+ String msg = "Failed to compare normalized values for " + Arrays.toString( getUnsafe() )
+ " and " + Arrays.toString( value.get() );
LOG.error( msg, e );
throw new IllegalStateException( msg, e );
@@ -271,7 +274,7 @@
{
// return zero if the value is null so only one null value can be
// stored in an attribute - the string version does the same
- if ( get() == null )
+ if ( isNull() )
{
return 0;
}
@@ -315,14 +318,13 @@
}
ServerBinaryValue other = ( ServerBinaryValue ) obj;
- if ( get() == null && other.get() == null )
+
+ if ( isNull() && other.isNull() )
{
return true;
}
- //noinspection SimplifiableIfStatement
- if ( get() == null && other.get() != null ||
- get() != null && other.get() == null )
+ if ( isNull() != other.isNull() )
{
return false;
}
@@ -340,7 +342,7 @@
+ toString() + " and " + other.toString() , e );
// recover by comparing non-normalized values
- return Arrays.equals( get(), other.get() );
+ return Arrays.equals( getUnsafe(), other.getUnsafe() );
}
}
Added: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerModification.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerModification.java?rev=602574&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerModification.java (added)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerModification.java Sat Dec 8 15:10:21 2007
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.server.core.entry;
+
+import java.io.Serializable;
+
+import javax.naming.directory.DirContext;
+
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.entry.Value;
+
+/**
+ * An internal implementation for a ModificationItem. The name has been
+ * chosen so that it does not conflict with @see ModificationItem
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ServerModification implements Modification, Serializable
+{
+ public static final long serialVersionUID = 1L;
+
+ /** The modification operation */
+ private ModificationOperation operation;
+
+ /** The attribute which contains the modification */
+ private EntryAttribute<? extends Value<?>> attribute;
+
+
+ /**
+ * @return the operation
+ */
+ public ModificationOperation getOperation()
+ {
+ return operation;
+ }
+
+
+ /**
+ * Store the modification operation
+ *
+ * @param operation The DirContext value to assign
+ */
+ public void setOperation( int operation )
+ {
+ switch ( operation )
+ {
+ case DirContext.ADD_ATTRIBUTE :
+ this.operation = ModificationOperation.ADD_ATTRIBUTE;
+
+ case DirContext.REPLACE_ATTRIBUTE :
+ this.operation = ModificationOperation.REPLACE_ATTRIBUTE;
+
+ case DirContext.REMOVE_ATTRIBUTE :
+ this.operation = ModificationOperation.REMOVE_ATTRIBUTE;
+ }
+ }
+
+
+ /**
+ * Store the modification operation
+ *
+ * @param operation The DirContext value to assign
+ */
+ public void setOperation( ModificationOperation operation )
+ {
+ this.operation = operation;
+ }
+
+
+ /**
+ * @return the attribute containing the modifications
+ */
+ public EntryAttribute<? extends Value<?>> getAttribute()
+ {
+ return attribute;
+ }
+
+
+ /**
+ * Set the attribute's modification
+ *
+ * @param attribute The modified attribute
+ */
+ public void setAttribute( EntryAttribute<? extends Value<?>> attribute )
+ {
+ this.attribute = attribute;
+ }
+
+
+ /**
+ * Compute the modification @see Object#hashCode
+ */
+ public int hashCode()
+ {
+ int h = 37;
+
+ h += h*17 + operation.getValue();
+ h += h*17 + attribute.hashCode();
+
+ return h;
+ }
+
+
+ /**
+ * @see Object#toString()
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "Modification: " ).
+ append( operation ).
+ append( "\n" ).
+ append( ", attribute : " ).
+ append( attribute );
+
+ return sb.toString();
+ }
+}
Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStreamedValue.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStreamedValue.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStreamedValue.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStreamedValue.java Sat Dec 8 15:10:21 2007
@@ -78,11 +78,9 @@
private static final Logger LOG = LoggerFactory.getLogger( ServerStreamedValue.class );
// use this to lookup the attributeType when deserializing
- @SuppressWarnings ( { "UnusedDeclaration", "FieldCanBeLocal" } )
private final String oid;
// do not serialize the schema entity graph associated with the type
- @SuppressWarnings ( { "UnusedDeclaration", "FieldCanBeLocal" } )
private transient AttributeType attributeType;
@@ -241,7 +239,6 @@
return true;
}
- //noinspection RedundantIfStatement
if ( this.attributeType.isDescentantOf( attributeType ) )
{
return true;
Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerStringValue.java Sat Dec 8 15:10:21 2007
@@ -45,7 +45,6 @@
private static final Logger LOG = LoggerFactory.getLogger( ServerStringValue.class );
/** used to dynamically lookup the attributeType when/if deserializing */
- @SuppressWarnings ( { "UnusedDeclaration", "FieldCanBeLocal" } )
private final String oid;
/** reference to the attributeType which is not serialized */
@@ -146,7 +145,7 @@
*/
public String getNormalizedValue() throws NamingException
{
- if ( get() == null )
+ if ( isNull() )
{
return null;
}
@@ -197,28 +196,24 @@
*/
public int compareTo( ServerValue<String> value )
{
- if ( value == null && get() == null )
+ if ( isNull() )
{
- return 0;
- }
-
- if ( value != null && get() == null )
- {
- if ( value.get() == null )
+ if ( ( value == null ) || value.isNull() )
{
return 0;
}
- return -1;
+ else
+ {
+ return -1;
+ }
}
-
- if ( value == null )
+ else if ( ( value == null ) || value.isNull() )
{
return 1;
}
-
+
try
{
- //noinspection unchecked
return getComparator().compare( getNormalizedValue(), value.getNormalizedValue() );
}
catch ( NamingException e )
@@ -270,7 +265,7 @@
{
// return zero if the value is null so only one null value can be
// stored in an attribute - the binary version does the same
- if ( get() == null )
+ if ( isNull() )
{
return 0;
}
@@ -314,14 +309,13 @@
}
ServerStringValue other = ( ServerStringValue ) obj;
- if ( get() == null && other.get() == null )
+
+ if ( isNull() && other.isNull() )
{
return true;
}
- //noinspection SimplifiableIfStatement
- if ( get() == null && other.get() != null ||
- get() != null && other.get() == null )
+ if ( isNull() != other.isNull() )
{
return false;
}
Modified: directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerStringValueTest.java Sat Dec 8 15:10:21 2007
@@ -1,10 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
package org.apache.directory.server.core.entry;
-import junit.framework.TestCase;
-import org.apache.directory.shared.ldap.schema.*;
+import org.apache.directory.shared.ldap.schema.AbstractAttributeType;
+import org.apache.directory.shared.ldap.schema.AbstractMatchingRule;
+import org.apache.directory.shared.ldap.schema.AbstractSyntax;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.ByteArrayComparator;
+import org.apache.directory.shared.ldap.schema.MatchingRule;
+import org.apache.directory.shared.ldap.schema.NoOpNormalizer;
+import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.schema.Syntax;
import org.apache.directory.shared.ldap.schema.syntax.AcceptAllSyntaxChecker;
import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
+import org.junit.Test;
import javax.naming.NamingException;
import javax.naming.directory.InvalidAttributeValueException;
@@ -13,6 +40,10 @@
import java.util.Comparator;
import java.util.HashSet;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+
/**
* Tests that the ServerStringValue class works properly as expected.
@@ -27,13 +58,14 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public class ServerStringValueTest extends TestCase
+public class ServerStringValueTest
{
private AttributeType getCaseIgnoringAttributeNoNumbersType()
{
S s = new S( "1.1.1.1", true );
- s.setSyntaxChecker( new SyntaxChecker(){
+ s.setSyntaxChecker( new SyntaxChecker()
+ {
public String getSyntaxOid()
{
return "1.1.1.1";
@@ -46,9 +78,9 @@
}
String strval = ( String ) value;
- for ( int ii = 0; ii < strval.length(); ii++ )
+ for ( char c:strval.toCharArray() )
{
- if ( Character.isDigit( strval.charAt( ii ) ) )
+ if ( Character.isDigit( c ) )
{
return false;
}
@@ -77,13 +109,13 @@
}
//noinspection ConstantConditions
- if ( o1 == null && o2 != null )
+ if ( ( o1 == null ) && ( o2 != null ) )
{
return -1;
}
//noinspection ConstantConditions
- if ( o1 != null && o2 == null )
+ if ( ( o1 != null ) && ( o2 == null ) )
{
return 1;
}
@@ -93,13 +125,25 @@
int getValue( String val )
{
- if ( val.equals( "LOW" ) ) return 0;
- if ( val.equals( "MEDIUM" ) ) return 1;
- if ( val.equals( "HIGH" ) ) return 2;
+ if ( val.equals( "LOW" ) )
+ {
+ return 0;
+ }
+ else if ( val.equals( "MEDIUM" ) )
+ {
+ return 1;
+ }
+ else if ( val.equals( "HIGH" ) )
+ {
+ return 2;
+ }
+
throw new IllegalArgumentException( "Not a valid value" );
}
};
- mr.normalizer = new Normalizer(){
+
+ mr.normalizer = new Normalizer()
+ {
public Object normalize( Object value ) throws NamingException
{
@@ -122,7 +166,7 @@
* Tests to make sure the hashCode method is working properly.
* @throws Exception on errors
*/
- public void testHashCodeValidEquals() throws Exception
+ @Test public void testHashCodeValidEquals() throws Exception
{
AttributeType at = getCaseIgnoringAttributeNoNumbersType();
ServerStringValue v0 = new ServerStringValue( at, "Alex" );
@@ -156,7 +200,7 @@
*
* @throws Exception on errors
*/
- public void testConstrainedString() throws Exception
+ @Test public void testConstrainedString() throws Exception
{
S s = new S( "1.1.1.1", true );
@@ -307,7 +351,7 @@
* is still OK.
* @throws Exception on errors
*/
- public void testAcceptAllNoNormalization() throws Exception
+ @Test public void testAcceptAllNoNormalization() throws Exception
{
S s = new S( "1.1.1.1", false );
s.setSyntaxChecker( new AcceptAllSyntaxChecker( "1.1.1.1" ) );
@@ -362,7 +406,7 @@
list.add( v2 );
list.add( v4 );
- Comparator c = new Comparator<ServerStringValue>()
+ Comparator<ServerStringValue> c = new Comparator<ServerStringValue>()
{
public int compare( ServerStringValue o1, ServerStringValue o2 )
{
@@ -396,7 +440,6 @@
try
{
- //noinspection unchecked
return mr.getComparator().compare( b1, b2 );
}
catch ( Exception e )
@@ -405,7 +448,7 @@
}
}
};
- //noinspection unchecked
+
Collections.sort( list, c );
assertTrue( "since v4 equals v5 and has no value either could be at index 0 & 1", list.get( 0 ).equals( v4 ) );
Modified: directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/authz/AutzIntegUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/authz/AutzIntegUtils.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/authz/AutzIntegUtils.java (original)
+++ directory/apacheds/branches/bigbang/core-integ/src/test/java/org/apache/directory/server/core/authz/AutzIntegUtils.java Sat Dec 8 15:10:21 2007
@@ -27,6 +27,7 @@
import org.apache.directory.server.core.partition.PartitionNexus;
import org.apache.directory.server.core.subtree.SubentryInterceptor;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.constants.ServerDNConstants;
import org.apache.directory.shared.ldap.message.AttributeImpl;
import org.apache.directory.shared.ldap.message.AttributesImpl;
import org.apache.directory.shared.ldap.name.LdapDN;
@@ -111,7 +112,7 @@
Hashtable<String,Object> env = ( Hashtable<String,Object> ) sysRoot.getEnvironment().clone();
env.put( DirContext.PROVIDER_URL, dn );
env.put( DirContext.SECURITY_AUTHENTICATION, "simple" );
- env.put( DirContext.SECURITY_PRINCIPAL, PartitionNexus.ADMIN_PRINCIPAL );
+ env.put( DirContext.SECURITY_PRINCIPAL, "uid=admin, ou=system" );
env.put( DirContext.SECURITY_CREDENTIALS, "secret" );
env.put( DirContext.INITIAL_CONTEXT_FACTORY, "org.apache.directory.server.core.jndi.CoreContextFactory" );
env.put( DirectoryService.JNDI_KEY, service );
@@ -249,7 +250,7 @@
*/
public static DirContext getContextAs( Name user, String password ) throws NamingException
{
- return getContextAs( user, password, PartitionNexus.SYSTEM_PARTITION_SUFFIX );
+ return getContextAs( user, password, ServerDNConstants.SYSTEM_DN );
}
Modified: directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java (original)
+++ directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java Sat Dec 8 15:10:21 2007
@@ -27,6 +27,7 @@
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.constants.ServerDNConstants;
import org.apache.directory.shared.ldap.ldif.ChangeType;
import org.apache.directory.shared.ldap.ldif.Entry;
import org.apache.directory.shared.ldap.ldif.LdifReader;
@@ -115,7 +116,7 @@
*/
protected AbstractPerformanceTest( Class<?> subclass ) throws IOException
{
- super( PartitionNexus.ADMIN_PRINCIPAL, "secret" );
+ super( ServerDNConstants.ADMIN_SYSTEM_DN, "secret" );
this.subclass = subclass;
// Setup the statistics output writer
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Sat Dec 8 15:10:21 2007
@@ -1150,7 +1150,7 @@
// Warn if the default password is not changed.
boolean needToChangeAdminPassword = false;
- LdapDN adminDn = new LdapDN( PartitionNexus.ADMIN_PRINCIPAL );
+ LdapDN adminDn = new LdapDN( ServerDNConstants.ADMIN_SYSTEM_DN );
adminDn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
Attributes adminEntry = partitionNexus.lookup( new LookupOperationContext( adminDn ) );
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java Sat Dec 8 15:10:21 2007
@@ -170,9 +170,9 @@
private class EncryptionMethod
{
private byte[] salt;
- private String algorithm;
+ private LdapSecurityConstants algorithm;
- private EncryptionMethod( String algorithm, byte[] salt )
+ private EncryptionMethod( LdapSecurityConstants algorithm, byte[] salt )
{
this.algorithm = algorithm;
this.salt = salt;
@@ -322,7 +322,7 @@
}
// Let's see if the stored password was encrypted
- String algorithm = findAlgorithm( storedPassword );
+ LdapSecurityConstants algorithm = findAlgorithm( storedPassword );
if ( algorithm != null )
{
@@ -385,63 +385,60 @@
*/
private byte[] splitCredentials( byte[] credentials, EncryptionMethod encryptionMethod )
{
- String algorithm = encryptionMethod.algorithm;
+ int pos = encryptionMethod.algorithm.getName().length() + 2;
- int pos = algorithm.length() + 2;
-
- if ( ( LdapSecurityConstants.HASH_METHOD_MD5.equalsIgnoreCase( algorithm ) ) ||
- ( LdapSecurityConstants.HASH_METHOD_SHA.equalsIgnoreCase( algorithm ) ) )
- {
- try
- {
- // We just have the password just after the algorithm, base64 encoded.
- // Just decode the password and return it.
- return Base64.decode( new String( credentials, pos, credentials.length - pos, "UTF-8" ).toCharArray() );
- }
- catch ( UnsupportedEncodingException uee )
- {
- // do nothing
- return credentials;
- }
- }
- else if ( ( LdapSecurityConstants.HASH_METHOD_SMD5.equalsIgnoreCase( algorithm ) ) ||
- ( LdapSecurityConstants.HASH_METHOD_SSHA.equalsIgnoreCase( algorithm ) ) )
+ switch ( encryptionMethod.algorithm )
{
- try
- {
- // The password is associated with a salt. Decompose it
- // in two parts, after having decoded the password.
- // The salt will be stored into the EncryptionMethod structure
- // The salt is at the end of the credentials, and is 8 bytes long
- byte[] passwordAndSalt = Base64.decode( new String( credentials, pos, credentials.length - pos, "UTF-8" ).toCharArray() );
-
- encryptionMethod.salt = new byte[8];
- byte[] password = new byte[passwordAndSalt.length - encryptionMethod.salt.length];
- split( passwordAndSalt, 0, password, encryptionMethod.salt );
+ case HASH_METHOD_MD5 :
+ case HASH_METHOD_SHA :
+ try
+ {
+ // We just have the password just after the algorithm, base64 encoded.
+ // Just decode the password and return it.
+ return Base64.decode( new String( credentials, pos, credentials.length - pos, "UTF-8" ).toCharArray() );
+ }
+ catch ( UnsupportedEncodingException uee )
+ {
+ // do nothing
+ return credentials;
+ }
+
+ case HASH_METHOD_SMD5 :
+ case HASH_METHOD_SSHA :
+ try
+ {
+ // The password is associated with a salt. Decompose it
+ // in two parts, after having decoded the password.
+ // The salt will be stored into the EncryptionMethod structure
+ // The salt is at the end of the credentials, and is 8 bytes long
+ byte[] passwordAndSalt = Base64.decode( new String( credentials, pos, credentials.length - pos, "UTF-8" ).toCharArray() );
+
+ encryptionMethod.salt = new byte[8];
+ byte[] password = new byte[passwordAndSalt.length - encryptionMethod.salt.length];
+ split( passwordAndSalt, 0, password, encryptionMethod.salt );
+
+ return password;
+ }
+ catch ( UnsupportedEncodingException uee )
+ {
+ // do nothing
+ return credentials;
+ }
+
+ case HASH_METHOD_CRYPT :
+ // The password is associated with a salt. Decompose it
+ // in two parts, storing the salt into the EncryptionMethod structure.
+ // The salt comes first, not like for SSHA and SMD5, and is 2 bytes long
+ encryptionMethod.salt = new byte[2];
+ byte[] password = new byte[credentials.length - encryptionMethod.salt.length - pos];
+ split( credentials, pos, encryptionMethod.salt, password );
return password;
- }
- catch ( UnsupportedEncodingException uee )
- {
- // do nothing
+
+ default :
+ // unknown method
return credentials;
- }
- }
- else if ( LdapSecurityConstants.HASH_METHOD_CRYPT.equalsIgnoreCase( algorithm ) )
- {
- // The password is associated with a salt. Decompose it
- // in two parts, storing the salt into the EncryptionMethod structure.
- // The salt comes first, not like for SSHA and SMD5, and is 2 bytes long
- encryptionMethod.salt = new byte[2];
- byte[] password = new byte[credentials.length - encryptionMethod.salt.length - pos];
- split( credentials, pos, encryptionMethod.salt, password );
-
- return password;
- }
- else
- {
- // unknown method
- return credentials;
+
}
}
@@ -453,7 +450,7 @@
* @return the name of the algorithm to use
* TODO use an enum for the algorithm
*/
- private String findAlgorithm( byte[] credentials )
+ private LdapSecurityConstants findAlgorithm( byte[] credentials )
{
if ( ( credentials == null ) || ( credentials.length == 0 ) )
{
@@ -485,19 +482,7 @@
String algorithm = new String( credentials, 1, pos - 1 ).toLowerCase();
- if ( ( LdapSecurityConstants.HASH_METHOD_MD5.equals( algorithm ) ) ||
- ( LdapSecurityConstants.HASH_METHOD_SHA.equals( algorithm ) ) ||
- ( LdapSecurityConstants.HASH_METHOD_SMD5.equals( algorithm ) ) ||
- ( LdapSecurityConstants.HASH_METHOD_SSHA.equals( algorithm ) ) ||
- ( LdapSecurityConstants.HASH_METHOD_CRYPT.equals( algorithm ) ) )
- {
- return algorithm;
- }
- else
- {
- // unknown method
- return null;
- }
+ return LdapSecurityConstants.getAlgorithm( algorithm );
}
else
{
@@ -521,13 +506,13 @@
* @param salt the optional salt
* @return the digested credentials
*/
- private static byte[] digest( String algorithm, byte[] password, byte[] salt )
+ private static byte[] digest( LdapSecurityConstants algorithm, byte[] password, byte[] salt )
{
MessageDigest digest;
try
{
- digest = MessageDigest.getInstance( algorithm );
+ digest = MessageDigest.getInstance( algorithm.getName() );
}
catch ( NoSuchAlgorithmException e1 )
{
@@ -548,40 +533,37 @@
private byte[] encryptPassword( byte[] credentials, EncryptionMethod encryptionMethod )
{
- String algorithm = encryptionMethod.algorithm;
byte[] salt = encryptionMethod.salt;
- if ( LdapSecurityConstants.HASH_METHOD_SHA.equals( algorithm ) ||
- LdapSecurityConstants.HASH_METHOD_SSHA.equals( algorithm ) )
- {
- return digest( LdapSecurityConstants.HASH_METHOD_SHA, credentials, salt );
- }
- else if ( LdapSecurityConstants.HASH_METHOD_MD5.equals( algorithm ) ||
- LdapSecurityConstants.HASH_METHOD_SMD5.equals( algorithm ) )
- {
- return digest( LdapSecurityConstants.HASH_METHOD_MD5, credentials, salt );
- }
- else if ( LdapSecurityConstants.HASH_METHOD_CRYPT.equals( algorithm ) )
+ switch ( encryptionMethod.algorithm )
{
- if ( salt == null )
- {
- salt = new byte[2];
- SecureRandom sr = new SecureRandom();
- int i1 = sr.nextInt( 64 );
- int i2 = sr.nextInt( 64 );
-
- salt[0] = ( byte ) ( i1 < 12 ? ( i1 + '.' ) : i1 < 38 ? ( i1 + 'A' - 12 ) : ( i1 + 'a' - 38 ) );
- salt[1] = ( byte ) ( i2 < 12 ? ( i2 + '.' ) : i2 < 38 ? ( i2 + 'A' - 12 ) : ( i2 + 'a' - 38 ) );
- }
+ case HASH_METHOD_SHA :
+ case HASH_METHOD_SSHA :
+ return digest( LdapSecurityConstants.HASH_METHOD_SHA, credentials, salt );
+
+ case HASH_METHOD_MD5 :
+ case HASH_METHOD_SMD5 :
+ return digest( LdapSecurityConstants.HASH_METHOD_MD5, credentials, salt );
- String saltWithCrypted = UnixCrypt.crypt( StringTools.utf8ToString( credentials ), StringTools.utf8ToString( salt ) );
- String crypted = saltWithCrypted.substring( 2 );
-
- return StringTools.getBytesUtf8( crypted );
- }
- else
- {
- return credentials;
+ case HASH_METHOD_CRYPT :
+ if ( salt == null )
+ {
+ salt = new byte[2];
+ SecureRandom sr = new SecureRandom();
+ int i1 = sr.nextInt( 64 );
+ int i2 = sr.nextInt( 64 );
+
+ salt[0] = ( byte ) ( i1 < 12 ? ( i1 + '.' ) : i1 < 38 ? ( i1 + 'A' - 12 ) : ( i1 + 'a' - 38 ) );
+ salt[1] = ( byte ) ( i2 < 12 ? ( i2 + '.' ) : i2 < 38 ? ( i2 + 'A' - 12 ) : ( i2 + 'a' - 38 ) );
+ }
+
+ String saltWithCrypted = UnixCrypt.crypt( StringTools.utf8ToString( credentials ), StringTools.utf8ToString( salt ) );
+ String crypted = saltWithCrypted.substring( 2 );
+
+ return StringTools.getBytesUtf8( crypted );
+
+ default :
+ return credentials;
}
}
@@ -665,7 +647,7 @@
{
String algorithm = sPassword.substring( 1, rightParen );
- if ( LdapSecurityConstants.HASH_METHOD_CRYPT.equalsIgnoreCase( algorithm ) )
+ if ( LdapSecurityConstants.HASH_METHOD_CRYPT.getName().equalsIgnoreCase( algorithm ) )
{
return algorithm;
}
@@ -710,7 +692,7 @@
// create message digest object
try
{
- if ( LdapSecurityConstants.HASH_METHOD_CRYPT.equalsIgnoreCase( algorithm ) )
+ if ( LdapSecurityConstants.HASH_METHOD_CRYPT.getName().equalsIgnoreCase( algorithm ) )
{
String saltWithCrypted = UnixCrypt.crypt( StringTools.utf8ToString( password ), "" );
String crypted = saltWithCrypted.substring( 2 );
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java Sat Dec 8 15:10:21 2007
@@ -33,6 +33,7 @@
import org.apache.directory.shared.ldap.MultiException;
import org.apache.directory.shared.ldap.NotImplementedException;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.constants.ServerDNConstants;
import org.apache.directory.shared.ldap.constants.SupportedSASLMechanisms;
import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeIdentifierException;
import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
@@ -293,7 +294,7 @@
initializedPartitions.add( 0, this.system );
//noinspection unchecked
- Iterator<Partition> partitions = ( Iterator<Partition> ) directoryService.getPartitions().iterator();
+ Iterator<? extends Partition> partitions = ( Iterator<? extends Partition> ) directoryService.getPartitions().iterator();
try
{
while ( partitions.hasNext() )
@@ -348,10 +349,10 @@
objectClassAttr.add( SchemaConstants.TOP_OC );
objectClassAttr.add( SchemaConstants.ORGANIZATIONAL_UNIT_OC );
objectClassAttr.add( SchemaConstants.EXTENSIBLE_OBJECT_OC );
- systemEntry.put( SchemaConstants.CREATORS_NAME_AT, PartitionNexus.ADMIN_PRINCIPAL );
+ systemEntry.put( SchemaConstants.CREATORS_NAME_AT, ServerDNConstants.ADMIN_SYSTEM_DN );
systemEntry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
- systemEntry.put( NamespaceTools.getRdnAttribute( PartitionNexus.SYSTEM_PARTITION_SUFFIX ),
- NamespaceTools.getRdnValue( PartitionNexus.SYSTEM_PARTITION_SUFFIX ) );
+ systemEntry.put( NamespaceTools.getRdnAttribute( ServerDNConstants.SYSTEM_DN ),
+ NamespaceTools.getRdnValue( ServerDNConstants.SYSTEM_DN ) );
override.setContextEntry( systemEntry );
// ---------------------------------------------------------------
@@ -396,7 +397,7 @@
system = new JdbmPartition();
system.setId( "system" );
system.setCacheSize( 500 );
- system.setSuffix( PartitionNexus.SYSTEM_PARTITION_SUFFIX );
+ system.setSuffix( ServerDNConstants.SYSTEM_DN );
// Add objectClass attribute for the system partition
Set<Index> indexedAttrs = new HashSet<Index>();
@@ -410,10 +411,10 @@
objectClassAttr.add( SchemaConstants.ORGANIZATIONAL_UNIT_OC );
objectClassAttr.add( SchemaConstants.EXTENSIBLE_OBJECT_OC );
systemEntry.put( objectClassAttr );
- systemEntry.put( SchemaConstants.CREATORS_NAME_AT, PartitionNexus.ADMIN_PRINCIPAL );
+ systemEntry.put( SchemaConstants.CREATORS_NAME_AT, ServerDNConstants.ADMIN_SYSTEM_DN );
systemEntry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
- systemEntry.put( NamespaceTools.getRdnAttribute( PartitionNexus.SYSTEM_PARTITION_SUFFIX ),
- NamespaceTools.getRdnValue( PartitionNexus.SYSTEM_PARTITION_SUFFIX ) );
+ systemEntry.put( NamespaceTools.getRdnAttribute( ServerDNConstants.SYSTEM_DN ),
+ NamespaceTools.getRdnValue( ServerDNConstants.SYSTEM_DN ) );
system.setContextEntry( systemEntry );
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexus.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexus.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexus.java Sat Dec 8 15:10:21 2007
@@ -38,6 +38,7 @@
import org.apache.directory.server.core.interceptor.context.ListSuffixOperationContext;
import org.apache.directory.server.core.interceptor.context.RemoveContextPartitionOperationContext;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.constants.ServerDNConstants;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.schema.NoOpNormalizer;
import org.apache.directory.shared.ldap.schema.OidNormalizer;
@@ -55,7 +56,7 @@
public abstract class PartitionNexus implements Partition
{
/** the default user principal or DN */
- public final static String ADMIN_PRINCIPAL = "uid=admin,ou=system";
+ //public final static String ADMIN_PRINCIPAL = "uid=admin,ou=system";
/** the DN for the global schema subentry */
public final static String GLOBAL_SCHEMA_SUBENTRY_DN = "cn=schema";
@@ -76,15 +77,6 @@
public final static String GROUPS_BASE_NAME = "ou=groups,ou=system";
/**
- * System partition suffix constant. Should be kept down to a single Dn name
- * component or the default constructor will have to parse it instead of
- * 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";
-
-
- /**
* Gets the DN for the admin user.
*
* @return the admin user DN
@@ -95,7 +87,7 @@
try
{
- adminDn = new LdapDN( ADMIN_PRINCIPAL );
+ adminDn = new LdapDN( ServerDNConstants.ADMIN_SYSTEM_DN );
}
catch ( NamingException e )
{
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java Sat Dec 8 15:10:21 2007
@@ -31,6 +31,7 @@
import org.apache.directory.server.schema.registries.OidRegistry;
import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.constants.ServerDNConstants;
import org.apache.directory.shared.ldap.filter.*;
import org.apache.directory.shared.ldap.message.AttributeImpl;
import org.apache.directory.shared.ldap.message.AliasDerefMode;
@@ -570,7 +571,7 @@
new AttributeImpl( MetaSchemaConstants.M_DISABLED_AT ) ) );
mods.add( new ModificationItemImpl( DirContext.ADD_ATTRIBUTE,
- new AttributeImpl( SchemaConstants.MODIFIERS_NAME_AT, PartitionNexus.ADMIN_PRINCIPAL ) ) );
+ new AttributeImpl( SchemaConstants.MODIFIERS_NAME_AT, ServerDNConstants.ADMIN_SYSTEM_DN ) ) );
mods.add( new ModificationItemImpl( DirContext.ADD_ATTRIBUTE,
new AttributeImpl( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime() ) ) );
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java Sat Dec 8 15:10:21 2007
@@ -25,6 +25,7 @@
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.constants.ServerDNConstants;
import org.apache.directory.shared.ldap.message.AttributeImpl;
import org.apache.directory.shared.ldap.message.AttributesImpl;
import org.apache.directory.shared.ldap.name.LdapDN;
@@ -320,7 +321,7 @@
// Add the creatorsName
attr = new AttributeImpl( SchemaConstants.CREATORS_NAME_AT );
- attr.add( PartitionNexus.ADMIN_PRINCIPAL );
+ attr.add( ServerDNConstants.ADMIN_SYSTEM_DN );
attrs.put( attr );
// Add the modifyTimestamp
Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/checksum/RsaMd5Checksum.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/checksum/RsaMd5Checksum.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/checksum/RsaMd5Checksum.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/checksum/RsaMd5Checksum.java Sat Dec 8 15:10:21 2007
@@ -43,7 +43,7 @@
{
try
{
- MessageDigest digester = MessageDigest.getInstance( LdapSecurityConstants.HASH_METHOD_MD5 );
+ MessageDigest digester = MessageDigest.getInstance( LdapSecurityConstants.HASH_METHOD_MD5.getName() );
return digester.digest( data );
}
catch ( NoSuchAlgorithmException nsae )
Modified: directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/DesCbcMd5Encryption.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/DesCbcMd5Encryption.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/DesCbcMd5Encryption.java (original)
+++ directory/apacheds/branches/bigbang/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/DesCbcMd5Encryption.java Sat Dec 8 15:10:21 2007
@@ -71,7 +71,7 @@
{
try
{
- MessageDigest digester = MessageDigest.getInstance( LdapSecurityConstants.HASH_METHOD_MD5 );
+ MessageDigest digester = MessageDigest.getInstance( LdapSecurityConstants.HASH_METHOD_MD5.getName() );
return digester.digest( data );
}
catch ( NoSuchAlgorithmException nsae )
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultBindHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultBindHandler.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultBindHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultBindHandler.java Sat Dec 8 15:10:21 2007
@@ -23,7 +23,6 @@
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.authn.LdapPrincipal;
import org.apache.directory.server.core.jndi.ServerLdapContext;
-import org.apache.directory.server.core.partition.PartitionNexus;
import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType;
import org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey;
import org.apache.directory.server.kerberos.shared.store.PrincipalStoreEntry;
@@ -37,6 +36,7 @@
import org.apache.directory.server.ldap.support.bind.SaslFilter;
import org.apache.directory.server.protocol.shared.ServiceConfigurationException;
import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
+import org.apache.directory.shared.ldap.constants.ServerDNConstants;
import org.apache.directory.shared.ldap.constants.SupportedSASLMechanisms;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.message.*;
@@ -495,7 +495,7 @@
try
{
LdapPrincipal principal = new LdapPrincipal(
- new LdapDN( PartitionNexus.ADMIN_PRINCIPAL ), AuthenticationLevel.SIMPLE );
+ new LdapDN( ServerDNConstants.ADMIN_SYSTEM_DN ), AuthenticationLevel.SIMPLE );
ctx = ldapServer.getDirectoryService().getJndiContext( principal, ldapServer.getSearchBaseDn() );
}
catch ( NamingException ne )
Modified: directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java (original)
+++ directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java Sat Dec 8 15:10:21 2007
@@ -25,12 +25,12 @@
import org.apache.directory.server.core.DefaultDirectoryService;
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.authn.LdapPrincipal;
-import org.apache.directory.server.core.partition.PartitionNexus;
import org.apache.directory.server.ldap.LdapServer;
import org.apache.directory.server.protocol.shared.store.LdifFileLoader;
import org.apache.directory.server.protocol.shared.store.LdifLoadFilter;
import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.constants.ServerDNConstants;
import org.apache.directory.shared.ldap.message.AttributesImpl;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.util.StringTools;
@@ -318,7 +318,7 @@
}
- LdapPrincipal admin = new LdapPrincipal( new LdapDN( PartitionNexus.ADMIN_PRINCIPAL ),
+ LdapPrincipal admin = new LdapPrincipal( new LdapDN( ServerDNConstants.ADMIN_SYSTEM_DN ),
AuthenticationLevel.STRONG );
DirContext root = directoryService.getJndiContext( admin );
ensureLdifFileBase( root );
Modified: directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java (original)
+++ directory/apacheds/branches/bigbang/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java Sat Dec 8 15:10:21 2007
@@ -28,6 +28,7 @@
import org.apache.directory.server.core.jndi.CoreContextFactory;
import org.apache.directory.server.ldap.LdapServer;
import org.apache.directory.server.protocol.shared.SocketAcceptor;
+import org.apache.directory.shared.ldap.constants.ServerDNConstants;
import org.apache.directory.shared.ldap.exception.LdapConfigurationException;
import org.apache.directory.shared.ldap.ldif.Entry;
import org.apache.directory.shared.ldap.ldif.LdifReader;
@@ -301,7 +302,7 @@
protected void setContexts( Hashtable<String, Object> env ) throws NamingException
{
Hashtable<String, Object> envFinal = new Hashtable<String, Object>( env );
- envFinal.put( Context.PROVIDER_URL, "ou=system" );
+ envFinal.put( Context.PROVIDER_URL, ServerDNConstants.SYSTEM_DN );
sysRoot = new InitialLdapContext( envFinal, null );
envFinal.put( Context.PROVIDER_URL, "" );
Modified: directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/DIRSERVER951ITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/DIRSERVER951ITest.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/DIRSERVER951ITest.java (original)
+++ directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/DIRSERVER951ITest.java Sat Dec 8 15:10:21 2007
@@ -21,7 +21,6 @@
import org.apache.directory.server.core.partition.Oid;
-import org.apache.directory.server.core.partition.PartitionNexus;
import org.apache.directory.server.core.partition.impl.btree.Index;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
@@ -77,7 +76,7 @@
// @TODO need to make this configurable for the system partition
systemCfg.setCacheSize( 500 );
- systemCfg.setSuffix( PartitionNexus.SYSTEM_PARTITION_SUFFIX );
+ systemCfg.setSuffix( "ou=system" );
// Add indexed attributes for system partition
Set<Index> indexedAttrs = new HashSet<Index>();
Modified: directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/NegationOperatorITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/NegationOperatorITest.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/NegationOperatorITest.java (original)
+++ directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/NegationOperatorITest.java Sat Dec 8 15:10:21 2007
@@ -84,7 +84,7 @@
// @TODO need to make this configurable for the system partition
system.setCacheSize( 500 );
- system.setSuffix( PartitionNexus.SYSTEM_PARTITION_SUFFIX );
+ system.setSuffix( "ou=system" );
// Add indexed attributes for system partition
Set<Index> indexedAttrs = new HashSet<Index>();
@@ -99,10 +99,10 @@
objectClassAttr.add( SchemaConstants.ORGANIZATIONAL_UNIT_OC );
objectClassAttr.add( SchemaConstants.EXTENSIBLE_OBJECT_OC );
systemEntry.put( objectClassAttr );
- systemEntry.put( SchemaConstants.CREATORS_NAME_AT, PartitionNexus.ADMIN_PRINCIPAL );
+ systemEntry.put( SchemaConstants.CREATORS_NAME_AT, "uid=admin, ou=system" );
systemEntry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
- systemEntry.put( NamespaceTools.getRdnAttribute( PartitionNexus.SYSTEM_PARTITION_SUFFIX ),
- NamespaceTools.getRdnValue( PartitionNexus.SYSTEM_PARTITION_SUFFIX ) );
+ systemEntry.put( NamespaceTools.getRdnAttribute( "ou=system" ),
+ NamespaceTools.getRdnValue( "ou=system" ) );
system.setContextEntry( systemEntry );
directoryService.setSystemPartition( system );
Modified: directory/shared/branches/bigbang/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/LdapSecurityConstants.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/LdapSecurityConstants.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/LdapSecurityConstants.java (original)
+++ directory/shared/branches/bigbang/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/LdapSecurityConstants.java Sat Dec 8 15:10:21 2007
@@ -20,20 +20,77 @@
package org.apache.directory.shared.ldap.constants;
/**
- * A class to store all the security constants used in the server
+ * An enum to store all the security constants used in the server
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev:$
*/
-public class LdapSecurityConstants
+public enum LdapSecurityConstants
{
- public static final String HASH_METHOD_SHA = "sha";
+ HASH_METHOD_SHA( "sha" ),
- public static final String HASH_METHOD_SSHA = "ssha";
+ HASH_METHOD_SSHA( "ssha" ),
- public static final String HASH_METHOD_MD5 = "md5";
+ HASH_METHOD_MD5( "md5" ),
- public static final String HASH_METHOD_SMD5 = "smd5";
+ HASH_METHOD_SMD5( "smd5" ),
- public static final String HASH_METHOD_CRYPT = "crypt";
+ HASH_METHOD_CRYPT( "crypt" );
+
+ private String name;
+
+ /**
+ * Creates a new instance of LdapSecurityConstants.
+ */
+ private LdapSecurityConstants( String name )
+ {
+ this.name = name;
+ }
+
+ /**
+ * Return the name associated with the constant.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+
+ /**
+ * Get the associated constant from a string
+ *
+ * @param name The algorithm's name
+ * @return The associated constant
+ */
+ public static LdapSecurityConstants getAlgorithm( String name )
+ {
+ String algorithm = ( name == null ? "" : name.toLowerCase() );
+
+ if ( HASH_METHOD_SHA.getName().equalsIgnoreCase( algorithm ) )
+ {
+ return HASH_METHOD_SHA;
+ }
+
+ if ( HASH_METHOD_SSHA.getName().equalsIgnoreCase( algorithm ) )
+ {
+ return HASH_METHOD_SSHA;
+ }
+
+ if ( HASH_METHOD_MD5.getName().equalsIgnoreCase( algorithm ) )
+ {
+ return HASH_METHOD_MD5;
+ }
+
+ if ( HASH_METHOD_SMD5.getName().equalsIgnoreCase( algorithm ) )
+ {
+ return HASH_METHOD_SMD5;
+ }
+
+ if ( HASH_METHOD_CRYPT.getName().equalsIgnoreCase( algorithm ) )
+ {
+ return HASH_METHOD_CRYPT;
+ }
+
+ return null;
+ }
}
Modified: directory/shared/branches/bigbang/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/ServerDNConstants.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/ServerDNConstants.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/ServerDNConstants.java (original)
+++ directory/shared/branches/bigbang/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/ServerDNConstants.java Sat Dec 8 15:10:21 2007
@@ -29,4 +29,21 @@
{
public static final String ADMINISTRATORS_GROUP_DN = "cn=Administrators,ou=groups,ou=system";
+ public static final String SYSTEM_DN = "ou=system";
+
+ /** the default user principal or DN */
+ public final static String ADMIN_SYSTEM_DN = "uid=admin,ou=system";
+
+ /** the DN for the global schema subentry */
+ public final static String SCHEMA_DN = "cn=schema";
+
+ /** the normalized user principal or DN */
+ public final static String ADMIN_SYSTEM_DN_NORMALIZED = "0.9.2342.19200300.100.1.1=admin,2.5.4.11=system";
+
+ /** the base dn under which all users reside */
+ public final static String USERS_SYSTEM_DN = "ou=users,ou=system";
+
+ /** the base dn under which all groups reside */
+ public final static String GROUPS_SYSTEM_DN = "ou=groups,ou=system";
+
}
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/BinaryValue.java Sat Dec 8 15:10:21 2007
@@ -58,13 +58,7 @@
*/
public BinaryValue( byte[] wrapped )
{
- if ( wrapped != null )
- {
- this.wrapped = new byte[ wrapped.length ];
- System.arraycopy( wrapped, 0, this.wrapped, 0, wrapped.length );
- } else {
- this.wrapped = null;
- }
+ set( wrapped );
}
@@ -89,7 +83,9 @@
/**
- * Returns the wrapped binary value
+ * Returns the wrapped binary value. The value
+ * is copied, so any modification in the caller
+ * won't impact the local value.
*/
public byte[] get()
{
@@ -103,7 +99,27 @@
return copy;
}
+
+ /**
+ * Returns the wrapped binary value.
+ *
+ * Warning ! The value is not copied !!!
+ */
+ protected byte[] getUnsafe()
+ {
+ return wrapped;
+ }
+
+ /**
+ * Returns <code>true</code> if the wrapper contains no value.
+ */
+ public boolean isNull()
+ {
+ return wrapped == null;
+ }
+
+
/**
* Sets this value's wrapped value to a copy of the src array.
*
@@ -113,9 +129,10 @@
{
if ( wrapped != null )
{
- this.wrapped = new byte[ wrapped.length ];
- System.arraycopy( wrapped, 0, this.wrapped, 0, wrapped.length );
- } else {
+ this.wrapped = Arrays.copyOf( wrapped, wrapped.length );
+ }
+ else
+ {
this.wrapped = null;
}
}
@@ -132,8 +149,7 @@
if ( wrapped != null )
{
- cloned.wrapped = new byte[wrapped.length];
- System.arraycopy( wrapped, 0, cloned.wrapped, 0, wrapped.length );
+ cloned.wrapped = Arrays.copyOf( wrapped, wrapped.length );
}
return cloned;
@@ -167,9 +183,7 @@
return true;
}
- // no inspection SimplifiableIfStatement
- if ( ( wrapped == null ) && ( binaryValue.wrapped != null ) ||
- ( wrapped != null ) && ( binaryValue.wrapped == null ) )
+ if ( wrapped != binaryValue.wrapped )
{
return false;
}
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java Sat Dec 8 15:10:21 2007
@@ -26,7 +26,13 @@
/**
- * Document me!
+ * This interface represent a LDAP entry. An LDAP entry contains :
+ * - A distinguished name (DN)
+ * - A list of attributes
+ *
+ * The available methods on this object are described in this interface.
+ *
+ * This interface is used by the serverEntry and clientEntry interfaces.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
Added: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java?rev=602574&view=auto
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java (added)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Modification.java Sat Dec 8 15:10:21 2007
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.entry;
+
+
+/**
+ * An internal interface for a ModificationItem. The name has been
+ * chosen so that it does not conflict with @see ModificationItem
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface Modification
+{
+ /**
+ * @return the operation
+ */
+ ModificationOperation getOperation();
+
+
+ /**
+ * Store the modification operation
+ *
+ * @param operation The DirContext value to assign
+ */
+ void setOperation( int operation );
+
+
+ /**
+ * Store the modification operation
+ *
+ * @param operation The ModificationOperation value to assign
+ */
+ void setOperation( ModificationOperation operation );
+
+
+ /**
+ * @return the attribute containing the modifications
+ */
+ EntryAttribute<? extends Value<?>> getAttribute();
+
+
+ /**
+ * Set the attribute's modification
+ *
+ * @param attribute The modified attribute
+ */
+ void setAttribute( EntryAttribute<? extends Value<?>> attribute );
+}
Added: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ModificationOperation.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ModificationOperation.java?rev=602574&view=auto
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ModificationOperation.java (added)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ModificationOperation.java Sat Dec 8 15:10:21 2007
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.entry;
+
+/**
+ * An enum storing the different modification operation which can be used
+ * in a Modification. There is a one to one mapping with the DirContext.ADD_ATTRIBUTE,
+ * DirContext.REMOVE_ATTRIBUTE, DirContext.REPLACE_ATTRIBUTE
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public enum ModificationOperation
+{
+ ADD_ATTRIBUTE( 1 ),
+ REPLACE_ATTRIBUTE( 3 ),
+ REMOVE_ATTRIBUTE( 2 );
+
+ /** Internal value */
+ private int value;
+
+
+ /**
+ * Creates a new instance of ModificationOperation.
+ */
+ private ModificationOperation( int value )
+ {
+ this.value = value;
+ }
+
+
+ /**
+ * @return The integer value associated with the element. This value
+ * is equivalent to the one found in DirContext.
+ */
+ public int getValue()
+ {
+ return value;
+ }
+}
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StreamedValue.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StreamedValue.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StreamedValue.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StreamedValue.java Sat Dec 8 15:10:21 2007
@@ -91,6 +91,12 @@
{
return wrapped;
}
+
+
+ public boolean isNull()
+ {
+ return wrapped == null;
+ }
public void set( URI wrapped )
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/StringValue.java Sat Dec 8 15:10:21 2007
@@ -116,6 +116,12 @@
{
return wrapped;
}
+
+
+ public boolean isNull()
+ {
+ return wrapped == null;
+ }
public void set( String wrapped )
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java?rev=602574&r1=602573&r2=602574&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java Sat Dec 8 15:10:21 2007
@@ -43,4 +43,12 @@
* @param wrapped the value to set. Should be either a String, URI, or a byte[]
*/
void set( T wrapped );
+
+ /**
+ * Check if the contained value is null or not
+ *
+ * @return <code>true</code> if the inner value is null.
+ */
+ boolean isNull();
+
}