Skip to content

No log message or exception if expected ldif file does not exist #7791

Closed
@ybbabr19

Description

@ybbabr19

Summary

When configuring an embedded ldap server to import an ldif file (e.g., users.ldif), no log message (at not level) is written nor any exception is thrown if the provided file does not exist (e.g., uesrs.ldif):

private void importLdif(InMemoryDirectoryServer directoryServer) {
	if (StringUtils.hasText(this.ldif)) {
		Resource resource = this.context.getResource(this.ldif);
		try {
			if (resource.exists()) {
				try (InputStream inputStream = resource.getInputStream()) {
					directoryServer.importFromLDIF(false, new LDIFReader(inputStream));
				}
			}
		} catch (Exception ex) {
			throw new IllegalStateException("Unable to load LDIF " + this.ldif, ex);
		}
	}
}

While it is arguably legitimate not to throw an exception in this case and load the ldif file from a default location, logging a message out that warns the user that the configured ldif file was not found could spare some debugging time ;)

Actual Behavior

No log message is provided upon an unsuccessful import of a ldif file.

Expected Behavior

A log message that warns the users that the configured ldif file does not exist

Configuration

<security:ldap-server
		id="local-ldap-server"
		ldif="file:${configpath}/uesrs.ldif"
		port="8389"
		root="dc=springframework,dc=org"
	/>

On the file system however, the file is: ${configpath}/users.ldif

Version

5.2.1.RELEASE

Sample

https://github.com/spring-projects/spring-security/blob/master/ldap/src/main/java/org/springframework/security/ldap/server/UnboundIdContainer.java

Metadata

Metadata

Assignees

Labels

in: ldapAn issue in spring-security-ldapstatus: ideal-for-contributionAn issue that we actively are looking for someone to help us withtype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions