Skip to content
Permalink
Browse files
o Added the SyncStateValue factory in the list of response factories (it
was missing)
o used SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID instead of
"2.5.13.1"
o Fixed the creation of Intermediate Response : the controls and
LdapResdult are now copied
  • Loading branch information
elecharny committed Jan 1, 2019
1 parent 8c30eec commit c4145424389d21b1c4aaf7ea0742bc2895ec7127
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 24 deletions.
@@ -27,7 +27,9 @@
import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.codec.api.IntermediateOperationFactory;
import org.apache.directory.api.ldap.codec.api.LdapMessageContainerDirect;
import org.apache.directory.api.ldap.model.message.Control;
import org.apache.directory.api.ldap.model.message.IntermediateResponse;
import org.apache.directory.api.ldap.model.message.LdapResult;
import org.apache.directory.api.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -92,7 +94,23 @@ public void action( LdapMessageContainerDirect<IntermediateResponse> container )
{
// Ok, let's create the new operation, which will replace
// the one created during the init phase
container.setMessage( intermediateFactory.newResponse() );
IntermediateResponse newIntermediateResponse = intermediateFactory.newResponse();
newIntermediateResponse.setMessageId( intermediateResponse.getMessageId() );

// Copy the LdapResult
LdapResult ldapResult = intermediateResponse.getLdapResult();
newIntermediateResponse.getLdapResult().setDiagnosticMessage( ldapResult.getDiagnosticMessage() );
newIntermediateResponse.getLdapResult().setMatchedDn( ldapResult.getMatchedDn() );
newIntermediateResponse.getLdapResult().setReferral( ldapResult.getReferral() );
newIntermediateResponse.getLdapResult().setResultCode( ldapResult.getResultCode() );

// Copy the controls
for ( Control control : intermediateResponse.getControls().values() )
{
newIntermediateResponse.addControl( control );
}

container.setMessage( newIntermediateResponse );
container.setIntermediateFactory( intermediateFactory );
}
else
@@ -292,6 +292,7 @@ public static void loadStockControls( Map<String, ControlFactory<?>> requestCont
// SyncStateValue
ControlFactory<SyncStateValue> syncStateValueFactory = new SyncStateValueFactory( apiService );
requestControlFactories.put( syncStateValueFactory.getOid(), syncStateValueFactory );
responseControlFactories.put( syncStateValueFactory.getOid(), syncStateValueFactory );

if ( LOG.isInfoEnabled() )
{
@@ -33,6 +33,7 @@
import java.util.Set;

import org.apache.directory.api.util.FileUtils;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapSchemaException;
import org.apache.directory.api.ldap.model.schema.AttributeType;
@@ -221,7 +222,7 @@ public void testAddAttributeTypeNoSupNoSyntaxNoSuperior() throws Exception
int goidSize = schemaManager.getGlobalOidRegistry().size();

MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
attributeType.setEqualityOid( "2.5.13.1" );
attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setOrderingOid( null );
attributeType.setSubstringOid( null );

@@ -251,7 +252,7 @@ public void testAddAttributeTypeNoSupCollectiveUser() throws Exception
int goidSize = schemaManager.getGlobalOidRegistry().size();

MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
attributeType.setEqualityOid( "2.5.13.1" );
attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setOrderingOid( null );
attributeType.setSubstringOid( null );
attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
@@ -279,7 +280,7 @@ public void testAddAttributeTypeSupCollectiveUser() throws Exception

// Create the collective attribute first
MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
attributeType.setEqualityOid( "2.5.13.1" );
attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setOrderingOid( null );
attributeType.setSubstringOid( null );
attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
@@ -295,7 +296,7 @@ public void testAddAttributeTypeSupCollectiveUser() throws Exception

// Now try to create an AT which is a subtype of teh create collective attribute
MutableAttributeType subType = new MutableAttributeType( "1.1.1" );
subType.setEqualityOid( "2.5.13.1" );
subType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
subType.setOrderingOid( null );
subType.setSubstringOid( null );
subType.setSuperiorOid( "1.1.0" );
@@ -323,7 +324,7 @@ public void testAddAttributeTypeNoSupCollectiveOperational() throws Exception
int goidSize = schemaManager.getGlobalOidRegistry().size();

MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
attributeType.setEqualityOid( "2.5.13.1" );
attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setOrderingOid( null );
attributeType.setSubstringOid( null );
attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
@@ -356,7 +357,7 @@ public void testAddAttributeTypeCollectiveOperationalSigleValue() throws Excepti
int goidSize = schemaManager.getGlobalOidRegistry().size();

MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
attributeType.setEqualityOid( "2.5.13.1" );
attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setOrderingOid( null );
attributeType.setSubstringOid( null );
attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
@@ -390,7 +391,7 @@ public void testAddAttributeTypeNoSupNoUserModificationUserAplication() throws E
int goidSize = schemaManager.getGlobalOidRegistry().size();

MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
attributeType.setEqualityOid( "2.5.13.1" );
attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setOrderingOid( null );
attributeType.setSubstringOid( null );
attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
@@ -423,7 +424,7 @@ public void testAddAttributeTypeNoSupNoUserModificationOpAttr() throws Exception
int goidSize = schemaManager.getGlobalOidRegistry().size();

MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
attributeType.setEqualityOid( "2.5.13.1" );
attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setOrderingOid( null );
attributeType.setSubstringOid( null );
attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
@@ -572,9 +573,9 @@ public void testAddAttributeTypeNoSupValidMR() throws Exception
int goidSize = schemaManager.getGlobalOidRegistry().size();

MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
attributeType.setEqualityOid( "2.5.13.1" );
attributeType.setOrderingOid( "2.5.13.1" );
attributeType.setSubstringOid( "2.5.13.1" );
attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setOrderingOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setSubstringOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
attributeType.setUsage( UsageEnum.USER_APPLICATIONS );

@@ -598,9 +599,9 @@ public void testAddAttributeTypeAlreadyExist() throws Exception
int goidSize = schemaManager.getGlobalOidRegistry().size();

MutableAttributeType attributeType = new MutableAttributeType( "2.5.18.4" );
attributeType.setEqualityOid( "2.5.13.1" );
attributeType.setOrderingOid( "2.5.13.1" );
attributeType.setSubstringOid( "2.5.13.1" );
attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setOrderingOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setSubstringOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );

// It should fail
assertFalse( schemaManager.add( attributeType ) );
@@ -633,9 +634,9 @@ public void testAddAttributeTypeNameAlreadyExist() throws Exception
int goidSize = schemaManager.getGlobalOidRegistry().size();

MutableAttributeType attributeType = new MutableAttributeType( "1.1.1.0" );
attributeType.setEqualityOid( "2.5.13.1" );
attributeType.setOrderingOid( "2.5.13.1" );
attributeType.setSubstringOid( "2.5.13.1" );
attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setOrderingOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setSubstringOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
attributeType.setNames( "Test", "cn" );

@@ -667,9 +668,9 @@ public void testAddAttributeTypeNameOfAnObjectClass() throws Exception
int goidSize = schemaManager.getGlobalOidRegistry().size();

MutableAttributeType attributeType = new MutableAttributeType( "1.1.1.0" );
attributeType.setEqualityOid( "2.5.13.1" );
attributeType.setOrderingOid( "2.5.13.1" );
attributeType.setSubstringOid( "2.5.13.1" );
attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setOrderingOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setSubstringOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
attributeType.setNames( "Test", "referral" );

@@ -719,7 +720,7 @@ public void testAddAttributeTypeSupNoSyntaxNoSuperior() throws Exception
AttributeType result = schemaManager.lookupAttributeTypeRegistry( "1.1.0" );

assertEquals( "1.3.6.1.4.1.1466.115.121.1.12", result.getSyntaxOid() );
assertEquals( "2.5.13.1", result.getEqualityOid() );
assertEquals( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID, result.getEqualityOid() );
assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
assertEquals( goidSize + 1, schemaManager.getGlobalOidRegistry().size() );
}
@@ -31,6 +31,7 @@
import java.util.List;

import org.apache.directory.api.util.FileUtils;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException;
import org.apache.directory.api.ldap.model.schema.AttributeType;
@@ -228,7 +229,7 @@ public void testDeleteNonExistingAttributeType() throws Exception
int goidSize = schemaManager.getGlobalOidRegistry().size();

MutableAttributeType attributeType = new MutableAttributeType( "1.1.0" );
attributeType.setEqualityOid( "2.5.13.1" );
attributeType.setEqualityOid( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
attributeType.setOrderingOid( null );
attributeType.setSubstringOid( null );

@@ -512,7 +513,7 @@ public void testDeleteExistingMatchingRuleUsedByAttributeType() throws Exception
int goidSize = schemaManager.getGlobalOidRegistry().size();

// AT with OID 2.5.18.4 has syntax 1.3.6.1.4.1.1466.115.121.1.12 which is used by MR 2.5.13.1
MatchingRule mr = new MatchingRule( "2.5.13.1" );
MatchingRule mr = new MatchingRule( SchemaConstants.DISTINGUISHED_NAME_MATCH_MR_OID );
assertFalse( schemaManager.delete( mr ) );

assertEquals( mrSize, schemaManager.getMatchingRuleRegistry().size() );

0 comments on commit c414542

Please sign in to comment.