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