Commit 1ebff1cf authored by Emmanuel Bourg's avatar Emmanuel Bourg

New upstream version 2.0.0~M24

parent 5f7f5a9e
target/
.project
.classpath
.settings/
.svn/
bin/
# Intellij
*.ipr
*.iml
.idea
out/
.DS_Store
/bootstrap
/dependencies.xml
.java-version
META-INF/
dependency-reduced-pom.xml
ApacheDS
Copyright 2003-2015 The Apache Software Foundation
Copyright 2003-2017 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
......@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-parent</artifactId>
<version>2.0.0-M23</version>
<version>2.0.0-M24</version>
</parent>
<artifactId>apacheds-all</artifactId>
......
......@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-parent</artifactId>
<version>2.0.0-M23</version>
<version>2.0.0-M24</version>
</parent>
<artifactId>apacheds-core-annotations</artifactId>
......
......@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-parent</artifactId>
<version>2.0.0-M23</version>
<version>2.0.0-M24</version>
</parent>
<artifactId>apacheds-core-api</artifactId>
......
......@@ -51,7 +51,7 @@ public enum InterceptorEnum
* The private constructor
* @param methodName The associated interceptor name
*/
private InterceptorEnum( String name )
InterceptorEnum( String name )
{
this.name = name;
}
......
......@@ -395,6 +395,15 @@ public class LdapCoreSessionConnection extends AbstractLdapConnection
}
/**
* {@inheritDoc}
*/
public boolean isRequestCompleted( int messageId )
{
return false;
}
/**
* {@inheritDoc}
*/
......
......@@ -69,7 +69,7 @@ public enum OperationEnum
* The private constructor
* @param methodName The associated method name
*/
private OperationEnum( String methodName )
OperationEnum( String methodName )
{
this.methodName = methodName;
}
......
......@@ -50,7 +50,7 @@ public enum ReferralHandlingMode
* @see Context#REFERRAL
* @param jndiValue the JNDI Context.REFERRAL key's value
*/
private ReferralHandlingMode( String jndiValue )
ReferralHandlingMode( String jndiValue )
{
this.jndiValue = jndiValue;
}
......
......@@ -51,7 +51,7 @@ public enum CheckQualityEnum
/**
* Create a new instance of this enum
*/
private CheckQualityEnum( int value )
CheckQualityEnum( int value )
{
this.value = value;
}
......
......@@ -34,7 +34,7 @@ public enum RevisionOrder
private final boolean ascending;
private RevisionOrder( boolean ascending )
RevisionOrder( boolean ascending )
{
this.ascending = ascending;
}
......
......@@ -48,7 +48,7 @@ public enum EventType
private int mask;
private EventType( int mask )
EventType( int mask )
{
this.mask = mask;
}
......
......@@ -24,6 +24,7 @@ import org.apache.commons.lang.NotImplementedException;
import org.apache.directory.api.ldap.model.constants.AuthenticationLevel;
import org.apache.directory.api.ldap.model.exception.LdapAuthenticationException;
import org.apache.directory.api.ldap.model.message.MessageTypeEnum;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.util.Strings;
import org.apache.directory.server.core.api.CoreSession;
import org.apache.directory.server.core.api.OperationEnum;
......@@ -88,11 +89,11 @@ public class BindOperationContext extends AbstractOperationContext
public AuthenticationLevel getAuthenticationLevel() throws LdapAuthenticationException
{
// First check if the SASL mechanism has been set
if ( ( saslMechanism == null ) )
if ( saslMechanism == null )
{
// No, it's either a SIMPLE, ANONYMOUS, UNAUTHENT or an error
//
if ( dn.isEmpty() )
if ( Dn.isNullOrEmpty( dn ) )
{
if ( Strings.isEmpty( credentials ) )
{
......
......@@ -46,7 +46,7 @@ public interface StoredProcEngine
* <p>
* This method should be called before an attempt to invoke a stored procedure via this Engine.
*/
void setSPUnitEntry( final Entry spUnit );
void setSPUnitEntry( Entry spUnit );
/**
......
......@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-parent</artifactId>
<version>2.0.0-M23</version>
<version>2.0.0-M24</version>
</parent>
<artifactId>apacheds-core-avl</artifactId>
......
......@@ -37,7 +37,7 @@ final class AvlNode<T extends Comparable<T>>
T value = null;
public AvlNode( AvlNode<T> parent, T value )
AvlNode( AvlNode<T> parent, T value )
{
this.parent = parent;
this.value = value;
......
......@@ -36,7 +36,7 @@ final class AvlTreeIterator<T extends Comparable<T>> implements Iterator<T>
private boolean initial = true;
public AvlTreeIterator( AvlNode<T> root )
AvlTreeIterator( AvlNode<T> root )
{
this.root = root;
findNext();
......
......@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-parent</artifactId>
<version>2.0.0-M23</version>
<version>2.0.0-M24</version>
</parent>
<artifactId>apacheds-core-constants</artifactId>
......
......@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-parent</artifactId>
<version>2.0.0-M23</version>
<version>2.0.0-M24</version>
</parent>
<artifactId>apacheds-core-integ</artifactId>
......
......@@ -530,6 +530,54 @@ public class SimpleAuthenticationIT extends AbstractLdapTestUnit
}
@Test
public void testBCRYPT() throws Exception
{
apply( getService(), getUserAddLdif() );
String userDn = "uid=akarasulu,ou=users,ou=system";
LdapConnection connection = getConnectionAs( getService(), userDn, "test" );
// Check that we can get the attributes
Entry entry = connection.lookup( userDn );
assertNotNull( entry );
assertTrue( entry.get( "uid" ).contains( "akarasulu" ) );
// now modify the password for akarasulu : 'secret', encrypted using CRYPT
ModifyRequest modReq = new ModifyRequestImpl();
modReq.setName( new Dn( userDn ) );
// The hash is for 'secret'
modReq.replace( "userPassword", "{crypt}$2a$06$LH2xIb/TZmajuLJGDNuegeeY.SCwkg6YAVLNXTh8n4Xfb1uwmLXg6" );
connection.modify( modReq );
// close and try with old password (should fail)
connection.close();
try
{
connection.bind( userDn, "test" );
fail();
}
catch ( LdapAuthenticationException lae )
{
assertTrue( true );
}
// try again now with new password (should be successful)
connection.bind( userDn, "secret" );
entry = connection.lookup( userDn );
assertNotNull( entry );
assertTrue( entry.get( "uid" ).contains( "akarasulu" ) );
// try again now with new password, to check that the
// cache is updated (should be successfull)
connection.bind( userDn, "secret" );
entry = connection.lookup( userDn );
assertNotNull( entry );
assertTrue( entry.get( "uid" ).contains( "akarasulu" ) );
}
@Test
public void testInvalidateCredentialCacheForUpdatingAnotherUsersPassword() throws Exception
{
......
......@@ -39,6 +39,7 @@ import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException;
import org.apache.directory.api.ldap.model.exception.LdapReferralException;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.util.Strings;
import org.apache.directory.server.constants.ServerDNConstants;
import org.apache.directory.server.core.annotations.ApplyLdifs;
import org.apache.directory.server.core.annotations.CreateDS;
......@@ -213,7 +214,7 @@ public class DeleteReferralIT extends AbstractLdapTestUnit
try
{
session.lookup( dn, new String[]{} );
session.lookup( dn, Strings.EMPTY_STRING_ARRAY );
fail();
}
catch ( LdapNoSuchObjectException lnsoe )
......@@ -277,7 +278,7 @@ public class DeleteReferralIT extends AbstractLdapTestUnit
// We should not find the entry
try
{
session.lookup( dn, new String[]{} );
session.lookup( dn, Strings.EMPTY_STRING_ARRAY );
fail();
}
catch ( LdapNoSuchObjectException lnsoe )
......@@ -337,7 +338,7 @@ public class DeleteReferralIT extends AbstractLdapTestUnit
// We should not find the entry
try
{
session.lookup( dn, new String[]{} );
session.lookup( dn, Strings.EMPTY_STRING_ARRAY );
fail();
}
catch ( LdapNoSuchObjectException lnsoe )
......
......@@ -27,7 +27,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
import javax.naming.NoPermissionException;
import javax.naming.directory.Attribute;
import javax.naming.directory.AttributeInUseException;
......@@ -41,7 +40,7 @@ import javax.naming.directory.ModificationItem;
import javax.naming.directory.SchemaViolationException;
import javax.naming.ldap.LdapContext;
import org.apache.directory.api.util.StringConstants;
import org.apache.directory.api.util.Strings;
import org.apache.directory.server.core.annotations.ApplyLdifs;
import org.apache.directory.server.core.annotations.CreateDS;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
......@@ -355,7 +354,7 @@ public class ModifyAddIT extends AbstractLdapTestUnit
// A valid AT not in MUST or MAY, but the extensibleObject OC is present in the OCs
// The value is empty
Attributes attrs = new BasicAttributes( "crossCertificatePair", StringConstants.EMPTY_BYTES, true );
Attributes attrs = new BasicAttributes( "crossCertificatePair", Strings.EMPTY_BYTES, true );
// Add the Ava
sysRoot.modifyAttributes( "ou=testing01", DirContext.ADD_ATTRIBUTE, attrs );
......@@ -364,7 +363,7 @@ public class ModifyAddIT extends AbstractLdapTestUnit
attrs = sysRoot.getAttributes( "ou=testing01" );
Attribute attr = attrs.get( "crossCertificatePair" );
assertNotNull( attr );
assertTrue( attr.contains( StringConstants.EMPTY_BYTES ) );
assertTrue( attr.contains( Strings.EMPTY_BYTES ) );
assertEquals( 1, attr.size() );
}
......@@ -548,7 +547,7 @@ public class ModifyAddIT extends AbstractLdapTestUnit
// Add the first Ava
sysRoot.modifyAttributes( "ou=testing01", DirContext.ADD_ATTRIBUTE, attrs );
attrs = new BasicAttributes( "crossCertificatePair", StringConstants.EMPTY_BYTES, true );
attrs = new BasicAttributes( "crossCertificatePair", Strings.EMPTY_BYTES, true );
// Add the second Ava
sysRoot.modifyAttributes( "ou=testing01", DirContext.ADD_ATTRIBUTE, attrs );
......@@ -558,7 +557,7 @@ public class ModifyAddIT extends AbstractLdapTestUnit
Attribute attr = attrs.get( "crossCertificatePair" );
assertNotNull( attr );
assertTrue( attr.contains( "12345".getBytes() ) );
assertTrue( attr.contains( StringConstants.EMPTY_BYTES ) );
assertTrue( attr.contains( Strings.EMPTY_BYTES ) );
assertEquals( 2, attr.size() );
}
......
/*
* 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.operations.search;
import java.util.HashSet;
import java.util.Set;
import org.apache.directory.api.ldap.model.cursor.EntryCursor;
import org.apache.directory.api.ldap.model.entry.DefaultEntry;
import org.apache.directory.api.ldap.model.message.SearchScope;
import org.apache.directory.ldap.client.api.LdapConnection;
import org.apache.directory.server.core.annotations.CreateDS;
import org.apache.directory.server.core.api.partition.Partition;
import org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory;
import org.apache.directory.server.core.factory.DirectoryServiceFactory;
import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
import org.apache.directory.server.core.integ.FrameworkRunner;
import org.apache.directory.server.core.integ.IntegrationUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertTrue;
/**
* Tests various search scenarios.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@RunWith(FrameworkRunner.class)
@CreateDS( name = "SearchWithIndicesIT" )
public class SearchWithIndicesPersonIT extends AbstractLdapTestUnit
{
private static LdapConnection connection;
@Before
public void createData() throws Exception
{
connection = IntegrationUtils.getAdminConnection( getService() );
Partition systemPartition = getService().getSystemPartition();
DirectoryServiceFactory dsFactory = DefaultDirectoryServiceFactory.class.newInstance();
dsFactory.getPartitionFactory().addIndex( systemPartition, "cn", 100 );
// Restart the service so that the index is created
getService().shutdown();
getService().startup();
// -------------------------------------------------------------------
// Add a bunch of persons
// -------------------------------------------------------------------
for ( int i = 0; i < 1000; i++ )
{
addPerson( "name" + i, i );
}
}
private void addPerson( String name, int id ) throws Exception
{
connection.add(
new DefaultEntry(
"cn=" + name + ",ou=system",
"objectClass: top",
"objectClass: person",
"cn", name,
"sn", name
) );
}
/**
* Convenience method that performs a one level search using the
* specified filter returning their DNs as Strings in a set.
*
* @param controls the search controls
* @param filter the filter expression
* @return the set of groups
* @throws Exception if there are problems conducting the search
*/
public Set<String> searchPersons( String filter ) throws Exception
{
Set<String> results = new HashSet<String>();
long t0 = System.nanoTime();
EntryCursor cursor = connection.search( "ou=system", filter, SearchScope.SUBTREE, "1.1" );
long t1 = System.nanoTime();
while ( cursor.next() )
{
results.add( cursor.get().getDn().getName() );
}
cursor.close();
return results;
}
@Test
public void testSearch() throws Exception
{
Set<String> results = searchPersons( "(&(cn=name10*)(objectClass=person))" );
Set<String> expected = new HashSet<String>();
expected.add( "cn=name10,ou=system" );
expected.add( "cn=name100,ou=system" );
expected.add( "cn=name101,ou=system" );
expected.add( "cn=name102,ou=system" );
expected.add( "cn=name103,ou=system" );
expected.add( "cn=name104,ou=system" );
expected.add( "cn=name105,ou=system" );
expected.add( "cn=name106,ou=system" );
expected.add( "cn=name107,ou=system" );
expected.add( "cn=name108,ou=system" );
expected.add( "cn=name109,ou=system" );
for ( String person : results )
{
assertTrue( expected.contains( person ) );
expected.remove( person );
}
assertTrue( expected.size() == 0 );
}
}
......@@ -36,8 +36,6 @@ import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import javax.naming.NamingException;
import org.apache.directory.api.ldap.model.entry.Attribute;
import org.apache.directory.api.ldap.model.entry.DefaultAttribute;
import org.apache.directory.api.ldap.model.entry.DefaultEntry;
......
......@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-parent</artifactId>
<version>2.0.0-M23</version>
<version>2.0.0-M24</version>
</parent>
<artifactId>apacheds-core-jndi</artifactId>
......
......@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-parent</artifactId>
<version>2.0.0-M23</version>
<version>2.0.0-M24</version>
</parent>
<artifactId>apacheds-core-shared</artifactId>
......
......@@ -65,7 +65,7 @@ class SortedEntryComparator implements Comparator<Entry>, Serializable
* @param mrOid the OID or name of the matchingrule
* @param reverse flag to indicate the sort order
*/
public SortedEntryComparator( AttributeType at, String mrule, boolean reverse, SchemaManager schemaManager ) throws LdapException
SortedEntryComparator( AttributeType at, String mrule, boolean reverse, SchemaManager schemaManager ) throws LdapException
{
this.type = at;
this.reverse = reverse;
......
......@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-parent</artifactId>
<version>2.0.0-M23</version>
<version>2.0.0-M24</version>
</parent>
<artifactId>apacheds-core</artifactId>
......
......@@ -1305,15 +1305,23 @@ public class DefaultDirectoryService implements DirectoryService
LOG.debug( "--- Destroying the journal " );
journal.destroy();
}
// --------------------------------------------------------------------
// Shutdown the partition
// --------------------------------------------------------------------
LOG.debug( "--- Destroying the nexus" );
partitionNexus.destroy();
// --------------------------------------------------------------------
// Shutdown the interceptors
// --------------------------------------------------------------------
LOG.debug( "--- Destroying the interceptors" );
for ( Interceptor interceptor : interceptors )
{
interceptor.destroy();
}
// --------------------------------------------------------------------
// And shutdown the server
// --------------------------------------------------------------------
......
......@@ -22,7 +22,7 @@
<parent>
<artifactId>apacheds-parent</artifactId>
<groupId>org.apache.directory.server</groupId>
<version>2.0.0-M23</version>
<version>2.0.0-M24</version>
</parent>
<artifactId>apacheds-http-directory-bridge</artifactId>
......
......@@ -24,7 +24,7 @@
<parent>
<artifactId>apacheds-parent</artifactId>
<groupId>org.apache.directory.server</groupId>
<version>2.0.0-M23</version>
<version>2.0.0-M24</version>
</parent>
<artifactId>apacheds-http-integration</artifactId>
......
......@@ -23,10 +23,11 @@ package org.apache.directory.server.integration.http;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.KeyPair;
import java.security.KeyStore;
import java.security.cert.Certificate;
......@@ -55,7 +56,8 @@ import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.xml.XmlConfiguration;import org.slf4j.Logger;
import org.eclipse.jetty.xml.XmlConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -114,7 +116,8 @@ public class HttpServer
if ( confFile != null )
{
jettyConf = new XmlConfiguration( new FileInputStream( confFile ) );
InputStream input = Files.newInputStream( Paths.get( confFile ) );
jettyConf = new XmlConfiguration( input );
LOG.info( "configuring jetty http server from the configuration file {}", confFile );