1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.core.authn;
21
22
23 import java.net.SocketAddress;
24
25 import org.apache.directory.api.ldap.model.constants.AuthenticationLevel;
26 import org.apache.directory.api.ldap.model.exception.LdapAuthenticationException;
27 import org.apache.directory.api.ldap.model.name.Dn;
28 import org.apache.directory.server.core.api.LdapPrincipal;
29 import org.apache.directory.server.core.api.interceptor.context.BindOperationContext;
30 import org.apache.mina.core.session.IoSession;
31
32
33
34
35
36
37
38
39
40
41 public class StrongAuthenticator extends AbstractAuthenticator
42 {
43
44
45
46 public StrongAuthenticator()
47 {
48 super( AuthenticationLevel.STRONG );
49 }
50
51
52
53
54
55
56
57 public StrongAuthenticator( Dn baseDn )
58 {
59 super( AuthenticationLevel.STRONG, baseDn );
60 }
61
62
63
64
65
66
67 @Override
68 public LdapPrincipal authenticate( BindOperationContext bindContext ) throws LdapAuthenticationException
69 {
70
71 LdapPrincipal/api/LdapPrincipal.html#LdapPrincipal">LdapPrincipal principal = new LdapPrincipal( getDirectoryService().getSchemaManager(), bindContext.getDn(),
72 AuthenticationLevel.STRONG );
73
74 IoSession session = bindContext.getIoSession();
75
76 if ( session != null )
77 {
78 SocketAddress clientAddress = session.getRemoteAddress();
79 principal.setClientAddress( clientAddress );
80 SocketAddress serverAddress = session.getServiceAddress();
81 principal.setServerAddress( serverAddress );
82 }
83
84 return principal;
85 }
86 }