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.bindResponse;
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.BindResponseDecorator;
28 import org.apache.directory.api.ldap.model.message.BindResponse;
29 import org.apache.directory.api.util.StringConstants;
30 import org.apache.directory.api.util.Strings;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33
34
35
36
37
38
39
40
41
42
43
44 public class StoreServerSASLCreds extends GrammarAction<LdapMessageContainer<BindResponseDecorator>>
45 {
46
47 private static final Logger LOG = LoggerFactory.getLogger( StoreServerSASLCreds.class );
48
49
50 private static final boolean IS_DEBUG = LOG.isDebugEnabled();
51
52
53
54
55
56 public StoreServerSASLCreds()
57 {
58 super( "Store server sasl credentials value" );
59 }
60
61
62
63
64
65 public void action( LdapMessageContainer<BindResponseDecorator> container ) throws DecoderException
66 {
67
68 TLV tlv = container.getCurrentTLV();
69
70
71
72 byte[] serverSaslCreds = null;
73
74 if ( tlv.getLength() == 0 )
75 {
76 serverSaslCreds = StringConstants.EMPTY_BYTES;
77 }
78 else
79 {
80 serverSaslCreds = tlv.getValue().getData();
81 }
82
83 BindResponse response = container.getMessage();
84 response.setServerSaslCreds( serverSaslCreds );
85
86
87 container.setGrammarEndAllowed( true );
88
89 if ( IS_DEBUG )
90 {
91 LOG.debug( "The SASL credentials value is : {}", Strings.dumpBytes( serverSaslCreds ) );
92 }
93 }
94 }