LdapConstants.SEARCH_RESULT_ENTRY_TAG, new GrammarAction<LdapMessageContainer<MessageDecorator<? extends Message>>>( "Init SearchResultEntry" )
{
public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container )
{
// Now, we can allocate the SearchResultEntry Object
SearchResultEntryDecorator searchResultEntry = new SearchResultEntryDecorator(
container.getLdapCodecService(), new SearchResultEntryImpl( container.getMessageId() ) );
container.setMessage( searchResultEntry );
}
} );
// --------------------------------------------------------------------------------------------
// Transition from SearchResultEntry Message to ObjectName
// --------------------------------------------------------------------------------------------
// SearchResultEntry ::= [APPLICATION 4] SEQUENCE { ...
// objectName LDAPDN,
// ...
//
// Store the object name.
super.transitions[LdapStatesEnum.SEARCH_RESULT_ENTRY_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
LdapStatesEnum.SEARCH_RESULT_ENTRY_STATE, LdapStatesEnum.OBJECT_NAME_STATE, UniversalTag.OCTET_STRING.getValue(),
new GrammarAction<LdapMessageContainer<SearchResultEntryDecorator>>( "Store search result entry object name Value" )
{
public void action( LdapMessageContainer<SearchResultEntryDecorator> container ) throws DecoderException
{
SearchResultEntryDecorator searchResultEntry = container.getMessage();
TLV tlv = container.getCurrentTLV();
Dn objectName = Dn.EMPTY_DN;
// Store the value.
if ( tlv.getLength() == 0 )
{
searchResultEntry.setObjectName( objectName );
}
else
{
byte[] dnBytes = tlv.getValue().getData();
String dnStr = Strings.utf8ToString(dnBytes);
try
{
objectName = new Dn( dnStr );
}
catch ( LdapInvalidDnException ine )
{
// This is for the client side. We will never decode LdapResult on the server
String msg = "The Dn " + Strings.dumpBytes(dnBytes) + "is invalid : "
+ ine.getMessage();
LOG.error( "{} : {}", msg, ine.getMessage() );
throw new DecoderException( msg, ine );
}
searchResultEntry.setObjectName( objectName );
}
if ( IS_DEBUG )
{
LOG.debug( "Search Result Entry Dn found : {}", searchResultEntry.getObjectName() );
}
}
} );
// --------------------------------------------------------------------------------------------
// Transition from ObjectName to AttributesSR
// --------------------------------------------------------------------------------------------
// SearchResultEntry ::= [APPLICATION 4] SEQUENCE { ...
// ...
// attributes PartialAttributeList }
//
// PartialAttributeList ::= *SEQUENCE* OF SEQUENCE {
// ...
//
// We may have no attributes. Just allows the grammar to end
super.transitions[LdapStatesEnum.OBJECT_NAME_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
LdapStatesEnum.OBJECT_NAME_STATE, LdapStatesEnum.ATTRIBUTES_SR_STATE, UniversalTag.SEQUENCE.getValue(),
new GrammarAction<LdapMessageContainer<MessageDecorator<? extends Message>>>( "Pop and end allowed" )
{
public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container ) throws DecoderException
{
container.setGrammarEndAllowed( true );
}
} );
// --------------------------------------------------------------------------------------------
// Transition from AttributesSR to PartialAttributesList
// --------------------------------------------------------------------------------------------
// SearchResultEntry ::= [APPLICATION 4] SEQUENCE { ...
// ...
// attributes PartialAttributeList }
//
// PartialAttributeList ::= SEQUENCE OF *SEQUENCE* {
// ...
//
// nothing to do
super.transitions[LdapStatesEnum.ATTRIBUTES_SR_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
LdapStatesEnum.ATTRIBUTES_SR_STATE, LdapStatesEnum.PARTIAL_ATTRIBUTES_LIST_STATE,
UniversalTag.SEQUENCE.getValue(), null );
// --------------------------------------------------------------------------------------------
// Transition from AttributesSR to Controls
// --------------------------------------------------------------------------------------------
// searchResultEntry SearchResultEntry,
// ... },
// controls [0] Controls OPTIONAL }
//
// Initialize the controls
super.transitions[LdapStatesEnum.ATTRIBUTES_SR_STATE.ordinal()][LdapConstants.CONTROLS_TAG] = new GrammarTransition(
LdapStatesEnum.ATTRIBUTES_SR_STATE, LdapStatesEnum.CONTROLS_STATE, LdapConstants.CONTROLS_TAG,
new ControlsInitAction() );
// --------------------------------------------------------------------------------------------
// Transition from PartialAttributesList to typeSR
// --------------------------------------------------------------------------------------------
// SearchResultEntry ::= [APPLICATION 4] SEQUENCE { ...
// ...
// attributes PartialAttributeList }
//
// PartialAttributeList ::= SEQUENCE OF SEQUENCE {
// type AttributeDescription,
// ...
//
// Store the attribute's name.
super.transitions[LdapStatesEnum.PARTIAL_ATTRIBUTES_LIST_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
LdapStatesEnum.PARTIAL_ATTRIBUTES_LIST_STATE, LdapStatesEnum.TYPE_SR_STATE, UniversalTag.OCTET_STRING.getValue(),
new GrammarAction<LdapMessageContainer<SearchResultEntryDecorator>>( "Store search result entry object name Value" )
{
public void action( LdapMessageContainer<SearchResultEntryDecorator> container ) throws DecoderException
{
SearchResultEntryDecorator searchResultEntry = container.getMessage();
TLV tlv = container.getCurrentTLV();
String type = "";
// Store the name
if ( tlv.getLength() == 0 )
{
// The type can't be null
String msg = I18n.err( I18n.ERR_04081 );
LOG.error( msg );
throw new DecoderException( msg );
}
else
{
type = getType(tlv.getValue().getData());
try
{
searchResultEntry.addAttribute( type );
}
catch ( LdapException ine )
{
// This is for the client side. We will never decode LdapResult on the server
String msg = "The Attribute type " + type + "is invalid : " + ine.getMessage();