Reputation: 412
When am trying to authenticate the user through LDAP from database am getting the following error.
Reason: Cannot pass null or empty values to constructor.
Can anyone please tell me what am doing wrong?
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http auto-config="true">
<intercept-url pattern="/**" access="ROLE_USER,ROLE_ADMIN" />
<intercept-url pattern="/administrator.htm" access="ROLE_ADMIN" />
<!-- <form-login login-page="/dashboard.htm" default-target-url="/dashboard.htm" authentication-failure-url="/ExceptionPage.jsp" /> -->
<form-login/>
</http>
<authentication-manager>
<authentication-provider>
<!-- <user-service>
<user name="20022263" password="da" authorities="ROLE_USER" />
<user name="20039004" password="da" authorities="ROLE_ADMIN" />
</user-service> -->
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="SELECT a.GLOBALID AS username, a.PASSWORD AS password, a.Enabled AS enabled FROM EU_MAS_TBUSER a WHERE a.GLOBALID=?"
authorities-by-username-query="select eu.USERNAME AS username, r.ACCESSROLEID AS authority from EU_MAS_TBUSER eu, EU_MAS_TBUSERS_ROLE r where eu.GLOBALID = r.GLOBALID and eu.GLOBALID=?"
role-prefix="ROLE_"/>
</authentication-provider>
</authentication-manager>
</beans:beans>
Upvotes: 8
Views: 20394
Reputation: 21551
HTTP Status 401 : Cannot pass null or empty values to constructor
The server is expecting a query param but you are sending the wrong value in it.
So simpler answer is:
We need to send a valid query param what the server is expecting.
Upvotes: 0
Reputation: 22742
The actual line that produces the exception is here. The relevant code where the user object is created is here.
So my best guess is that you have a null password field for the user in the database.
Note that if you are posting an error like this it's a lot easier to answer if you give the stacktrace and the relevant debug output from the server log.
Upvotes: 29