[maven-release-plugin] copy for tag 1.0.0-M22
git-svn-id: https://svn.apache.org/repos/asf/directory/shared/tags/1.0.0-M22@1588441 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/Asn1Decoder.java b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/Asn1Decoder.java
index 5932498..0da2b56 100644
--- a/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/Asn1Decoder.java
+++ b/asn1/ber/src/main/java/org/apache/directory/api/asn1/ber/Asn1Decoder.java
@@ -588,6 +588,7 @@
* </code> otherwise
* @throws DecoderException Thrown if anything went wrong
*/
+ @SuppressWarnings("unchecked")
private boolean treatTLVDoneState( ByteBuffer stream, Asn1Container container ) throws DecoderException
{
if ( IS_DEBUG )
diff --git a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/SearchRequestDsml.java b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/SearchRequestDsml.java
index 9c87ae3..b11ed2e 100644
--- a/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/SearchRequestDsml.java
+++ b/dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/request/SearchRequestDsml.java
@@ -824,4 +824,40 @@
{
return ( SearchRequest ) super.removeControl( control );
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isFollowReferrals()
+ {
+ return getDecorated().isFollowReferrals();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SearchRequest followReferrals()
+ {
+ return getDecorated().followReferrals();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isIgnoreReferrals()
+ {
+ return getDecorated().isIgnoreReferrals();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SearchRequest ignoreReferrals()
+ {
+ return getDecorated().ignoreReferrals();
+ }
}
diff --git a/integ/src/test/java/org/apache/directory/api/ldap/codec/api/StandaloneLdapCodecServiceTest.java b/integ/src/test/java/org/apache/directory/api/ldap/codec/api/StandaloneLdapCodecServiceTest.java
index 57f76ba..49a874b 100644
--- a/integ/src/test/java/org/apache/directory/api/ldap/codec/api/StandaloneLdapCodecServiceTest.java
+++ b/integ/src/test/java/org/apache/directory/api/ldap/codec/api/StandaloneLdapCodecServiceTest.java
@@ -56,8 +56,7 @@
"org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncInfoValueFactory," +
"org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncRequestValueFactory," +
"org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncStateValueFactory," +
- "org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncFactory," +
- "org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncResponseFactory" );
+ "org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncFactory" );
System.setProperty( StandaloneLdapApiService.EXTENDED_OPERATIONS_LIST,
"org.apache.directory.api.ldap.extras.extended.ads_impl.cancel.CancelFactory," +
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
index d81d9d5..ba7b462 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
@@ -117,6 +117,7 @@
import org.apache.directory.api.ldap.model.message.SearchScope;
import org.apache.directory.api.ldap.model.message.UnbindRequest;
import org.apache.directory.api.ldap.model.message.UnbindRequestImpl;
+import org.apache.directory.api.ldap.model.message.controls.ManageDsaITImpl;
import org.apache.directory.api.ldap.model.message.controls.OpaqueControl;
import org.apache.directory.api.ldap.model.message.extended.AddNoDResponse;
import org.apache.directory.api.ldap.model.message.extended.BindNoDResponse;
@@ -1667,6 +1668,12 @@
int newId = messageId.incrementAndGet();
searchRequest.setMessageId( newId );
+
+ if ( searchRequest.isIgnoreReferrals() )
+ {
+ // We want to ignore the referral, inject the ManageDSAIT control in the request
+ searchRequest.addControl( new ManageDsaITImpl() );
+ }
LOG.debug( "Sending request \n{}", searchRequest );
diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java
index 82c252b..a5cde7a 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/SearchCursorImpl.java
@@ -31,6 +31,7 @@
import org.apache.directory.api.ldap.model.cursor.SearchCursor;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.ldap.model.exception.LdapReferralException;
import org.apache.directory.api.ldap.model.message.IntermediateResponse;
import org.apache.directory.api.ldap.model.message.Referral;
import org.apache.directory.api.ldap.model.message.Response;
@@ -365,6 +366,12 @@
{
return ( ( SearchResultEntry ) response ).getEntry();
}
+
+ if ( isReferral() )
+ {
+ Referral referral = ( ( SearchResultReference ) response ).getReferral();
+ throw new LdapReferralException( referral.getLdapUrls() );
+ }
throw new LdapException();
}
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ExtendedRequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ExtendedRequestDecorator.java
index d648fa6..760bdcb 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ExtendedRequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/api/ExtendedRequestDecorator.java
@@ -158,7 +158,6 @@
/**
* {@inheritDoc}
*/
- @SuppressWarnings("unchecked")
public ExtendedRequest addControl( Control control )
{
return ( ExtendedRequest ) super.addControl( control );
@@ -168,7 +167,6 @@
/**
* {@inheritDoc}
*/
- @SuppressWarnings("unchecked")
public ExtendedRequest addAllControls( Control[] controls )
{
return ( ExtendedRequest ) super.addAllControls( controls );
@@ -178,7 +176,6 @@
/**
* {@inheritDoc}
*/
- @SuppressWarnings("unchecked")
public ExtendedRequest removeControl( Control control )
{
return ( ExtendedRequest ) super.removeControl( control );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestGrammar.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestGrammar.java
index 732054e..35b3a9a 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestGrammar.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortRequestGrammar.java
@@ -49,9 +49,10 @@
static final boolean IS_DEBUG = LOG.isDebugEnabled();
/** The instance of grammar. SortRequestGrammar is a singleton */
- private static Grammar<?> instance = new SortRequestGrammar();
+ private static Grammar<SortRequestContainer> instance = new SortRequestGrammar();
+ @SuppressWarnings("unchecked")
private SortRequestGrammar()
{
setName( SortRequestGrammar.class.getName() );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseGrammar.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseGrammar.java
index 96fcfc3..002511c 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseGrammar.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/controls/sort/SortResponseGrammar.java
@@ -46,9 +46,10 @@
static final boolean IS_DEBUG = LOG.isDebugEnabled();
/** The instance of grammar. SortResponseGrammar is a singleton */
- private static Grammar<?> instance = new SortResponseGrammar();
+ private static Grammar<SortResponseContainer> instance = new SortResponseGrammar();
+ @SuppressWarnings("unchecked")
private SortResponseGrammar()
{
setName( SortResponseGrammar.class.getName() );
diff --git a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchRequestDecorator.java b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchRequestDecorator.java
index 2bf5df3..49a8daf 100644
--- a/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchRequestDecorator.java
+++ b/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/SearchRequestDecorator.java
@@ -1127,4 +1127,40 @@
{
return ( SearchRequest ) super.removeControl( control );
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isFollowReferrals()
+ {
+ return getDecorated().isFollowReferrals();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SearchRequest followReferrals()
+ {
+ return getDecorated().followReferrals();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isIgnoreReferrals()
+ {
+ return getDecorated().isIgnoreReferrals();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SearchRequest ignoreReferrals()
+ {
+ return getDecorated().ignoreReferrals();
+ }
}
diff --git a/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java b/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
index 80b065f..671f1df 100644
--- a/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
+++ b/ldap/codec/standalone/src/main/java/org/apache/directory/api/ldap/codec/standalone/CodecFactoryUtil.java
@@ -35,8 +35,6 @@
import org.apache.directory.api.ldap.codec.controls.sort.SortResponseFactory;
import org.apache.directory.api.ldap.extras.controls.ad.AdDirSync;
import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncFactory;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncResponse;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncResponseFactory;
import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicy;
import org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyFactory;
import org.apache.directory.api.ldap.extras.controls.syncrepl.syncDone.SyncDoneValue;
@@ -137,10 +135,6 @@
ControlFactory<AdDirSync> adDirSyncFactory = new AdDirSyncFactory( apiService );
controlFactories.put( adDirSyncFactory.getOid(), adDirSyncFactory );
LOG.info( "Registered pre-bundled control factory: {}", adDirSyncFactory.getOid() );
-
- ControlFactory<AdDirSyncResponse> adDirSyncResponseFactory = new AdDirSyncResponseFactory( apiService );
- controlFactories.put( adDirSyncResponseFactory.getOid(), adDirSyncResponseFactory );
- LOG.info( "Registered pre-bundled control factory: {}", adDirSyncResponseFactory.getOid() );
}
diff --git a/ldap/codec/standalone/src/test/java/org/apache/directory/api/ldap/codec/standalone/AbstractCodecServiceTest.java b/ldap/codec/standalone/src/test/java/org/apache/directory/api/ldap/codec/standalone/AbstractCodecServiceTest.java
index 4b88405..01a71db 100644
--- a/ldap/codec/standalone/src/test/java/org/apache/directory/api/ldap/codec/standalone/AbstractCodecServiceTest.java
+++ b/ldap/codec/standalone/src/test/java/org/apache/directory/api/ldap/codec/standalone/AbstractCodecServiceTest.java
@@ -60,8 +60,7 @@
"org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncInfoValueFactory," +
"org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncRequestValueFactory," +
"org.apache.directory.api.ldap.extras.controls.syncrepl_impl.SyncStateValueFactory," +
- "org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncFactory," +
- "org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncResponseFactory" );
+ "org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncFactory" );
System.setProperty( StandaloneLdapApiService.EXTENDED_OPERATIONS_LIST,
"org.apache.directory.api.ldap.extras.extended.ads_impl.cancel.CancelFactory," +
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSync.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSync.java
index 8b5fb2a..4b1512b 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSync.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSync.java
@@ -33,11 +33,23 @@
* criticality TRUE
* }
*
+ * the control value can be one of the two structures :
+ *
+ * Client side :
* realReplControlValue ::= SEQUENCE {
* parentsFirst integer
* maxReturnLength integer
* cookie OCTET STRING
* }
+ *
+ * or
+ *
+ * server side :
+ * realReplControlValue ::= SEQUENCE {
+ * flag integer
+ * maxReturnLength integer
+ * cookie OCTET STRING
+ * }
* </pre>
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -83,4 +95,22 @@
* for the first control.
*/
void setCookie( byte[] cookie );
+
+
+ /**
+ * @return The flag returned by the server. One of :
+ * <ul>
+ * <li>LDAP_DIRSYNC_OBJECT_SECURITY (0x0001)</li>
+ * <li>LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER (0x0800)</li>
+ * <li>LDAP_DIRSYNC_PUBLIC_DATA_ONLY (0x2000)(</li>
+ * <li>LDAP_DIRSYNC_INCREMENTAL_VALUES (0x7FFFFFFF)</li>
+ * </ul>
+ */
+ AdDirSyncFlag getFlag();
+
+
+ /**
+ * @param flag The flag.
+ */
+ void setFlag( AdDirSyncFlag flag );
}
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java
index bd38200..91b7dd4 100644
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java
+++ b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncImpl.java
@@ -35,6 +35,9 @@
/** A flag used to tell the server to return the parent before the children */
int parentFirst = 1;
+ /** A flag used to indicate that there are more data to return */
+ AdDirSyncFlag flag = AdDirSyncFlag.DEFAULT;
+
/** The maximum number of attributes to return */
int maxReturnLength = 0;
@@ -71,6 +74,24 @@
/**
* {@inheritDoc}
*/
+ public AdDirSyncFlag getFlag()
+ {
+ return flag;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setFlag( AdDirSyncFlag flag )
+ {
+ this.flag = flag;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
public int getMaxReturnLength()
{
return maxReturnLength;
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponse.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponse.java
deleted file mode 100644
index 857286b..0000000
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponse.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.api.ldap.extras.controls.ad;
-
-import org.apache.directory.api.ldap.model.message.Control;
-
-/**
- * The AdDirSyncResponse control has the following value :
- *
- * <pre>
- * Repl Control ::= SEQUENCE {
- * controlType 1.2.840.113556.1.4.841
- * controlValue replControlValue
- * criticality TRUE
- * }
- *
- * realReplControlValue ::= SEQUENCE {
- * flag integer
- * maxReturnLength integer
- * cookie OCTET STRING
- * }
- * </pre>
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public interface AdDirSyncResponse extends Control
-{
- /** This control OID */
- static final String OID = "1.2.840.113556.1.4.841";
-
- /**
- * @return The flag returned by the server. One of :
- * <ul>
- * <li>LDAP_DIRSYNC_OBJECT_SECURITY (0x0001)</li>
- * <li>LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER (0x0800)</li>
- * <li>LDAP_DIRSYNC_PUBLIC_DATA_ONLY (0x2000)(</li>
- * <li>LDAP_DIRSYNC_INCREMENTAL_VALUES (0x7FFFFFFF)</li>
- * </ul>
- */
- AdDirSyncFlag getFlag();
-
-
- /**
- * @param flag The flag.
- */
- void setFlag( AdDirSyncFlag flag );
-
-
- /**
- * @return The maximum length of attributes to be returned
- */
- int getMaxReturnLength();
-
-
- /**
- * @param maxReturnLength The maximum length of attributes to be returned
- */
- void setMaxReturnLength( int maxReturnLength );
-
-
- /**
- * @return The cookie used while processing the successive DirSync operations
- */
- byte[] getCookie();
-
-
- /**
- * @param cookie The cookie to send to the server. It's the value found in the response control. Should be null
- * for the first control.
- */
- void setCookie( byte[] cookie );
-}
diff --git a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseImpl.java b/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseImpl.java
deleted file mode 100644
index fbb6996..0000000
--- a/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseImpl.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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.api.ldap.extras.controls.ad;
-
-import org.apache.directory.api.ldap.model.message.controls.AbstractControl;
-import org.apache.directory.api.util.Strings;
-
-/**
- * The class implementing the AdDirSyncResponse
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class AdDirSyncResponseImpl extends AbstractControl implements AdDirSyncResponse
-{
- /** A flag used to indicate that there are more data to return */
- AdDirSyncFlag flag = AdDirSyncFlag.DEFAULT;
-
- /** The maximum number of attributes to return */
- int maxReturnLength = 0;
-
- /** The DirSync cookie */
- private byte[] cookie;
-
- /**
- * Default constructor for this control
- */
- public AdDirSyncResponseImpl()
- {
- super( OID, Boolean.TRUE );
- }
-
-
- /**
- * {@inheritDoc}
- */
- public AdDirSyncFlag getFlag()
- {
- return flag;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void setFlag( AdDirSyncFlag flag )
- {
- this.flag = flag;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public int getMaxReturnLength()
- {
- return maxReturnLength;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void setMaxReturnLength( int maxReturnLength )
- {
- this.maxReturnLength = maxReturnLength;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public byte[] getCookie()
- {
- return cookie;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void setCookie( byte[] cookie )
- {
- if ( cookie != null )
- {
- this.cookie = new byte[cookie.length];
- System.arraycopy( cookie, 0, this.cookie, 0,cookie.length );
- }
- else
- {
- this.cookie = Strings.EMPTY_BYTES;
- }
- }
-}
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasBundleActivator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasBundleActivator.java
index 7d89001..fb6da06 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasBundleActivator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/ExtrasBundleActivator.java
@@ -24,8 +24,6 @@
import org.apache.directory.api.ldap.codec.api.LdapApiService;
import org.apache.directory.api.ldap.extras.controls.ad.AdDirSync;
import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncFactory;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncResponse;
-import org.apache.directory.api.ldap.extras.controls.ad.AdDirSyncResponseFactory;
import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicy;
import org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyFactory;
import org.apache.directory.api.ldap.extras.controls.syncrepl.syncDone.SyncDoneValue;
@@ -104,9 +102,6 @@
ControlFactory<AdDirSync> adDirSyncFactory = new AdDirSyncFactory( codec );
codec.registerControl( adDirSyncFactory );
-
- ControlFactory<AdDirSyncResponse> adDirSyncResponseFactory = new AdDirSyncResponseFactory( codec );
- codec.registerControl( adDirSyncResponseFactory );
}
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncDecorator.java
index 04feaa3..0351ec0 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncDecorator.java
@@ -66,10 +66,92 @@
{
super( codec, control );
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getParentFirst()
+ {
+ return getDecorated().getParentFirst();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setParentFirst( int parentFirst )
+ {
+ getDecorated().setParentFirst( parentFirst );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public AdDirSyncFlag getFlag()
+ {
+ return getDecorated().getFlag();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setFlag( AdDirSyncFlag flag )
+ {
+ getDecorated().setFlag( flag );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getMaxReturnLength()
+ {
+ return getDecorated().getMaxReturnLength();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setMaxReturnLength( int maxReturnLength )
+ {
+ getDecorated().setMaxReturnLength( maxReturnLength );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte[] getCookie()
+ {
+ return getDecorated().getCookie();
+ }
/**
- * Compute the AdDirSync length.
+ * {@inheritDoc}
+ */
+ public void setCookie( byte[] cookie )
+ {
+ // Copy the bytes
+ if ( !Strings.isEmpty( cookie ) )
+ {
+ byte[] copy = new byte[cookie.length];
+ System.arraycopy( cookie, 0, copy, 0, cookie.length );
+ getDecorated().setCookie( copy );
+ }
+ else
+ {
+ getDecorated().setCookie( null );
+ }
+ }
+
+
+ /**
+ * Compute the AdDirSync length. We use the client side control.
* 0x30 L1
* |
* +--> 0x02 0x0(1-4) nnn (parentFirst)
@@ -105,7 +187,7 @@
/**
- * Encode the AdDirSync control
+ * Encode the AdDirSync control. We use the client side control.
*
* @param buffer The encoded sink
* @return A ByteBuffer that contains the encoded PDU
@@ -177,70 +259,6 @@
/**
* {@inheritDoc}
*/
- public int getParentFirst()
- {
- return getDecorated().getParentFirst();
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void setParentFirst( int parentFirst )
- {
- getDecorated().setParentFirst( parentFirst );
- }
-
-
- /**
- * {@inheritDoc}
- */
- public int getMaxReturnLength()
- {
- return getDecorated().getMaxReturnLength();
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void setMaxReturnLength( int maxReturnLength )
- {
- getDecorated().setMaxReturnLength( maxReturnLength );
- }
-
-
- /**
- * {@inheritDoc}
- */
- public byte[] getCookie()
- {
- return getDecorated().getCookie();
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void setCookie( byte[] cookie )
- {
- // Copy the bytes
- if ( !Strings.isEmpty( cookie ) )
- {
- byte[] copy = new byte[cookie.length];
- System.arraycopy( cookie, 0, copy, 0, cookie.length );
- getDecorated().setCookie( copy );
- }
- else
- {
- getDecorated().setCookie( null );
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
public Asn1Object decode( byte[] controlBytes ) throws DecoderException
{
ByteBuffer bb = ByteBuffer.wrap( controlBytes );
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncGrammar.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncGrammar.java
index e6bbd30..b9d7e7c 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncGrammar.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncGrammar.java
@@ -36,16 +36,16 @@
/**
*
- * Implementation of AdDirSync Control. All the actions are declared in
+ * Implementation of AdDirSync Response Control. All the actions are declared in
* this class. As it is a singleton, these declaration are only done once.
*
* The decoded grammar is as follows :
*
* <pre>
* realReplControlValue ::= SEQUENCE {
- * parentsFirst integer
+ * flag integer
* maxReturnLength integer
- * cookie OCTET STRING
+ * cookie OCTET STRING
* }
* </pre>
*
@@ -81,9 +81,10 @@
* AdDirSync ::= SEQUENCE {
* ...
*
- * Initialize the adSyncDir object
+ * Initialize the adDirSync object
*/
- super.transitions[AdDirSyncStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition<AdDirSyncContainer>(
+ super.transitions[AdDirSyncStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
+ new GrammarTransition<AdDirSyncContainer>(
AdDirSyncStatesEnum.START_STATE, AdDirSyncStatesEnum.AD_DIR_SYNC_SEQUENCE_STATE,
UniversalTag.SEQUENCE.getValue(),
new GrammarAction<AdDirSyncContainer>( "Initialization" )
@@ -95,16 +96,16 @@
/**
- * transition from start to parentFirst
+ * transition from start to flag
* realReplControlValue ::= SEQUENCE {
- * parentsFirst integer
+ * flag integer
* ....
* }
*/
super.transitions[AdDirSyncStatesEnum.AD_DIR_SYNC_SEQUENCE_STATE.ordinal()][UniversalTag.INTEGER
.getValue()] =
new GrammarTransition<AdDirSyncContainer>( AdDirSyncStatesEnum.AD_DIR_SYNC_SEQUENCE_STATE,
- AdDirSyncStatesEnum.PARENT_FIRST_STATE, UniversalTag.INTEGER.getValue(),
+ AdDirSyncStatesEnum.FLAG_STATE, UniversalTag.INTEGER.getValue(),
new GrammarAction<AdDirSyncContainer>( "Set AdDirSyncControl parentFirst" )
{
public void action( AdDirSyncContainer container ) throws DecoderException
@@ -113,18 +114,27 @@
try
{
- int parentFirst = IntegerDecoder.parse( value );
+ int flagValue = IntegerDecoder.parse( value );
+
+ AdDirSyncFlag flag = AdDirSyncFlag.getFlag( flagValue );
+
+ if ( flag == null )
+ {
+ String msg = "Error while decoding the AdDirSync flag, unknown value : " + flagValue;
+ LOG.error( msg );
+ throw new DecoderException( msg );
+ }
if ( IS_DEBUG )
{
- LOG.debug( "parentFirst = {}", parentFirst );
+ LOG.debug( "flag = {}", flagValue );
}
- container.getAdDirSyncControl().setParentFirst( parentFirst );
+ container.getAdDirSyncControl().setFlag( flag );
}
catch ( IntegerDecoderException ide )
{
- String msg = "Error while decoding the AdDirSync parentFirst : " + ide.getMessage();
+ String msg = "Error while decoding the AdDirSync flag : " + ide.getMessage();
LOG.error( msg, ide );
throw new DecoderException( msg );
}
@@ -133,16 +143,16 @@
/**
- * transition from parentFirst to maxReturnLength
+ * transition from flag to maxReturnLength
* realReplControlValue ::= SEQUENCE {
- * parentsFirst integer
+ * flag integer
* maxReturnLength integer
* ....
* }
*/
- super.transitions[AdDirSyncStatesEnum.PARENT_FIRST_STATE.ordinal()][UniversalTag.INTEGER
+ super.transitions[AdDirSyncStatesEnum.FLAG_STATE.ordinal()][UniversalTag.INTEGER
.getValue()] =
- new GrammarTransition<AdDirSyncContainer>( AdDirSyncStatesEnum.PARENT_FIRST_STATE,
+ new GrammarTransition<AdDirSyncContainer>( AdDirSyncStatesEnum.FLAG_STATE,
AdDirSyncStatesEnum.MAX_RETURN_LENGTH_STATE, UniversalTag.INTEGER.getValue(),
new GrammarAction<AdDirSyncContainer>( "Set AdDirSyncControl maxReturnLength" )
{
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseContainer.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseContainer.java
deleted file mode 100644
index dc8fae3..0000000
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseContainer.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.api.ldap.extras.controls.ad;
-
-
-import org.apache.directory.api.asn1.ber.AbstractContainer;
-import org.apache.directory.api.ldap.codec.api.LdapApiService;
-
-
-/**
- *
- * ASN.1 container for AD DirSyncResponse control.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class AdDirSyncResponseContainer extends AbstractContainer
-{
- /** adDirSync */
- private AdDirSyncResponse control;
-
- private LdapApiService codec;
-
-
- /**
- *
- * Creates a new AdDirSyncResponseControl Container object.
- *
- */
- public AdDirSyncResponseContainer( LdapApiService codec )
- {
- super();
- this.codec = codec;
- this.control = new AdDirSyncResponseDecorator( codec );
- grammar = AdDirSyncResponseGrammar.getInstance();
- setTransition( AdDirSyncResponseStatesEnum.START_STATE );
- }
-
-
- /**
- *
- * Creates a new AdDirSyncResponseControl object.
- *
- */
- public AdDirSyncResponseContainer( LdapApiService codec, AdDirSyncResponse control )
- {
- super();
- this.codec = codec;
- this.control = control;
- grammar = AdDirSyncResponseGrammar.getInstance();
- setTransition( AdDirSyncResponseStatesEnum.START_STATE );
- }
-
-
- /**
- * @return the AdDirSyncResponseControlCodec object
- */
- public AdDirSyncResponse getAdDirSyncResponseControl()
- {
- return control;
- }
-
-
- /**
- * Set a AdDirSyncResponseControlCodec Object into the container. It will be completed
- * by the ldapDecoder.
- *
- * @param control the AdDirSyncResponseControlCodec to set.
- */
- public void setAdDirSyncControl( AdDirSyncResponse control )
- {
- this.control = control;
- }
-
-
- public LdapApiService getCodecService()
- {
- return codec;
- }
-
-
- /**
- * clean the container
- */
- @Override
- public void clean()
- {
- super.clean();
- control = null;
- }
-}
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseDecorator.java
deleted file mode 100644
index 4a9351c..0000000
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseDecorator.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * 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.api.ldap.extras.controls.ad;
-
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.Asn1Object;
-import org.apache.directory.api.asn1.DecoderException;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.asn1.ber.Asn1Decoder;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.TLV;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.i18n.I18n;
-import org.apache.directory.api.ldap.codec.api.ControlDecorator;
-import org.apache.directory.api.ldap.codec.api.LdapApiService;
-import org.apache.directory.api.util.Strings;
-
-/**
- * A decorator around AdDirSyncResponse control. It will encode and decode this control.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class AdDirSyncResponseDecorator extends ControlDecorator<AdDirSyncResponse> implements AdDirSyncResponse
-{
- /** The global length for this control */
- private int adDirSyncResponseLength;
-
- /** An instance of this decoder */
- private static final Asn1Decoder decoder = new Asn1Decoder();
-
-
- /**
- * Creates a new instance of AdDirSyncResponseControlCodec.
- */
- public AdDirSyncResponseDecorator( LdapApiService codec )
- {
- super( codec, new AdDirSyncResponseImpl() );
- }
-
-
- /**
- * Creates a new instance of AdDirSyncResponseDecorator.
- *
- * @param codec The LDAP codec
- * @param control The control to be decorated
- */
- public AdDirSyncResponseDecorator( LdapApiService codec, AdDirSyncResponse control )
- {
- super( codec, control );
- }
-
-
- /**
- * Compute the AdDirSyncResponse length.
- * 0x30 L1
- * |
- * +--> 0x02 0x0(1-4) nnn (Flag)
- * +--> 0x02 0x0(1-4) nnn (maxReturnLength)
- * +--> 0x04 L2 xkcd!!!... (cookie)
- */
- @Override
- public int computeLength()
- {
- // the parentFirst flag length
- int flagValue = getFlag().getValue();
- adDirSyncResponseLength = 1 + TLV.getNbBytes( flagValue ) + BerValue.getNbBytes( flagValue );
-
- // the maxReturnLength length
- adDirSyncResponseLength += 1 + TLV.getNbBytes( getMaxReturnLength() ) + BerValue.getNbBytes( getMaxReturnLength() );
-
- // cookie's length
- byte[] cookie = getCookie();
-
- if ( cookie == null )
- {
- adDirSyncResponseLength += 1 + 1;
- }
- else
- {
- adDirSyncResponseLength += 1 + TLV.getNbBytes( cookie.length ) + cookie.length;
- }
-
- valueLength = 1 + TLV.getNbBytes( adDirSyncResponseLength ) + adDirSyncResponseLength;
-
- // Call the super class to compute the global control length
- return valueLength;
- }
-
-
- /**
- * Encode the AdDirSyncResponse control
- *
- * @param buffer The encoded sink
- * @return A ByteBuffer that contains the encoded PDU
- * @throws EncoderException If anything goes wrong while encoding.
- */
- @Override
- public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
- {
- if ( buffer == null )
- {
- throw new EncoderException( I18n.err( I18n.ERR_04023 ) );
- }
-
- // Encode the SEQ
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( adDirSyncResponseLength ) );
-
- // Encode the ParentFirst flag
- BerValue.encode( buffer, getFlag().getValue() );
-
- // Encode the MaxReturnLength
- BerValue.encode( buffer, getMaxReturnLength() );
-
- // Encode the cookie
- BerValue.encode( buffer, getCookie() );
-
- return buffer;
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public byte[] getValue()
- {
- if ( value == null )
- {
- try
- {
- computeLength();
- ByteBuffer buffer = ByteBuffer.allocate( valueLength );
-
- // Encode the SEQ
- buffer.put( UniversalTag.SEQUENCE.getValue() );
- buffer.put( TLV.getBytes( adDirSyncResponseLength ) );
-
- // Encode the ParentFirst flag
- BerValue.encode( buffer, getFlag().getValue() );
-
- // Encode the MaxReturnLength
- BerValue.encode( buffer, getMaxReturnLength() );
-
- // Encode the cookie
- BerValue.encode( buffer, getCookie() );
-
- value = buffer.array();
- }
- catch ( Exception e )
- {
- return null;
- }
- }
-
- return value;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public AdDirSyncFlag getFlag()
- {
- return getDecorated().getFlag();
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void setFlag( AdDirSyncFlag flag )
- {
- getDecorated().setFlag( flag );
- }
-
-
- /**
- * {@inheritDoc}
- */
- public int getMaxReturnLength()
- {
- return getDecorated().getMaxReturnLength();
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void setMaxReturnLength( int maxReturnLength )
- {
- getDecorated().setMaxReturnLength( maxReturnLength );
- }
-
-
- /**
- * {@inheritDoc}
- */
- public byte[] getCookie()
- {
- return getDecorated().getCookie();
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void setCookie( byte[] cookie )
- {
- // Copy the bytes
- if ( !Strings.isEmpty( cookie ) )
- {
- byte[] copy = new byte[cookie.length];
- System.arraycopy( cookie, 0, copy, 0, cookie.length );
- getDecorated().setCookie( copy );
- }
- else
- {
- getDecorated().setCookie( null );
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- public Asn1Object decode( byte[] controlBytes ) throws DecoderException
- {
- ByteBuffer bb = ByteBuffer.wrap( controlBytes );
- AdDirSyncResponseContainer container = new AdDirSyncResponseContainer( getCodecService(), this );
- decoder.decode( bb, container );
- return this;
- }
-}
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseFactory.java
deleted file mode 100644
index 2f70449..0000000
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseFactory.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.api.ldap.extras.controls.ad;
-
-
-import org.apache.directory.api.ldap.codec.api.CodecControl;
-import org.apache.directory.api.ldap.codec.api.ControlFactory;
-import org.apache.directory.api.ldap.codec.api.LdapApiService;
-
-
-/**
- * A {@link ControlFactory} which creates {@link AdDirSync} controls.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev$, $Date$
- */
-public class AdDirSyncResponseFactory implements ControlFactory<AdDirSyncResponse>
-{
- /** The codec for this factory */
- private LdapApiService codec;
-
-
- /**
- * Creates a new instance of AdDirSyncResponseFactory.
- *
- * @param codec The codec for this factory.
- */
- public AdDirSyncResponseFactory( LdapApiService codec )
- {
- this.codec = codec;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public String getOid()
- {
- return AdDirSyncResponse.OID;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public CodecControl<AdDirSyncResponse> newCodecControl()
- {
- return new AdDirSyncResponseDecorator( codec );
- }
-
-
- /**
- * {@inheritDoc}
- */
- public CodecControl<AdDirSyncResponse> newCodecControl( AdDirSyncResponse control )
- {
- return new AdDirSyncResponseDecorator( codec, control );
- }
-}
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseGrammar.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseGrammar.java
deleted file mode 100644
index e38e2e0..0000000
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseGrammar.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * 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.api.ldap.extras.controls.ad;
-
-
-import org.apache.directory.api.asn1.DecoderException;
-import org.apache.directory.api.asn1.ber.grammar.AbstractGrammar;
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
-import org.apache.directory.api.asn1.ber.grammar.GrammarAction;
-import org.apache.directory.api.asn1.ber.grammar.GrammarTransition;
-import org.apache.directory.api.asn1.ber.tlv.BerValue;
-import org.apache.directory.api.asn1.ber.tlv.IntegerDecoder;
-import org.apache.directory.api.asn1.ber.tlv.IntegerDecoderException;
-import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
-import org.apache.directory.api.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- *
- * Implementation of AdDirSyncResponse Control. All the actions are declared in
- * this class. As it is a singleton, these declaration are only done once.
- *
- * The decoded grammar is as follows :
- *
- * <pre>
- * realReplControlValue ::= SEQUENCE {
- * flag integer
- * maxReturnLength integer
- * cookie OCTET STRING
- * }
- * </pre>
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public final class AdDirSyncResponseGrammar extends AbstractGrammar<AdDirSyncResponseContainer>
-{
-
- /** the logger */
- private static final Logger LOG = LoggerFactory.getLogger( AdDirSyncResponseGrammar.class );
-
- /** speedup for logger */
- private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
- /** AdDirSyncControlGrammar singleton instance */
- private static final AdDirSyncResponseGrammar INSTANCE = new AdDirSyncResponseGrammar();
-
-
- /**
- *
- * Creates a new instance of AdDirSyncResponseControlGrammar.
- *
- */
- @SuppressWarnings("unchecked")
- private AdDirSyncResponseGrammar()
- {
- setName( AdDirSyncResponseGrammar.class.getName() );
-
- super.transitions = new GrammarTransition[AdDirSyncResponseStatesEnum.LAST_AD_DIR_SYNC_RESPONSE_STATE.ordinal()][256];
-
- /**
- * Transition from initial state to AdDirSyncResponse sequence
- * AdDirSyncResponse ::= SEQUENCE {
- * ...
- *
- * Initialize the adDirSyncResponse object
- */
- super.transitions[AdDirSyncResponseStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
- new GrammarTransition<AdDirSyncResponseContainer>(
- AdDirSyncResponseStatesEnum.START_STATE, AdDirSyncResponseStatesEnum.AD_DIR_SYNC_RESPONSE_SEQUENCE_STATE,
- UniversalTag.SEQUENCE.getValue(),
- new GrammarAction<AdDirSyncResponseContainer>( "Initialization" )
- {
- public void action( AdDirSyncResponseContainer container ) throws DecoderException
- {
- }
- } );
-
-
- /**
- * transition from start to flag
- * realReplControlValue ::= SEQUENCE {
- * flag integer
- * ....
- * }
- */
- super.transitions[AdDirSyncResponseStatesEnum.AD_DIR_SYNC_RESPONSE_SEQUENCE_STATE.ordinal()][UniversalTag.INTEGER
- .getValue()] =
- new GrammarTransition<AdDirSyncResponseContainer>( AdDirSyncResponseStatesEnum.AD_DIR_SYNC_RESPONSE_SEQUENCE_STATE,
- AdDirSyncResponseStatesEnum.FLAG_STATE, UniversalTag.INTEGER.getValue(),
- new GrammarAction<AdDirSyncResponseContainer>( "Set AdDirSyncResponseControl parentFirst" )
- {
- public void action( AdDirSyncResponseContainer container ) throws DecoderException
- {
- BerValue value = container.getCurrentTLV().getValue();
-
- try
- {
- int flagValue = IntegerDecoder.parse( value );
-
- AdDirSyncFlag flag = AdDirSyncFlag.getFlag( flagValue );
-
- if ( flag == null )
- {
- String msg = "Error while decoding the AdDirSync flag, unknown value : " + flagValue;
- LOG.error( msg );
- throw new DecoderException( msg );
- }
-
- if ( IS_DEBUG )
- {
- LOG.debug( "flag = {}", flagValue );
- }
-
- container.getAdDirSyncResponseControl().setFlag( flag );
- }
- catch ( IntegerDecoderException ide )
- {
- String msg = "Error while decoding the AdDirSyncResponse flag : " + ide.getMessage();
- LOG.error( msg, ide );
- throw new DecoderException( msg );
- }
- }
- } );
-
-
- /**
- * transition from flag to maxReturnLength
- * realReplControlValue ::= SEQUENCE {
- * flag integer
- * maxReturnLength integer
- * ....
- * }
- */
- super.transitions[AdDirSyncResponseStatesEnum.FLAG_STATE.ordinal()][UniversalTag.INTEGER
- .getValue()] =
- new GrammarTransition<AdDirSyncResponseContainer>( AdDirSyncResponseStatesEnum.FLAG_STATE,
- AdDirSyncResponseStatesEnum.MAX_RETURN_LENGTH_STATE, UniversalTag.INTEGER.getValue(),
- new GrammarAction<AdDirSyncResponseContainer>( "Set AdDirSyncResponseControl maxReturnLength" )
- {
- public void action( AdDirSyncResponseContainer container ) throws DecoderException
- {
- BerValue value = container.getCurrentTLV().getValue();
-
- try
- {
- int maxReturnLength = IntegerDecoder.parse( value );
-
- if ( IS_DEBUG )
- {
- LOG.debug( "maxReturnLength = {}", maxReturnLength );
- }
-
- container.getAdDirSyncResponseControl().setMaxReturnLength( maxReturnLength );
- }
- catch ( IntegerDecoderException ide )
- {
- String msg = "Error while decoding the AdDirSyncResponse maxReturnLength : " + ide.getMessage();
- LOG.error( msg, ide );
- throw new DecoderException( msg );
- }
- }
- } );
-
-
- /**
- * transition from maxReturnLength to cookie
- * ...
- * maxReturnLength integer
- * cookie OCTET STRING
- * }
- */
- super.transitions[AdDirSyncResponseStatesEnum.MAX_RETURN_LENGTH_STATE.ordinal()][UniversalTag.OCTET_STRING
- .getValue()] =
- new GrammarTransition<AdDirSyncResponseContainer>( AdDirSyncResponseStatesEnum.MAX_RETURN_LENGTH_STATE,
- AdDirSyncResponseStatesEnum.COOKIE_STATE, UniversalTag.OCTET_STRING.getValue(),
- new GrammarAction<AdDirSyncResponseContainer>( "Set AdDirSyncResponseControl cookie" )
- {
- public void action( AdDirSyncResponseContainer container ) throws DecoderException
- {
- BerValue value = container.getCurrentTLV().getValue();
-
- byte[] cookie = value.getData();
-
- if ( IS_DEBUG )
- {
- LOG.debug( "cookie = {}", Strings.dumpBytes( cookie ) );
- }
-
- container.getAdDirSyncResponseControl().setCookie( cookie );
-
- container.setGrammarEndAllowed( true );
- }
- } );
- }
-
-
- /**
- * @return the singleton instance of the AdDirSyncResponseControlGrammar
- */
- public static Grammar<AdDirSyncResponseContainer> getInstance()
- {
- return INSTANCE;
- }
-}
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseStatesEnum.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseStatesEnum.java
deleted file mode 100644
index 01b349a..0000000
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseStatesEnum.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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.api.ldap.extras.controls.ad;
-
-
-import org.apache.directory.api.asn1.ber.grammar.Grammar;
-import org.apache.directory.api.asn1.ber.grammar.States;
-
-
-/**
- * ASN.1 grammar constants of AdDirSyncResponse Control.
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public enum AdDirSyncResponseStatesEnum implements States
-{
-
- /** The END_STATE */
- END_STATE,
-
- /***/
- START_STATE,
-
- /** sequence start state */
- AD_DIR_SYNC_RESPONSE_SEQUENCE_STATE,
-
- /** flag state */
- FLAG_STATE,
-
- /** maxReturnLength value state */
- MAX_RETURN_LENGTH_STATE,
-
- /** cookie value state */
- COOKIE_STATE,
-
- /** terminal state */
- LAST_AD_DIR_SYNC_RESPONSE_STATE;
-
- /**
- * Get the grammar name
- *
- * @param grammar The grammar code
- * @return The grammar name
- */
- public String getGrammarName( int grammar )
- {
- return "AD_DIR_SYNC_RESPONSE_GRAMMAR";
- }
-
-
- /**
- * Get the grammar name
- *
- * @param grammar The grammar class
- * @return The grammar name
- */
- public String getGrammarName( Grammar<AdDirSyncResponseContainer> grammar )
- {
- if ( grammar instanceof AdDirSyncResponseGrammar )
- {
- return "AD_DIR_SYNC_RESPONSE_GRAMMAR";
- }
-
- return "UNKNOWN GRAMMAR";
- }
-
-
- /**
- * Get the string representing the state
- *
- * @param state The state number
- * @return The String representing the state
- */
- public String getState( int state )
- {
- return ( ( state == END_STATE.ordinal() ) ? "AD_DIR_SYNC_RESPONSE_GRAMMAR" : this.name() );
- }
-
-
- /**
- * {@inheritDoc}
- */
- public boolean isEndState()
- {
- return this == END_STATE;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public AdDirSyncResponseStatesEnum getStartState()
- {
- return START_STATE;
- }
-}
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncStatesEnum.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncStatesEnum.java
index 218b0ae..90d2a49 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncStatesEnum.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncStatesEnum.java
@@ -41,8 +41,8 @@
/** sequence start state */
AD_DIR_SYNC_SEQUENCE_STATE,
- /** parentFirst value state */
- PARENT_FIRST_STATE,
+ /** flag state */
+ FLAG_STATE,
/** maxReturnLength value state */
MAX_RETURN_LENGTH_STATE,
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyFactory.java
index f0e43fd..aa640eb 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/pwdModify/PasswordModifyFactory.java
@@ -124,6 +124,7 @@
}
// It's an opaque extended operation
+ @SuppressWarnings("unchecked")
ExtendedResponseDecorator<ExtendedResponse> response = ( ExtendedResponseDecorator<ExtendedResponse> ) decoratedResponse;
// Decode the response, as it's an opaque operation
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsFactory.java
index e14cfa9..552b406 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsFactory.java
@@ -116,6 +116,7 @@
}
// It's an opaque extended operation
+ @SuppressWarnings("unchecked")
ExtendedResponseDecorator<ExtendedResponse> response = ( ExtendedResponseDecorator<ExtendedResponse> ) decoratedResponse;
// Decode the response, as it's an opaque operation
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsResponseDecorator.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsResponseDecorator.java
index 472bf88..cbfa80f 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsResponseDecorator.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/startTls/StartTlsResponseDecorator.java
@@ -33,12 +33,9 @@
*/
public class StartTlsResponseDecorator extends ExtendedResponseDecorator<StartTlsResponse> implements StartTlsResponse
{
- private StartTlsResponse startTlsResponse;
-
public StartTlsResponseDecorator( LdapApiService codec, StartTlsResponse decoratedMessage )
{
super( codec, decoratedMessage );
- startTlsResponse = decoratedMessage;
}
diff --git a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIFactory.java b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIFactory.java
index 889550d..fdb26f7 100644
--- a/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIFactory.java
+++ b/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIFactory.java
@@ -122,6 +122,7 @@
}
// It's an opaque extended operation
+ @SuppressWarnings("unchecked")
ExtendedResponseDecorator<ExtendedResponse> response = ( ExtendedResponseDecorator<ExtendedResponse> ) decoratedResponse;
// Decode the response, as it's an opaque operation
diff --git a/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncControlTest.java b/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncControlTest.java
index 086486e..96ae4a7 100644
--- a/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncControlTest.java
+++ b/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncControlTest.java
@@ -54,7 +54,7 @@
bb.put( new byte[]
{
0x30, 0x0C,
- 0x02, 0x01, 0x00, // parentFirst (false)
+ 0x02, 0x01, 0x01, // flag (LDAP_DIRSYNC_OBJECT_SECURITY)
0x02, 0x01, 0x00, // maxReturnLength (no limit)
0x04, 0x04, 'x', 'k', 'c', 'd' // the cookie
} );
@@ -65,16 +65,18 @@
AdDirSync adDirSync = ( AdDirSync ) ( ( AdDirSyncDecorator ) decorator ).decode( bb.array() );
- assertEquals( 0, adDirSync.getParentFirst() );
+ assertEquals( AdDirSyncFlag.LDAP_DIRSYNC_OBJECT_SECURITY, adDirSync.getFlag() );
assertEquals( 0, adDirSync.getMaxReturnLength() );
assertEquals( "xkcd", Strings.utf8ToString( adDirSync.getCookie() ) );
// test encoding
+ adDirSync.setParentFirst( 1 );
+
try
{
ByteBuffer buffer = ( ( AdDirSyncDecorator ) adDirSync ).encode( ByteBuffer
.allocate( ( ( AdDirSyncDecorator ) adDirSync ).computeLength() ) );
- String expected = Strings.dumpBytes( bb.array() );
+ String expected = "0x30 0x0C 0x02 0x01 0x01 0x02 0x01 0x00 0x04 0x04 0x78 0x6B 0x63 0x64 ";
String decoded = Strings.dumpBytes( buffer.array() );
assertEquals( expected, decoded );
}
@@ -93,7 +95,7 @@
bb.put( new byte[]
{
0x30, 0x08,
- 0x02, 0x01, 0x00, // parentFirst (false)
+ 0x02, 0x01, 0x01, // flag (LDAP_DIRSYNC_OBJECT_SECURITY)
0x02, 0x01, 0x00, // maxReturnLength (no limit)
0x04, 0x00 // the cookie
} );
@@ -104,16 +106,18 @@
AdDirSync adDirSync = ( AdDirSync ) ( ( AdDirSyncDecorator ) decorator ).decode( bb.array() );
- assertEquals( 0, adDirSync.getParentFirst() );
+ assertEquals( AdDirSyncFlag.LDAP_DIRSYNC_OBJECT_SECURITY, adDirSync.getFlag() );
assertEquals( 0, adDirSync.getMaxReturnLength() );
assertEquals( "", Strings.utf8ToString( adDirSync.getCookie() ) );
// test encoding
+ adDirSync.setParentFirst( 1 );
+
try
{
ByteBuffer buffer = ( ( AdDirSyncDecorator ) adDirSync ).encode( ByteBuffer
.allocate( ( ( AdDirSyncDecorator ) adDirSync ).computeLength() ) );
- String expected = Strings.dumpBytes( bb.array() );
+ String expected = "0x30 0x08 0x02 0x01 0x01 0x02 0x01 0x00 0x04 0x00 ";
String decoded = Strings.dumpBytes( buffer.array() );
assertEquals( expected, decoded );
}
diff --git a/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseControlTest.java b/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseControlTest.java
deleted file mode 100644
index b0e7480..0000000
--- a/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/controls/ad/AdDirSyncResponseControlTest.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * 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.api.ldap.extras.controls.ad;
-
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.nio.ByteBuffer;
-
-import org.apache.directory.api.asn1.DecoderException;
-import org.apache.directory.api.asn1.EncoderException;
-import org.apache.directory.api.ldap.extras.AbstractCodecServiceTest;
-import org.apache.directory.api.util.Strings;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
-
-
-/**
- *
- * TestCase for AdDirSyncResponseControlCodec .
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-@RunWith(ConcurrentJunitRunner.class)
-@Concurrency()
-public class AdDirSyncResponseControlTest extends AbstractCodecServiceTest
-{
- @Test
- public void testAdDirSyncResponseControl() throws Exception
- {
- ByteBuffer bb = ByteBuffer.allocate( 0x0E );
-
- bb.put( new byte[]
- {
- 0x30, 0x0C,
- 0x02, 0x01, 0x01, // flag (LDAP_DIRSYNC_OBJECT_SECURITY)
- 0x02, 0x01, 0x00, // maxReturnLength (no limit)
- 0x04, 0x04, 'x', 'k', 'c', 'd' // the cookie
- } );
-
- bb.flip();
-
- AdDirSyncResponse decorator = new AdDirSyncResponseDecorator( codec );
-
- AdDirSyncResponse adDirSyncResponse = ( AdDirSyncResponse ) ( ( AdDirSyncResponseDecorator ) decorator ).decode( bb.array() );
-
- assertEquals( AdDirSyncFlag.LDAP_DIRSYNC_OBJECT_SECURITY, adDirSyncResponse.getFlag() );
- assertEquals( 0, adDirSyncResponse.getMaxReturnLength() );
- assertEquals( "xkcd", Strings.utf8ToString( adDirSyncResponse.getCookie() ) );
-
- // test encoding
- try
- {
- ByteBuffer buffer = ( ( AdDirSyncResponseDecorator ) adDirSyncResponse ).encode( ByteBuffer
- .allocate( ( ( AdDirSyncResponseDecorator ) adDirSyncResponse ).computeLength() ) );
- String expected = Strings.dumpBytes( bb.array() );
- String decoded = Strings.dumpBytes( buffer.array() );
- assertEquals( expected, decoded );
- }
- catch ( EncoderException e )
- {
- fail( e.getMessage() );
- }
- }
-
-
- @Test
- public void testAdDirSyncResponseControlNoCookie() throws Exception
- {
- ByteBuffer bb = ByteBuffer.allocate( 0x0A );
-
- bb.put( new byte[]
- {
- 0x30, 0x08,
- 0x02, 0x01, 0x01, // flag (LDAP_DIRSYNC_OBJECT_SECURITY)
- 0x02, 0x01, 0x00, // maxReturnLength (no limit)
- 0x04, 0x00 // the cookie
- } );
-
- bb.flip();
-
- AdDirSyncResponse decorator = new AdDirSyncResponseDecorator( codec );
-
- AdDirSyncResponse adDirSyncResponse = ( AdDirSyncResponse ) ( ( AdDirSyncResponseDecorator ) decorator ).decode( bb.array() );
-
- assertEquals( AdDirSyncFlag.LDAP_DIRSYNC_OBJECT_SECURITY, adDirSyncResponse.getFlag() );
- assertEquals( 0, adDirSyncResponse.getMaxReturnLength() );
- assertEquals( "", Strings.utf8ToString( adDirSyncResponse.getCookie() ) );
-
- // test encoding
- try
- {
- ByteBuffer buffer = ( ( AdDirSyncResponseDecorator ) adDirSyncResponse ).encode( ByteBuffer
- .allocate( ( ( AdDirSyncResponseDecorator ) adDirSyncResponse ).computeLength() ) );
- String expected = Strings.dumpBytes( bb.array() );
- String decoded = Strings.dumpBytes( buffer.array() );
- assertEquals( expected, decoded );
- }
- catch ( EncoderException e )
- {
- fail( e.getMessage() );
- }
- }
-
-
- @Test
- public void testAdDirSyncResponseControlAbsentCookie() throws Exception
- {
- ByteBuffer bb = ByteBuffer.allocate( 0x08 );
-
- bb.put( new byte[]
- {
- 0x30, 0x06,
- 0x02, 0x01, 0x01, // parentFirst (LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER)
- 0x02, 0x01, 0x00 // maxReturnLength (no limit)
- } );
-
- bb.flip();
-
- AdDirSyncResponse decorator = new AdDirSyncResponseDecorator( codec );
-
- try
- {
- ( ( AdDirSyncResponseDecorator ) decorator ).decode( bb.array() );
- fail();
- }
- catch ( DecoderException de )
- {
- // expected
- }
- }
-
-
- @Test
- public void testAdDirSyncResponseControlAbsentParentFirst() throws Exception
- {
- ByteBuffer bb = ByteBuffer.allocate( 0x07 );
-
- bb.put( new byte[]
- {
- 0x30, 0x05,
- 0x02, 0x01, 0x00, // maxReturnLength (no limit)
- 0x04, 0x00 // cookie
- } );
-
- bb.flip();
-
- AdDirSyncResponse decorator = new AdDirSyncResponseDecorator( codec );
-
- try
- {
- ( ( AdDirSyncResponseDecorator ) decorator ).decode( bb.array() );
- fail();
- }
- catch ( DecoderException de )
- {
- // expected
- }
- }
-
-
- @Test
- public void testAdDirSyncResponseControlEmpty() throws Exception
- {
- ByteBuffer bb = ByteBuffer.allocate( 0x02 );
-
- bb.put( new byte[]
- {
- 0x30, 0x00,
- } );
-
- bb.flip();
-
- AdDirSyncResponse decorator = new AdDirSyncResponseDecorator( codec );
-
- try
- {
- ( ( AdDirSyncResponseDecorator ) decorator ).decode( bb.array() );
- fail();
- }
- catch ( DecoderException de )
- {
- // expected
- }
- }
-}
diff --git a/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseTest.java b/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseTest.java
index f40d127..6816059 100644
--- a/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseTest.java
+++ b/ldap/extras/codec/src/test/java/org/apache/directory/api/ldap/extras/extended/ads_impl/whoAmI/WhoAmIResponseTest.java
@@ -62,7 +62,7 @@
stream.put( new byte[]
{} ).flip();
- String decodedPdu = Strings.dumpBytes( stream.array() );
+ Strings.dumpBytes( stream.array() );
// Allocate a WhoAmI Container
Asn1Container whoAmIResponseContainer = new WhoAmIResponseContainer();
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java
index 0f04797..f967cc1 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/entry/DefaultEntry.java
@@ -991,7 +991,6 @@
* the original object won't affect the cloned object, as a modification
* on the cloned object has no impact on the original object
*/
- @SuppressWarnings("unchecked")
public Entry clone()
{
// First, clone the structure
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifEntry.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifEntry.java
index cea572c..2e1be30 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifEntry.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifEntry.java
@@ -223,6 +223,15 @@
// Now, parse the Ldif and convert it to a LdifEntry
LdifReader reader = new LdifReader();
List<LdifEntry> ldifEntries = reader.parseLdif( sb.toString() );
+
+ try
+ {
+ reader.close();
+ }
+ catch ( IOException e )
+ {
+ e.printStackTrace();
+ }
if ( ( ldifEntries != null ) && ( ldifEntries.size() == 1 ) )
{
@@ -258,6 +267,7 @@
{
modifications.put( modification.getAttribute().getId(), modification );
}
+
break;
}
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifUtils.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifUtils.java
index 139344e..7c77bcc 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifUtils.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/ldif/LdifUtils.java
@@ -20,6 +20,7 @@
package org.apache.directory.api.ldap.model.ldif;
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
import javax.naming.directory.Attributes;
@@ -269,7 +270,18 @@
{
LdifAttributesReader reader = new LdifAttributesReader();
- return AttributeUtils.toAttributes( reader.parseEntry( ldif ) );
+ try
+ {
+ Attributes attributes = AttributeUtils.toAttributes( reader.parseEntry( ldif ) );
+
+ reader.close();
+
+ return attributes;
+ }
+ catch ( IOException ioe )
+ {
+ throw new LdapLdifException( ioe.getMessage() );
+ }
}
@@ -727,6 +739,15 @@
LdifAttributesReader reader = new LdifAttributesReader();
Attributes attributes = AttributeUtils.toAttributes( reader.parseEntry( sb.toString() ) );
+
+ try
+ {
+ reader.close();
+ }
+ catch ( IOException e )
+ {
+ e.printStackTrace();
+ }
return attributes;
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ReferralsPolicyEnum.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ReferralsPolicyEnum.java
new file mode 100644
index 0000000..1ff19f9
--- /dev/null
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ReferralsPolicyEnum.java
@@ -0,0 +1,36 @@
+/*
+ * 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.api.ldap.model.message;
+
+/**
+ * An enum describing the three possible actions for referrals :
+ * <ul>
+ * <li>Ignore : The referrals will be retruned as is (ie, the 'ref' attribute type will be present in the entry</li>
+ * <li>Follow : The referral will be chased by the client</li>
+ * <li>Throws : An LdapReferralException will be thrown</li>
+ * </ul>
+ * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
+ */
+public enum ReferralsPolicyEnum
+{
+ IGNORE,
+ FOLLOW,
+ THROW
+}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ResultCodeEnum.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ResultCodeEnum.java
index 6e78ba5..2dc4a68 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ResultCodeEnum.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/ResultCodeEnum.java
@@ -1693,6 +1693,10 @@
case UNBIND_REQUEST:
return set.iterator().next();
+
+ case INTERMEDIATE_RESPONSE :
+ candidates = intersection( set, SEARCH_CODES );
+ break;
}
// we don't want any codes that do not have anything to do w/ errors
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchRequest.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchRequest.java
index e8a1ab4..e3fdc1a 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchRequest.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchRequest.java
@@ -270,4 +270,34 @@
* {@inheritDoc}
*/
SearchRequest removeControl( Control control );
+
+
+ /**
+ * Tells the client if it should follow referrals instead of throwing exceptions
+ * @return true if we should follow the referrals
+ */
+ boolean isFollowReferrals();
+
+
+ /**
+ * Tells the client to follow referrals instead of throwing exceptions
+ * @return The SearchRequest instance
+ */
+ SearchRequest followReferrals();
+
+
+ /**
+ * Tells the client if it should ignore referrals instead of throwing exceptions
+ * @return true if we should ignore the referrals
+ */
+ boolean isIgnoreReferrals();
+
+
+ /**
+ * Tells the client to ignore referrals instead of throwing exceptions. The entry
+ * will contain the referral attributeType with the link.
+ *
+ * @return The SearchRequest instance
+ */
+ SearchRequest ignoreReferrals();
}
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchRequestImpl.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchRequestImpl.java
index c544cf9..36689ae 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchRequestImpl.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/message/SearchRequestImpl.java
@@ -70,6 +70,9 @@
/** The final result containing SearchResponseDone response */
private SearchResultDone response;
+
+ /** A flag set to tell the search what to do wth referrals */
+ private ReferralsPolicyEnum referralHandling = ReferralsPolicyEnum.THROW;
// -----------------------------------------------------------------------
@@ -588,4 +591,44 @@
return super.toString( sb.toString() );
}
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isFollowReferrals()
+ {
+ return referralHandling == ReferralsPolicyEnum.FOLLOW;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SearchRequest followReferrals()
+ {
+ referralHandling = ReferralsPolicyEnum.FOLLOW;
+
+ return this;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isIgnoreReferrals()
+ {
+ return referralHandling == ReferralsPolicyEnum.IGNORE;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SearchRequest ignoreReferrals()
+ {
+ referralHandling = ReferralsPolicyEnum.IGNORE;
+
+ return this;
+ }
}
\ No newline at end of file
diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java
index 2ba3db6..7982d48 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/registries/Registries.java
@@ -725,6 +725,22 @@
case OBJECT_CLASS:
ObjectClassHelper.removeFromRegistries( ( ObjectClass ) schemaObject, errors, this );
break;
+
+ case DIT_CONTENT_RULE :
+ // TODO
+ break;
+
+ case DIT_STRUCTURE_RULE :
+ // TODO
+ break;
+
+ case NAME_FORM :
+ // TODO
+ break;
+
+ case MATCHING_RULE_USE :
+ // TODO
+ break;
}
}
catch ( LdapException ne )
diff --git a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaextractor/impl/DefaultSchemaLdifExtractor.java b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaextractor/impl/DefaultSchemaLdifExtractor.java
index 1b1febb..0004424 100644
--- a/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaextractor/impl/DefaultSchemaLdifExtractor.java
+++ b/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schemaextractor/impl/DefaultSchemaLdifExtractor.java
@@ -209,9 +209,11 @@
FileWriter out = new FileWriter( destination );
+ LdifReader ldifReader = null;
+
try
{
- LdifReader ldifReader = new LdifReader( source );
+ ldifReader = new LdifReader( source );
boolean first = true;
LdifEntry ldifEntry = null;
@@ -239,8 +241,6 @@
}
}
- ldifReader.close();
-
// Add the version at the first line, to avoid a warning
String ldifString = "version: 1\n" + ldifEntry.toString();
@@ -261,6 +261,7 @@
}
finally
{
+ ldifReader.close();
out.close();
}
}
diff --git a/util/src/main/java/org/apache/directory/api/util/OsgiUtils.java b/util/src/main/java/org/apache/directory/api/util/OsgiUtils.java
index e66f0f2..6b779ee 100644
--- a/util/src/main/java/org/apache/directory/api/util/OsgiUtils.java
+++ b/util/src/main/java/org/apache/directory/api/util/OsgiUtils.java
@@ -181,7 +181,7 @@
*/
public static String getBundleExports( File bundle )
{
- JarFile jar;
+ JarFile jar = null;
try
{
jar = new JarFile( bundle );
@@ -207,5 +207,19 @@
LOG.error( "Failed to open jar file or manifest.", e );
throw new RuntimeException( "Failed to open jar file or manifest.", e );
}
+ finally
+ {
+ if ( jar != null )
+ {
+ try
+ {
+ jar.close();
+ }
+ catch ( IOException e )
+ {
+ e.printStackTrace();
+ }
+ }
+ }
}
}