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.ldap.codec.api.LdapMessageContainer;
27 import org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator;
28 import org.apache.directory.api.ldap.codec.search.ExtensibleMatchFilter;
29 import org.apache.directory.api.ldap.model.entry.BinaryValue;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 public class StoreMatchValue extends GrammarAction<LdapMessageContainer<SearchRequestDecorator>>
49 {
50
51 private static final Logger LOG = LoggerFactory.getLogger( StoreMatchValue.class );
52
53
54 private static final boolean IS_DEBUG = LOG.isDebugEnabled();
55
56
57
58
59
60 public StoreMatchValue()
61 {
62 super( "Store match Value" );
63 }
64
65
66
67
68
69 public void action( LdapMessageContainer<SearchRequestDecorator> container ) throws DecoderException
70 {
71 SearchRequestDecorator decorator = container.getMessage();
72
73 TLV tlv = container.getCurrentTLV();
74
75
76 ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) decorator.getTerminalFilter();
77
78 byte[] value = tlv.getValue().getData();
79 extensibleMatchFilter.setMatchValue( new BinaryValue( value ) );
80
81
82 decorator.unstackFilters( container );
83
84 if ( IS_DEBUG )
85 {
86 LOG.debug( "Stored a match value : {}", value );
87 }
88 }
89 }