jax ws - Apply HTTP basic authentication to jax ws (HttpSpiContextHandler) in embedded Jetty -


there similar questions earlier versions of jetty (pre 9) none address specific problem :

server server = new server(); system.setproperty("com.sun.net.httpserver.httpserverprovider",      jettyhttpserverprovider.class.getname());  jettyhttpserver jettyserver = new jettyhttpserver(server, true); endpoint endpoint = endpoint.create(new soapservice()); // class handle ws requests endpoint.publish(jettyserver.createcontext("/service")); // access path server.start() 

simplified code example above show way have found bridge between jetty , incoming soap requests jax-ws service. settings in code no web.xml, part of larger solution has multiple contexts , connections different purposes (servlets etc..)

i have tried add handler class jettyserver.createcontext("/service",new handler()) see if can perform header extraction simulate basic auth never gets executed.

my problem cannot find way specify, code against jetty server, use basic authentication. using setsecurityhandler method of servletcontexthandler easy , works great other contexts, can't figure out how use concept jax-ws service. appreciated.

p.s. ssl implemented, need add http basic auth.

for else may of come across same problem here answer stumbled on eventually.

final httpcontext httpcontext = jettyserver.createcontext("/service"); com.sun.net.httpserver.basicauthenticator = new com.sun.net.httpserver.basicauthenticator("") {                 public boolean checkcredentials (string username, string pw)                  {                     return username.equals("username") && pw.equals("password");                 }             }; httpcontext.setauthenticator(a); endpoint.publish(httpcontext);//access path 

you can expand checkcredentials bit more sophisticated of course, shows basic working method.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -