Quantcast

Pax Web Whiteboard Karaf 3.0.7

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Pax Web Whiteboard Karaf 3.0.7

sekaijin
This post was updated on .
Hi
I'm using Pax Web Whiteboard for my application.
I've 2 bundles
Main and Queues
each bundle define a contextMaping with same path
      DefaultHttpContextMapping httpContextMap = new DefaultHttpContextMapping();
      httpContextMap.setHttpContextId(module.getContextId());
      httpContextMap.setPath(module.getContextPath());

      ServiceRegistration<?> 
      registration =
         bundleContext.registerService(HttpContextMapping.class.getName(), httpContextMap, null);
These bundles start serving correctly.
> web:list
ID  | State       | Web-State   | Level | Web-ContextPath | Name
------------------------------------------------------------------------------------------------------
312 | Active      | Unknown     | 80    | /pantheon       | Pantheon :: Web :: Main (1.0.0.SNAPSHOT)
313 | Active      | Unknown     | 80    | /pantheon       | Pantheon :: Web :: Queues (1.0.0.SNAPSHOT)
Everything works fine.
I'm now trying to add an authentication using the default realms.
I don't have web.xml in my bundles
I don't have WebContainer or WebApplication object.
Everything is created by whiteboard.
I found an example of adding realms but using Pax Web API.
But I do not have access to the internal whitboard object.
         String authMethod = "BASIC";
         String realmName = "karaf";
         String formLoginPage = null;
         String formErrorPage = null;
         webContainer.registerLoginConfig(authMethod, realmName, formLoginPage, formErrorPage, httpContext);
         String constraintName = module.getModuleName();
         String url = "/"+module.getContextPath();
         String mapping = null;
         String dataConstraint = null;
         boolean authentication = true;
         java.util.List<String> roles = Arrays.asList(new String[] {"*"});
         webContainer.registerConstraintMapping(constraintName, url, mapping, dataConstraint, authentication, roles,
            httpContext);
I tried to use the context of the HttpContextMapping but this one is null.
      httpContext= httpContextMap.getHttpContext();
I did not find an example with Pax Web Whiteboard. I did not find anything on how to do it in the doc.
Howto s├ęcure my App ?

Thank
JYT
Loading...