Skip to content
Permalink
Browse files
Refactored the ExtendedRequest hierarchy to have all the impl extendi…
…ng the OpaqueExtendedRequest
  • Loading branch information
elecharny committed Jan 7, 2022
1 parent e512030 commit 32b25240b7f358f471daa5bc1f15f0ede0ed9040
Showing 11 changed files with 52 additions and 38 deletions.
@@ -20,7 +20,7 @@
package org.apache.directory.api.ldap.extras.extended.cancel;


import org.apache.directory.api.ldap.model.message.AbstractExtendedRequest;
import org.apache.directory.api.ldap.model.message.OpaqueExtendedRequest;


/**
@@ -37,7 +37,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class CancelRequestImpl extends AbstractExtendedRequest implements CancelRequest
public class CancelRequestImpl extends OpaqueExtendedRequest implements CancelRequest
{
/** The cancelId of the request to be canceled */
private int cancelId;
@@ -20,7 +20,7 @@
package org.apache.directory.api.ldap.extras.extended.certGeneration;


import org.apache.directory.api.ldap.model.message.AbstractExtendedRequest;
import org.apache.directory.api.ldap.model.message.OpaqueExtendedRequest;


/**
@@ -30,7 +30,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class CertGenerationRequestImpl extends AbstractExtendedRequest implements CertGenerationRequest
public class CertGenerationRequestImpl extends OpaqueExtendedRequest implements CertGenerationRequest
{
/** the Dn of the server entry which will be updated*/
private String targetDN;
@@ -20,7 +20,7 @@
package org.apache.directory.api.ldap.extras.extended.endTransaction;


import org.apache.directory.api.ldap.model.message.AbstractExtendedRequest;
import org.apache.directory.api.ldap.model.message.OpaqueExtendedRequest;
import org.apache.directory.api.util.Strings;


@@ -44,7 +44,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class EndTransactionRequestImpl extends AbstractExtendedRequest implements EndTransactionRequest
public class EndTransactionRequestImpl extends OpaqueExtendedRequest implements EndTransactionRequest
{
/** The transaction ID received from the StartTransactionResponse */
private byte[] transactionId;
@@ -20,7 +20,7 @@
package org.apache.directory.api.ldap.extras.extended.gracefulShutdown;


import org.apache.directory.api.ldap.model.message.AbstractExtendedRequest;
import org.apache.directory.api.ldap.model.message.OpaqueExtendedRequest;


/**
@@ -32,7 +32,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class GracefulShutdownRequestImpl extends AbstractExtendedRequest implements GracefulShutdownRequest
public class GracefulShutdownRequestImpl extends OpaqueExtendedRequest implements GracefulShutdownRequest
{
/** Offline time after disconnection */
private int timeOffline;
@@ -20,7 +20,7 @@
package org.apache.directory.api.ldap.extras.extended.pwdModify;


import org.apache.directory.api.ldap.model.message.AbstractExtendedRequest;
import org.apache.directory.api.ldap.model.message.OpaqueExtendedRequest;
import org.apache.directory.api.util.Strings;


@@ -36,7 +36,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class PasswordModifyRequestImpl extends AbstractExtendedRequest implements PasswordModifyRequest
public class PasswordModifyRequestImpl extends OpaqueExtendedRequest implements PasswordModifyRequest
{
/** The user identity */
private byte[] userIdentity;
@@ -20,15 +20,15 @@
package org.apache.directory.api.ldap.extras.extended.startTls;


import org.apache.directory.api.ldap.model.message.AbstractExtendedRequest;
import org.apache.directory.api.ldap.model.message.OpaqueExtendedRequest;


/**
* The RFC 4511 StartTLS request
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class StartTlsRequestImpl extends AbstractExtendedRequest implements StartTlsRequest
public class StartTlsRequestImpl extends OpaqueExtendedRequest implements StartTlsRequest
{
/**
* Create a new instance of the StartTlsRequest extended operation
@@ -20,7 +20,7 @@
package org.apache.directory.api.ldap.extras.extended.startTransaction;


import org.apache.directory.api.ldap.model.message.AbstractExtendedRequest;
import org.apache.directory.api.ldap.model.message.OpaqueExtendedRequest;


/**
@@ -37,7 +37,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class StartTransactionRequestImpl extends AbstractExtendedRequest implements StartTransactionRequest
public class StartTransactionRequestImpl extends OpaqueExtendedRequest implements StartTransactionRequest
{
/**
* Creates a new instance of StartTransactionRequestImpl.
@@ -27,7 +27,7 @@
import org.apache.directory.api.asn1.ber.tlv.IntegerDecoder;
import org.apache.directory.api.asn1.ber.tlv.IntegerDecoderException;
import org.apache.directory.api.i18n.I18n;
import org.apache.directory.api.ldap.model.message.AbstractExtendedRequest;
import org.apache.directory.api.ldap.model.message.OpaqueExtendedRequest;
import org.apache.directory.api.util.Strings;
import org.apache.directory.api.util.exception.NotImplementedException;

@@ -37,7 +37,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class StoredProcedureRequestImpl extends AbstractExtendedRequest implements StoredProcedureRequest
public class StoredProcedureRequestImpl extends OpaqueExtendedRequest implements StoredProcedureRequest
{
private String language = "Java";

@@ -20,15 +20,15 @@
package org.apache.directory.api.ldap.extras.extended.whoAmI;


import org.apache.directory.api.ldap.model.message.AbstractExtendedRequest;
import org.apache.directory.api.ldap.model.message.OpaqueExtendedRequest;


/**
* The RFC 4532 WhoAmI request
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class WhoAmIRequestImpl extends AbstractExtendedRequest implements WhoAmIRequest
public class WhoAmIRequestImpl extends OpaqueExtendedRequest implements WhoAmIRequest
{
/**
* Create a new instance of the WhoAmIRequest extended operation
@@ -30,7 +30,7 @@ public abstract class AbstractExtendedRequest extends AbstractRequest implements
static final long serialVersionUID = 7916990159044177480L;

/** Extended request's Object Identifier or <b>requestName</b> */
private String oid;
protected String oid;

/** The associated response */
private ExtendedResponse response;
@@ -52,7 +52,7 @@ public AbstractExtendedRequest()
*
* @param id the sequential message identifier
*/
public AbstractExtendedRequest( final int id )
public AbstractExtendedRequest( int id )
{
super( id, MessageTypeEnum.EXTENDED_REQUEST, true );
}
@@ -219,20 +219,26 @@ public boolean equals( Object obj )
}

ExtendedRequest req = ( ExtendedRequest ) obj;

String requestName = req.getRequestName();

if ( ( oid != null ) && ( req.getRequestName() == null ) )
{
return false;
}

if ( ( oid == null ) && ( req.getRequestName() != null ) )
if ( oid == null )
{
return false;
if ( requestName != null )
{
return false;
}
}

if ( ( oid != null ) && ( req.getRequestName() != null ) && !oid.equals( req.getRequestName() ) )
else
{
return false;
if ( requestName == null )
{
return false;
}
else if ( !oid.equals( requestName ) )
{
return false;
}
}

return true;
@@ -28,13 +28,10 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class OpaqueExtendedRequest extends AbstractRequest implements ExtendedRequest
public class OpaqueExtendedRequest extends AbstractExtendedRequest
{
static final long serialVersionUID = 7916990159044177480L;

/** Extended request's Object Identifier or <b>requestName</b> */
private String oid;

/** Extended request value as an opaque byte array */
private byte[] requestValue;

@@ -48,7 +45,18 @@ public class OpaqueExtendedRequest extends AbstractRequest implements ExtendedRe
*/
public OpaqueExtendedRequest()
{
super( -1, MessageTypeEnum.EXTENDED_REQUEST, true );
super( -1 );
}


/**
* Creates an ExtendedRequest implementing object used to perform
* extended protocol operation on the server.
* @param id The message ID
*/
public OpaqueExtendedRequest( int id )
{
super( id );
}


@@ -60,7 +68,7 @@ public OpaqueExtendedRequest()
*/
public OpaqueExtendedRequest( String requestName )
{
super( -1, MessageTypeEnum.EXTENDED_REQUEST, true );
super( -1 );
this.oid = requestName;
}

@@ -73,7 +81,7 @@ public OpaqueExtendedRequest( String requestName )
*/
public OpaqueExtendedRequest( byte[] requestValue )
{
super( -1, MessageTypeEnum.EXTENDED_REQUEST, true );
super( -1 );
this.requestValue = requestValue;
}

@@ -87,7 +95,7 @@ public OpaqueExtendedRequest( byte[] requestValue )
*/
public OpaqueExtendedRequest( String requestName, byte[] requestValue )
{
super( -1, MessageTypeEnum.EXTENDED_REQUEST, true );
super( -1 );
this.oid = requestName;
this.requestValue = requestValue;
}

0 comments on commit 32b2524

Please sign in to comment.