-
Notifications
You must be signed in to change notification settings - Fork 487
NullPointerException thrown if principal or credentials are null #538
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Thanks for raising the issue in spring-ldap @philwebb. Just some extra info. There could be a guard when setting the user and password in the |
Thanks for the report @philwebb I don't think I agree with not adding null entries. If the credentials are null and |
@rwinch I'd have to defer to @filiphr on that. My original understanding of the issue was that if the credentials are I guess a better exception message is needed regardless. Perhaps it's just a case of doing |
BTW, we fixed Boot in the meantime to not call the setters with |
Was looking at the master code of spring-ldap and I saw that this should not be an issue anymore if the user is set to However, if the user is set and the password is somehow set to The logging message if the password has no text is a bit misleading as well
Which is not quite correct by looking at the code. Since the |
Thanks for the additional details @filiphr and @philwebb! A better error message would be useful.
I don't think this will help much since the values are null by default. This means if a user doesn't set them at all, the improved error message wouldn't be used. @filiphr Would you be interested in sending a PR to clean up the error message and logging? |
@rwinch yes I can try to craft a PR, but what I don't get what the resolution is now? If you ask me the fix should be in spring-ldap/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java Lines 680 to 689 in 15142d4
And return empty string if the btw the values are empty string by default, not |
Hi, @filiphr. I think the fix is based on Rob's comment here:
Given that, empty creds should not be inferred from null creds. Instead, the application should error to alert the user.
I can see your point here, though I believe there is a difference between the framework inferring an empty string and the context source setting a different value than what the application asked for. That is, calling |
Originally raised in spring-projects/spring-boot#17861
The
org.springframework.ldap.core.support.AbstractContextSource
class has asetupAuthenticatedEnvironment
which is passed aprincipal
andcredentials
. If either of these arenull
aNullPointerException
is thrown becausenull
values are not permitted in aHashtable
.I think it might be better if
DirContextAuthenticationStrategy
implementations could guard againstnull
values and not add entries in such cases.The text was updated successfully, but these errors were encountered: