authentication - What was I wrong when using Jersey Client to authenticate an Spring Security web application? -


i have web application protected spring security login form authentication. want use jersey client authenticate web pages , think should pass through login form on normal browser.

my client authentication code below

    client client = clientbuilder.newclient();     webtarget target = client.target("http://localhost:8080/authentication-inmem/j_spring_security_check");     form form = new form();     form.param("j_username", "car");     form.param("j_password", "scarvarez");      response response =  target.request()     .post(entity.entity(form, mediatype.application_form_urlencoded_type));     system.out.println(response.getstatus()); 

this code produces 404 status code. when type link http://localhost:8080/authentication-inmem/j_spring_security_check browser or modify above code request. receive html code authentication login form. hence, don't know why url not found post?

hope show me wrong here, , moreover, doing proper way authenticate server without using browser?

i have found answer, default jersey client automatically redirect receives response status 3xx. (in case 302). now, turn off feature bit configuration ahead, , status 302 display on console.

clientconfig clientconfig = new clientconfig(); clientconfig.property(clientproperties.follow_redirects, false); client client = clientbuilder.newclient(clientconfig); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -