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.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.api.ResponseCarryingException;
29 import org.apache.directory.api.ldap.codec.decorators.BindRequestDecorator;
30 import org.apache.directory.api.ldap.model.message.BindRequest;
31 import org.apache.directory.api.ldap.model.message.BindResponseImpl;
32 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 public class InitSaslBind extends GrammarAction<LdapMessageContainer<BindRequestDecorator>>
55 {
56
57 private static final Logger LOG = LoggerFactory.getLogger( InitSaslBind.class );
58
59
60 private static final boolean IS_DEBUG = LOG.isDebugEnabled();
61
62
63
64
65
66 public InitSaslBind()
67 {
68 super( "Initialize Bind SASL Authentication" );
69 }
70
71
72
73
74
75 public void action( LdapMessageContainer<BindRequestDecorator> container ) throws DecoderException
76 {
77 BindRequest bindRequestMessage = container.getMessage();
78 TLV tlv = container.getCurrentTLV();
79
80
81 if ( tlv.getLength() == 0 )
82 {
83 String msg = I18n.err( I18n.ERR_04079 );
84 LOG.error( msg );
85
86 BindResponseImpl response = new BindResponseImpl( bindRequestMessage.getMessageId() );
87
88 throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_CREDENTIALS,
89 bindRequestMessage.getDn(), null );
90 }
91
92 bindRequestMessage.setSimple( false );
93
94 if ( IS_DEBUG )
95 {
96 LOG.debug( "The SaslCredential has been created" );
97 }
98 }
99 }