Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public final class LdapContextSource
- Object
- 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.
Fields
public static final String PREFIX = "cn1.ldap." |
Constructors
public LdapContextSource(String... urls) |
Methods
public static LdapContextSource fromConfig(Config config)
throws IOException | The context source the cn1.ldap.* settings describe, or null when cn1.ldap.urls is not set. |
public List<String> getUrls() | |
public String getBase() | |
public void setBase(String base) | |
public void setUserDn(String userDn) | The account searches run as; empty for anonymous searches. |
public void setPassword(String password) | |
public void setStartTls(boolean startTls) | |
public void setCaFile(String caFile) | |
public void setConnectTimeoutMillis(int millis) | |
public void setReadTimeoutMillis(int millis) | |
public String absolute(String name) | name under the base: uid=ada,ou=people becomes uid=ada,ou=people,dc=corp,dc=example. |
public LdapConnection connect()
throws IOException | A connection to the first server that answers, not bound. |
public LdapConnection readOnly()
throws IOException | A connection bound as the search account, or anonymous when none is set. |
Inherited methods
Field details
PREFIX
public static final String PREFIX = "cn1.ldap."Constructor details
LdapContextSource
public LdapContextSource(String... urls)Parameters
urlsString...ldap://host[:port][/base]orldaps://...; the base of the first is used whensetBaseis not called
Method details
fromConfig
public static LdapContextSource fromConfig(Config config)
throws IOExceptionThe context source the
cn1.ldap.* settings describe, or null when
cn1.ldap.urls is not set.Throws
getUrls
public List<String> getUrls()getBase
public String getBase()setBase
public void setBase(String base)setUserDn
public void setUserDn(String userDn)The account searches run as; empty for anonymous searches.
setPassword
public void setPassword(String password)setStartTls
public void setStartTls(boolean startTls)setCaFile
public void setCaFile(String caFile)setConnectTimeoutMillis
public void setConnectTimeoutMillis(int millis)setReadTimeoutMillis
public void setReadTimeoutMillis(int millis)absolute
public String absolute(String name)name under the base: uid=ada,ou=people becomes
uid=ada,ou=people,dc=corp,dc=example.connect
public LdapConnection connect()
throws IOExceptionA connection to the first server that answers, not bound.
Throws
readOnly
public LdapConnection readOnly()
throws IOExceptionA connection bound as the search account, or anonymous when none is set.