LdapConstants.EXTENDED_REQUEST_NAME_TAG, new GrammarAction<LdapMessageContainer<ExtendedRequestDecorator>>( "Store name" )
{
public void action( LdapMessageContainer<ExtendedRequestDecorator> container ) throws DecoderException
{
// We can allocate the ExtendedRequest Object
ExtendedRequest extendedRequest = container.getMessage();
// Get the Value and store it in the ExtendedRequest
TLV tlv = container.getCurrentTLV();
// We have to handle the special case of a 0 length matched
// OID
if ( tlv.getLength() == 0 )
{
String msg = I18n.err( I18n.ERR_04095 );
LOG.error( msg );
// This will generate a PROTOCOL_ERROR
throw new DecoderException( msg );
}
else
{
byte[] requestNameBytes = tlv.getValue().getData();
try
{
String requestName = Strings.utf8ToString(requestNameBytes);
if ( !OID.isOID( requestName ) )
{
String msg = "The Request name is not a valid OID : "
+ Strings.utf8ToString(requestNameBytes) + " ("
+ Strings.dumpBytes(requestNameBytes) + ") is invalid";
LOG.error( msg );
// throw an exception, we will get a PROTOCOL_ERROR
throw new DecoderException( msg );
}
extendedRequest.setRequestName( requestName );
}
catch ( DecoderException de )
{
String msg = "The Request name is not a valid OID : "
+ Strings.utf8ToString(requestNameBytes) + " ("
+ Strings.dumpBytes(requestNameBytes) + ") is invalid";
LOG.error( "{} : {}", msg, de.getMessage() );
// Rethrow the exception, we will get a PROTOCOL_ERROR
throw de;
}
}
// We can have an END transition
container.setGrammarEndAllowed( true );
if ( IS_DEBUG )
{
LOG.debug( "OID read : {}", extendedRequest.getRequestName() );
}
}
} );
// --------------------------------------------------------------------------------------------
// Transition from RequestName to RequestValue
// --------------------------------------------------------------------------------------------
// ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
// ...
// requestValue [1] OCTET STRING OPTIONAL }
//
// Stores the value
super.transitions[LdapStatesEnum.REQUEST_NAME_STATE.ordinal()][LdapConstants.EXTENDED_REQUEST_VALUE_TAG] = new GrammarTransition(
LdapStatesEnum.REQUEST_NAME_STATE, LdapStatesEnum.REQUEST_VALUE_STATE,
LdapConstants.EXTENDED_REQUEST_VALUE_TAG, new GrammarAction<LdapMessageContainer<ExtendedRequestDecorator>>( "Store value" )
{
public void action( LdapMessageContainer<ExtendedRequestDecorator> container ) throws DecoderException
{
// We can allocate the ExtendedRequest Object
ExtendedRequest extendedRequest = container.getMessage();
// Get the Value and store it in the ExtendedRequest
TLV tlv = container.getCurrentTLV();
// We have to handle the special case of a 0 length matched
// value
if ( tlv.getLength() == 0 )
{
extendedRequest.setRequestValue( StringConstants.EMPTY_BYTES );
}
else
{
extendedRequest.setRequestValue( tlv.getValue().getData() );
}
// We can have an END transition
container.setGrammarEndAllowed( true );
if ( IS_DEBUG )
{
LOG.debug( "Extended value : {}", extendedRequest.getRequestValue() );
}
}
} );
// --------------------------------------------------------------------------------------------