0

I am trying to use spring security in my application developing restful web services and not getting the way how to send request to j_spring_security_check directly so that i can provide same url as a web service to Authorization of username and password.

Currently i am using following request pattern:

URL: "http://localhost:8080/CabFMS/j_spring_security_check" Content-type: application/x-www-form-urlencoded Body: {'j_username':'user','j_password':'123'}

Response: is Bad credentials

I am not sure about Content-type and body parameters. Please provide suggestion. To send request i am using REST Client

Tarun Gupta

Tarun Gupta
  • 1,232
  • 2
  • 13
  • 26

3 Answers3

1

As you correctly noticed j_spring_security_checks expects application/x-www-form-urlencoded content, therefore you need to encode it as such:

j_username=user&j_password=123
axtavt
  • 239,438
  • 41
  • 511
  • 482
  • Its working fine thanks for revert..but how i will authenticate for further requested web services. Is there any session ID mechanism support form spring security. If yes how to get that – Tarun Gupta Oct 22 '12 at 10:38
0

Your request pattern should be :

/j_spring_security_check?j_username=user&j_password=123

with method "POST" type.

other then this you can change request action & parameters text "j_spring_security_check" and "j_username" ,"j_password" by configuring alternate text in attributes :

login-processing-url, username-parameter, password-parameter

of spring "form-login" tag in security configuration xml file.

Mike Clark
  • 1,860
  • 14
  • 21
0

Create an AuthenticationSuccessHadler for this, in the authenticationSuccess method, return base64 encoded authorization header with the pattern username:password

Then, on each request, set the header as Basic yourtokenhere

AlbertoRuvel
  • 356
  • 4
  • 14