Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meliorartefacts/service-harness-ldap
An easy to use, auto-configuring, LDAP client with connection pooling and automatic object mapping.
https://github.com/meliorartefacts/service-harness-ldap
connection-pool ldap spring-boot spring-client
Last synced: about 2 months ago
JSON representation
An easy to use, auto-configuring, LDAP client with connection pooling and automatic object mapping.
- Host: GitHub
- URL: https://github.com/meliorartefacts/service-harness-ldap
- Owner: MeliorArtefacts
- Created: 2022-06-03T10:21:30.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-15T18:05:56.000Z (12 months ago)
- Last Synced: 2024-01-15T23:21:47.638Z (12 months ago)
- Topics: connection-pool, ldap, spring-boot, spring-client
- Language: Java
- Homepage:
- Size: 321 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Melior Service Harness :: LDAP
## Artefact
Get the artefact and the POM file in the *artefact* folder.
```org.melior
melior-harness-ldap
2.3```
## Client
Create a bean to instantiate the LDAP client. The LDAP client uses connection pooling to improve performance.
```
@Bean("myclient")
@ConfigurationProperties("myclient")
public LdapClient client() {
return LdapClientBuilder.create().ssl().build();
}
```The LDAP client is auto-configured from the application properties.
```
myclient.url=ldaps://some.service:636
myclient.username=user
myclient.password=password
myclient.request-timeout=30
myclient.inactivity-timeout=300
```Map the attributes in the LDAP repository to the fields in the JAVA class.
```
public class Person {
@LdapProperty("name")
private String name;@LdapProperty("postaladdress")
private String postalAddress;@LdapProperty("age")
private int age;...
}```
Wire in and use the LDAP client. Use the LDAP object mapper to request only those attributes that are required by the mapping.
```
@Autowired
private LdapClient client;public List foo(String name) throws RemotingException {
return client.search(LdapQueryBuilder.query().base("ou=person,o=company")
.attributes(LdapObjectMapper.getAttributes(Person.class))
.where("name").is(name), Person.class);
}
```The LDAP client may be configured using these application properties.
|Name|Default|Description|
|:---|:---|:---|
|`url`||The URL of the LDAP repository|
|`username`||The user name required by the LDAP repository|
|`password`||The password required by the LDAP repository|
|`minimum-connections`|0|The minimum number of connections to open to the LDAP repository|
|`maximum-connections`|1000|The maximum number of connections to open to the LDAP repository|
|`connection-timeout`|30 s|The amount of time to allow for a new connection to open to the LDAP repository|
|`validate-on-borrow`|false|Indicates if a connection must be validated when it is borrowed from the JDBC connection pool|
|`validation-timeout`|5 s|The amount of time to allow for a connection to be validated|
|`request-timeout`|60 s|The amount of time to allow for a request to the LDAP repository to complete|
|`backoff-period`|1 s|The amount of time to back off when the circuit breaker trips|
|`backoff-multiplier`|1|The factor with which to increase the backoff period when the circuit breaker trips repeatedly|
|`backoff-limit`||The maximum amount of time to back off when the circuit breaker trips repeatedly|
|`inactivity-timeout`|300 s|The amount of time to allow before surplus connections to the LDAP repository are pruned|
|`maximum-lifetime`|unlimited|The maximum lifetime of a connection to the LDAP repository|
|`prune-interval`|60 s|The interval at which surplus connections to the LDAP repository are pruned|
## References
Refer to the [**Melior Service Harness :: Core**](https://github.com/MeliorArtefacts/service-harness-core) module for detail on the Melior logging system and available utilities.