ntlm - I want to login to a web page by passing credentials from java application -
i want login web page passing credentials java application? using below code getting error:
httpclient client = new httpclient(); client.getparams().setparameter("user name", "user"); client.getparams().setparameter("password", "password"); getmethod request = new getmethod("url");
error: info: no credentials available ntlm @192.168.224.142:7048
i have tried below code:
httpclient client = new httpclient(); client.getstate().setcredentials(authscope.any, new ntcredentials("user", "password", "ip:port", "http")); getmethod request = new getmethod("url");
error:info: failure authenticating ntlm
suggest way login web page passing credentials java application?.
you passing user credentials request parameters. website expects ntlm-based authentication (the username , password not sent server).
use org.apache.http.auth.ntcredentials
store username , password.
ntcredentials usercredentials = new ntcredentials(username, password, system.getproperty("computername"), domain); credentialsprovider credentialsprovider = new basiccredentialsprovider(); credentialsprovider.setcredentials(new authscope(authscope.any_host, authscope.any_port), usercredentials); httpclientcontext httpclientcontext = httpclientcontext.create(); httpclientcontext.setcredentialsprovider(credentialsprovider); httpclient httpclient = httpclientbuilder.create(). setdefaultcredentialsprovider(credentialsprovider).build();
feel free modify authscope
needs.
Comments
Post a Comment