jetty authentication in Eclipse Luna [message #1700153] |
Tue, 30 June 2015 12:44 |
Peter Richards Messages: 10 Registered: June 2015 |
Junior Member |
|
|
Hello,
I am trying to set up basic authentication for a RAP application. I derive from JettyCustomizer the class shown below and add -Dorg.eclipse.equinox.http.jetty.customizer.class=rapauth.auth.BasicAuthCustomizer to the run configuration arguments.
I include this in the simple "RAP Hello World" application, which comes with Eclipse Luna.
However, when I run this RAP application inside Eclipse, I get this error:
java.lang.ClassNotFoundException: rapauth.auth.BasicAuthCustomizer cannot be found by org.eclipse.equinox.http.jetty_3.0.200.v20131021-1843
[...]
How do I configure an application so that org.eclipse.equinox.http.jetty will find my BasicAuthCustomizer?
The page http://wiki.eclipse.org/RAP/FAQ#How_can_I_use_Jetty_basic_authentication_in_my_application.3F says "In order for this class to be loaded correctly by the Eclipse code that customizes Jetty, you will need to put this class into a fragment that attaches to the org.eclipse.equinox.http.jetty bundle." I haven't worked with fragments before.
To add another question, other solutions explain how to set up authentication in an WEB-INF/web.xml or WEB-INF/jetty-web.xml. These two files seem to be ignored when I run my application inside eclipse. What needs to be changed so that it works?
Regards,
Peter
BasicAuthCustomizer.java:
package rapauth.auth;
import java.util.Dictionary;
import org.eclipse.equinox.http.jetty.JettyCustomizer;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.security.Constraint;
public class BasicAuthCustomizer extends JettyCustomizer {
@Override
public Object customizeContext(Object o, Dictionary<String, ?> settings) {
System.err.println("AUTHENTICATION");
Constraint constraint = new Constraint();
constraint.setName(Constraint.__BASIC_AUTH);
constraint.setRoles(new String[] { "admin" });
constraint.setAuthenticate(true);
ConstraintMapping mapping = new ConstraintMapping();
mapping.setConstraint(constraint);
mapping.setPathSpec("/*");
HashLoginService loginService = new HashLoginService("MyRealm");
loginService.setConfig("/tmp/users.properties");
ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
securityHandler.setLoginService(loginService);
securityHandler
.setConstraintMappings(new ConstraintMapping[] { mapping });
ServletContextHandler context = (ServletContextHandler) o;
context.setSecurityHandler(securityHandler);
return o;
}
}
MANIFEST.MF:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Rapauth
Bundle-SymbolicName: rapauth;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: rapauth.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.rap.ui;bundle-version="[2.0.0,3.0.0)",
org.eclipse.equinox.http.jetty;bundle-version="3.0.200",
org.eclipse.jetty.security;bundle-version="8.1.16",
org.eclipse.jetty.util;bundle-version="8.1.16",
org.eclipse.jetty.http;bundle-version="8.1.16",
org.eclipse.jetty.server;bundle-version="8.1.16",
org.eclipse.jetty.servlet;bundle-version="8.1.16"
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04214 seconds