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.controls;
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.api.MessageDecorator;
28 import org.apache.directory.api.ldap.model.message.Message;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31
32
33
34
35
36
37
38
39
40
41 public class InitControls extends GrammarAction<LdapMessageContainer<MessageDecorator<? extends Message>>>
42 {
43
44 private static final Logger LOG = LoggerFactory.getLogger( InitControls.class );
45
46
47 private static final boolean IS_DEBUG = LOG.isDebugEnabled();
48
49
50
51
52
53 public InitControls()
54 {
55 super( "Initialize a control" );
56 }
57
58
59
60
61
62 public void action( LdapMessageContainer<MessageDecorator<? extends Message>> container ) throws DecoderException
63 {
64 TLV tlv = container.getCurrentTLV();
65 int expectedLength = tlv.getLength();
66
67
68 if ( expectedLength == 0 )
69 {
70 LOG.error( "The length of controls must not be null" );
71
72
73 throw new DecoderException( "The length of controls must not be null" );
74 }
75
76 if ( IS_DEBUG )
77 {
78 LOG.debug( "A new list of controls has been initialized" );
79 }
80 }
81 }