I am developing website(HTML, javascript, jQuery, Ajax, css) in which, I am using basic authentication in spring in server side. I am sending Basic="Base64 Endcoded Username & password" in Authorization header of HTTP request. Login works fine on correct username & password. But on failure, it shows me a default prompt to enter a username & password. What can I do to so that prompt is not shown, Instead I should get a error code. So that, I can display proper failure message.
Spring Security
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.3.xsd">
<http create-session="never">
<intercept-url pattern="/rest/user*" access="ROLE_USER" />
<logout logout-success-url="/index.jsp" invalidate-session="true" />
<http-basic />
</http>
<authentication-manager>
<authentication-provider>
<password-encoder hash="md5"/>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="
select UserName as username, Password as user_password,true
from User where username=?"
authorities-by-username-query="
select UserName as username,'ROLE_USER' from User where username=?"
/>
</authentication-provider>
</authentication-manager>