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.bindRequest;
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.ldap.codec.api.LdapMessageContainer;
26 import org.apache.directory.api.ldap.codec.decorators.BindRequestDecorator;
27 import org.apache.directory.api.ldap.model.message.BindRequest;
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 public class StoreSaslMechanism extends GrammarAction<LdapMessageContainer<BindRequestDecorator>>
43 {
44
45 private static final Logger LOG = LoggerFactory.getLogger( StoreSaslMechanism.class );
46
47
48 private static final boolean IS_DEBUG = LOG.isDebugEnabled();
49
50
51
52
53
54 public StoreSaslMechanism()
55 {
56 super( "Store SASL mechanism" );
57 }
58
59
60
61
62
63 public void action( LdapMessageContainer<BindRequestDecorator> container )
64 {
65 BindRequest bindRequestMessage = container.getMessage();
66 TLV tlv = container.getCurrentTLV();
67
68
69
70 if ( tlv.getLength() == 0 )
71 {
72 bindRequestMessage.setSaslMechanism( "" );
73 }
74 else
75 {
76 bindRequestMessage.setSaslMechanism( Strings.utf8ToString( tlv.getValue().getData() ) );
77 }
78
79
80 container.setGrammarEndAllowed( true );
81
82 if ( IS_DEBUG )
83 {
84 LOG.debug( "The mechanism is : {}", bindRequestMessage.getSaslMechanism() );
85 }
86 }
87 }