Class LdapContextSource
java.lang.Object
com.codename1.backend.security.ldap.LdapContextSource
Where the directory is and how to reach it: the server URLs, tried in
order, the base every name is under, the account searches run as, and the
TLS settings. Spring's LdapContextSource, from the same settings Spring
Boot reads (spring.ldap.* there, cn1.ldap.* here):
cn1.ldap.urls=ldaps://ldap1.corp.example,ldaps://ldap2.corp.example
cn1.ldap.base=dc=corp,dc=example
cn1.ldap.username=cn=reader,dc=corp,dc=example
cn1.ldap.password=${LDAP_READER_PASSWORD}
plus cn1.ldap.starttls (upgrade ldap:// URLs), cn1.ldap.ca-file (PEM
of the authorities to trust), cn1.ldap.connect-timeout-millis and
cn1.ldap.read-timeout-millis (both 10 seconds by default).
Connections are not pooled: each sign-in opens its own and closes it, so a directory that is down costs one connect timeout per attempt and nothing stays open between sign-ins.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnameunder the base:uid=ada,ou=peoplebecomesuid=ada,ou=people,dc=corp,dc=example.connect()A connection to the first server that answers, not bound.static LdapContextSourcefromConfig(Config config) The context source thecn1.ldap.*settings describe, or null whencn1.ldap.urlsis not set.getBase()getUrls()readOnly()A connection bound as the search account, or anonymous when none is set.voidvoidvoidsetConnectTimeoutMillis(int millis) voidsetPassword(String password) voidsetReadTimeoutMillis(int millis) voidsetStartTls(boolean startTls) voidThe account searches run as; empty for anonymous searches.
-
Field Details
-
PREFIX
- See Also:
-
-
Constructor Details
-
LdapContextSource
- Parameters:
urls-ldap://host[:port][/base]orldaps://...; the base of the first is used whensetBase(String)is not called
-
-
Method Details
-
fromConfig
The context source thecn1.ldap.*settings describe, or null whencn1.ldap.urlsis not set.- Throws:
IOException
-
getUrls
-
getBase
-
setBase
-
setUserDn
The account searches run as; empty for anonymous searches. -
setPassword
-
setStartTls
public void setStartTls(boolean startTls) -
setCaFile
-
setConnectTimeoutMillis
public void setConnectTimeoutMillis(int millis) -
setReadTimeoutMillis
public void setReadTimeoutMillis(int millis) -
absolute
-
connect
A connection to the first server that answers, not bound.- Throws:
IOException
-
readOnly
A connection bound as the search account, or anonymous when none is set.- Throws:
IOException
-