Jetty + Programph SPNEGO Configuration

I am trying to configure the Jetty Embedded Web Server to use SPNEGO programmatically (without xml).

I am trying to convert this: http://www.eclipse.org/jetty/documentation/current/spnego-support.html to a configuration other than xml. Here is my attempt:

AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); // ... String domainRealm = "MY.DOMAIN.COM"; Constraint constraint = new Constraint(); constraint.setName(Constraint.__SPNEGO_AUTH); constraint.setRoles(new String[] { domainRealm }); constraint.setAuthenticate(true); ConstraintMapping cm = new ConstraintMapping(); cm.setConstraint(constraint); cm.setPathSpec("/*"); SpnegoLoginService loginService = new SpnegoLoginService(); loginService.setConfig(System.getProperty("spnego.properties")); loginService.setName(domainRealm); ConstraintSecurityHandler sh = new ConstraintSecurityHandler(); sh.setLoginService(loginService); sh.setConstraintMappings(new ConstraintMapping[]{cm}); sh.setRealmName(domainRealm); ServletContextHandler contextHandler = new ServletContextHandler(); contextHandler.setErrorHandler(new ErrorHandler() { }); // TODO contextHandler.setContextPath(contextPath); contextHandler.addServlet(new ServletHolder(new DispatcherServlet(context)), "/*"); contextHandler.addEventListener(new ContextLoaderListener(context)); contextHandler.setSecurityHandler(sh); Server server = new Server(port); server.setHandler(contextHandler); 

However, when I got to the server, it tries to use basic authentication (base 64).

Any ideas?

+5
source share
1 answer

In your ConstraintSecurityHandler, you need to install an authenticator for use with SpnegoAuthenticator.

https://github.com/eclipse/jetty.project/blob/master/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/SpnegoAuthenticator.java

+1
source

Source: https://habr.com/ru/post/1202155/


All Articles