Search in sources :

Example 1 with EjbInvokerConfiguration

use of fish.payara.ejb.http.admin.EjbInvokerConfiguration in project Payara by payara.

the class InvokeEJBServlet method init.

@Override
public void init() throws ServletException {
    EjbInvokerConfiguration config = Globals.getDefaultBaseServiceLocator().getService(EjbInvokerConfiguration.class);
    roles = config.getRoles().split(",");
    securityEnabled = Boolean.parseBoolean(config.getSecurityEnabled());
}
Also used : EjbInvokerConfiguration(fish.payara.ejb.http.admin.EjbInvokerConfiguration)

Example 2 with EjbInvokerConfiguration

use of fish.payara.ejb.http.admin.EjbInvokerConfiguration 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);
    }
}
Also used : ServletRegistration(javax.servlet.ServletRegistration) EjbInvokerConfiguration(fish.payara.ejb.http.admin.EjbInvokerConfiguration) HttpConstraintElement(javax.servlet.HttpConstraintElement) EjbOverHttpApplication(fish.payara.ejb.http.endpoint.EjbOverHttpApplication) ServletSecurityElement(javax.servlet.ServletSecurityElement) JerseyServletContainerInitializer(org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer)

Aggregations

EjbInvokerConfiguration (fish.payara.ejb.http.admin.EjbInvokerConfiguration)2 EjbOverHttpApplication (fish.payara.ejb.http.endpoint.EjbOverHttpApplication)1 HttpConstraintElement (javax.servlet.HttpConstraintElement)1 ServletRegistration (javax.servlet.ServletRegistration)1 ServletSecurityElement (javax.servlet.ServletSecurityElement)1 JerseyServletContainerInitializer (org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer)1