use of org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer in project Payara by payara.
the class EjbInvokerContainerInitializer method onStartup.
@Override
public void onStartup(Set<Class<?>> set, ServletContext ctx) throws ServletException {
EjbInvokerConfiguration config = Globals.getDefaultBaseServiceLocator().getService(EjbInvokerConfiguration.class);
String endpoint = ctx.getContextPath();
if (endpoint.startsWith("/")) {
endpoint = endpoint.substring(1);
}
if (!config.getEndpoint().equals(endpoint)) {
return;
}
if (Boolean.parseBoolean(config.getSecurityEnabled())) {
String[] roles = config.getRoles().split(",");
ServletRegistration.Dynamic reg = (ServletRegistration.Dynamic) ctx.getServletRegistration(EjbOverHttpApplication.class.getName());
if (reg == null) {
new JerseyServletContainerInitializer().onStartup(new HashSet<>(asList(EjbOverHttpApplication.class)), ctx);
reg = (ServletRegistration.Dynamic) ctx.getServletRegistration(EjbOverHttpApplication.class.getName());
}
reg.setServletSecurity(new ServletSecurityElement(new HttpConstraintElement(CONFIDENTIAL, roles)));
if (FORM_AUTH.equals(config.getAuthType())) {
ServletRegistration defaultRegistration = ctx.getServletRegistration("default");
defaultRegistration.addMapping("/login.xhtml");
defaultRegistration.addMapping("/error.xhtml");
}
ctx.declareRoles(roles);
}
}
Aggregations