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.unbindRequest;
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.api.LdapMessageContainer;
28 import org.apache.directory.api.ldap.codec.decorators.UnbindRequestDecorator;
29 import org.apache.directory.api.ldap.model.message.UnbindRequest;
30 import org.apache.directory.api.ldap.model.message.UnbindRequestImpl;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33
34
35
36
37
38
39
40
41
42
43 public class InitUnbindRequest extends GrammarAction<LdapMessageContainer<UnbindRequestDecorator>>
44 {
45
46 private static final Logger LOG = LoggerFactory.getLogger( InitUnbindRequest.class );
47
48
49
50
51
52 public InitUnbindRequest()
53 {
54 super( "Unbind Request initialization" );
55 }
56
57
58
59
60
61 public void action( LdapMessageContainer<UnbindRequestDecorator> container ) throws DecoderException
62 {
63
64 UnbindRequest unbindRequestInternal = new UnbindRequestImpl();
65 unbindRequestInternal.setMessageId( container.getMessageId() );
66 UnbindRequestDecorator unbindRequest = new UnbindRequestDecorator(
67 container.getLdapCodecService(), unbindRequestInternal );
68 container.setMessage( unbindRequest );
69
70 TLV tlv = container.getCurrentTLV();
71 int expectedLength = tlv.getLength();
72
73
74 if ( expectedLength != 0 )
75 {
76 LOG.error( I18n.err( I18n.ERR_04071, Integer.valueOf( expectedLength ) ) );
77
78
79 throw new DecoderException( I18n.err( I18n.ERR_04072 ) );
80 }
81
82
83 container.setGrammarEndAllowed( true );
84 }
85 }