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.request.compare;
21
22
23 import org.apache.directory.api.asn1.ber.grammar.GrammarAction;
24 import org.apache.directory.api.asn1.ber.tlv.TLV;
25 import org.apache.directory.api.i18n.I18n;
26 import org.apache.directory.api.ldap.codec.api.LdapMessageContainer;
27 import org.apache.directory.api.ldap.model.message.CompareRequest;
28 import org.apache.directory.api.util.Strings;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 public class StoreCompareRequestAssertionValue extends GrammarAction<LdapMessageContainer<CompareRequest>>
49 {
50
51 private static final Logger LOG = LoggerFactory.getLogger( StoreCompareRequestAssertionValue.class );
52
53
54
55
56 public StoreCompareRequestAssertionValue()
57 {
58 super( "Store CompareRequest assertion value" );
59 }
60
61
62
63
64
65 @Override
66 public void action( LdapMessageContainer<CompareRequest> container )
67 {
68
69 CompareRequest compareRequest = container.getMessage();
70
71
72 TLV tlv = container.getCurrentTLV();
73
74
75 if ( tlv.getLength() == 0 )
76 {
77 compareRequest.setAssertionValue( "" );
78 }
79 else
80 {
81 if ( container.isBinary( compareRequest.getAttributeId() ) )
82 {
83 compareRequest.setAssertionValue( tlv.getValue().getData() );
84
85 if ( LOG.isDebugEnabled() )
86 {
87 LOG.debug( I18n.msg( I18n.MSG_05121_COMPARING_ATTRIBUTE_VALUE,
88 Strings.dumpBytes( compareRequest.getAssertionValue().getBytes() ) ) );
89 }
90 }
91 else
92 {
93 compareRequest.setAssertionValue( Strings.utf8ToString( tlv.getValue().getData() ) );
94
95 if ( LOG.isDebugEnabled() )
96 {
97 LOG.debug( I18n.msg( I18n.MSG_05121_COMPARING_ATTRIBUTE_VALUE, compareRequest.getAssertionValue() ) );
98 }
99 }
100 }
101
102
103 container.setGrammarEndAllowed( true );
104 }
105 }