1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.codec.actions.searchRequest.filter;
21
22
23 import org.apache.directory.api.asn1.DecoderException;
24 import org.apache.directory.api.asn1.ber.grammar.GrammarAction;
25 import org.apache.directory.api.asn1.ber.tlv.TLV;
26 import org.apache.directory.api.i18n.I18n;
27 import org.apache.directory.api.ldap.codec.AttributeValueAssertion;
28 import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
29 import org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator;
30 import org.apache.directory.api.ldap.codec.search.AttributeValueAssertionFilter;
31 import org.apache.directory.api.util.Strings;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34
35
36
37
38
39
40
41 public class InitAttributeDescFilter extends GrammarAction<LdapMessageContainer<SearchRequestDecorator>>
42 {
43
44 private static final Logger LOG = LoggerFactory.getLogger( InitAttributeDescFilter.class );
45
46
47 private static final boolean IS_DEBUG = LOG.isDebugEnabled();
48
49
50
51
52
53 public InitAttributeDescFilter()
54 {
55 super( "Initialize AttributeDesc filter" );
56 }
57
58
59
60
61
62 public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
63 {
64 SearchRequestDecorator searchRequestDecorator = container.getMessage();
65
66 TLV tlv = container.getCurrentTLV();
67
68 AttributeValueAssertion assertion = new AttributeValueAssertion();
69
70 if ( tlv.getLength() == 0 )
71 {
72 String msg = I18n.err( I18n.ERR_04007 );
73 LOG.error( msg );
74 throw new DecoderException( msg );
75 }
76 else
77 {
78 String type = Strings.utf8ToString( tlv.getValue().getData() );
79 assertion.setAttributeDesc( type );
80
81 AttributeValueAssertionFilter terminalFilter = ( AttributeValueAssertionFilter )
82 searchRequestDecorator.getTerminalFilter();
83 terminalFilter.setAssertion( assertion );
84 }
85
86 if ( IS_DEBUG )
87 {
88 LOG.debug( "Initialize AttributeDesc filter" );
89 }
90 }
91 }