Search in sources :

Example 11 with GlassFishValve

use of org.glassfish.web.valve.GlassFishValve in project Payara by payara.

the class StandardContextValve method invoke.

/**
 * Select the appropriate child Wrapper to process this request,
 * based on the specified request URI.  If no matching Wrapper can
 * be found, return an appropriate HTTP error.
 *
 * @param request Request to be processed
 * @param response Response to be produced
 * @param valveContext Valve context used to forward to the next Valve
 *
 * @exception IOException if an input/output error occurred
 * @exception ServletException if a servlet error occurred
 */
@Override
public int invoke(Request request, Response response) throws IOException, ServletException {
    Wrapper wrapper = preInvoke(request, response);
    if (wrapper == null) {
        return END_PIPELINE;
    }
    // START GlassFish 1343
    if (wrapper.getPipeline().hasNonBasicValves() || wrapper.hasCustomPipeline()) {
        wrapper.getPipeline().invoke(request, response);
    } else {
        GlassFishValve basic = wrapper.getPipeline().getBasic();
        if (basic != null) {
            basic.invoke(request, response);
            basic.postInvoke(request, response);
        }
    }
    return END_PIPELINE;
}
Also used : GlassFishValve(org.glassfish.web.valve.GlassFishValve)

Example 12 with GlassFishValve

use of org.glassfish.web.valve.GlassFishValve in project Payara by payara.

the class StandardHost method configureStandardHostValve.

// ------------------------------------------------------ Private Methods
private void configureStandardHostValve(StandardHostValve host) {
    // Set error report valve
    if ((errorReportValveClass != null) && !"".equals(errorReportValveClass)) {
        try {
            GlassFishValve valve = (GlassFishValve) loadInstance(errorReportValveClass);
            /* START SJSAS 6374691
                addValve(valve);
                */
            // START SJSAS 6374691
            host.setErrorReportValve(valve);
        // END SJSAS 6374691
        } catch (Throwable t) {
            String msg = MessageFormat.format(rb.getString(LogFacade.LOAD_SPEC_ERROR_REPORT_EXCEPTION), errorReportValveClass);
            log.log(Level.SEVERE, msg, t);
        }
    }
}
Also used : GlassFishValve(org.glassfish.web.valve.GlassFishValve)

Example 13 with GlassFishValve

use of org.glassfish.web.valve.GlassFishValve in project Payara by payara.

the class VirtualServer method configureRemoteAddressFilterValve.

/**
 * Configures the Remote Address Filter valve of this VirtualServer.
 *
 * This valve enforces request accpetance/denial based on the string
 * representation of the remote client's IP address.
 */
protected void configureRemoteAddressFilterValve(String allow, String deny) {
    RemoteAddrValve remoteAddrValve = null;
    if (allow != null || deny != null) {
        remoteAddrValve = new RemoteAddrValve();
    }
    if (allow != null) {
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, LogFacade.ALLOW_ACCESS, new Object[] { getID(), allow });
        }
        remoteAddrValve.setAllow(allow);
    }
    if (deny != null) {
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, LogFacade.DENY_ACCESS, new Object[] { getID(), deny });
        }
        remoteAddrValve.setDeny(deny);
    }
    if (remoteAddrValve != null) {
        // Remove existing RemoteAddrValve (if any), in case of a reconfig
        GlassFishValve[] valves = getValves();
        for (int i = 0; valves != null && i < valves.length; i++) {
            if (valves[i] instanceof RemoteAddrValve) {
                removeValve(valves[i]);
                break;
            }
        }
        addValve((GlassFishValve) remoteAddrValve);
    }
}
Also used : RemoteAddrValve(org.apache.catalina.valves.RemoteAddrValve) GlassFishValve(org.glassfish.web.valve.GlassFishValve)

Example 14 with GlassFishValve

use of org.glassfish.web.valve.GlassFishValve in project Payara by payara.

the class VirtualServer method configureSingleSignOn.

/**
 * Configures the SSO valve of this VirtualServer.
 */
void configureSingleSignOn(boolean globalSSOEnabled, WebContainerFeatureFactory webContainerFeatureFactory, boolean ssoFailoverEnabled) {
    if (!isSSOEnabled(globalSSOEnabled)) {
        /*
             * Disable SSO
             */
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, LogFacade.DISABLE_SSO, getID());
        }
        boolean hasExistingSSO = false;
        // Remove existing SSO valve (if any)
        GlassFishValve[] valves = getValves();
        for (int i = 0; valves != null && i < valves.length; i++) {
            if (valves[i] instanceof SingleSignOn) {
                removeValve(valves[i]);
                hasExistingSSO = true;
                break;
            }
        }
        this.ssoFailoverEnabled = ssoFailoverEnabled;
        if (hasExistingSSO) {
            setSingleSignOnForChildren(null);
        }
    } else {
        /*
             * Enable SSO
             */
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, LogFacade.ENABLE_SSO, getID());
        }
        GlassFishSingleSignOn sso = null;
        // find existing SSO (if any), in case of a reconfig
        GlassFishValve[] valves = getValves();
        for (int i = 0; valves != null && i < valves.length; i++) {
            if (valves[i] instanceof GlassFishSingleSignOn) {
                sso = (GlassFishSingleSignOn) valves[i];
                break;
            }
        }
        if (sso != null && this.ssoFailoverEnabled != ssoFailoverEnabled) {
            removeValve(sso);
            sso = null;
        // then SSO Valve will be recreated
        }
        if (sso == null) {
            SSOFactory ssoFactory = webContainerFeatureFactory.getSSOFactory();
            sso = ssoFactory.createSingleSignOnValve(getName());
            this.ssoFailoverEnabled = ssoFailoverEnabled;
            setSingleSignOnForChildren(sso);
            addValve((GlassFishValve) sso);
        }
        // set max idle time if given
        Property idle = vsBean.getProperty(SSO_MAX_IDLE);
        if (idle != null && idle.getValue() != null) {
            if (_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE, LogFacade.SSO_MAX_INACTIVE_SET, new Object[] { idle.getValue(), getID() });
            }
            sso.setMaxInactive(Integer.parseInt(idle.getValue()));
        }
        // set expirer thread sleep time if given
        Property expireTime = vsBean.getProperty(SSO_REAP_INTERVAL);
        if (expireTime != null && expireTime.getValue() != null) {
            if (_logger.isLoggable(Level.FINE)) {
                _logger.log(Level.FINE, LogFacade.SSO_REAP_INTERVAL_SET);
            }
            sso.setReapInterval(Integer.parseInt(expireTime.getValue()));
        }
        configureSingleSignOnCookieSecure();
        configureSingleSignOnCookieHttpOnly();
    }
}
Also used : GlassFishSingleSignOn(com.sun.enterprise.security.web.GlassFishSingleSignOn) Property(org.jvnet.hk2.config.types.Property) GlassFishValve(org.glassfish.web.valve.GlassFishValve) SingleSignOn(org.apache.catalina.authenticator.SingleSignOn) GlassFishSingleSignOn(com.sun.enterprise.security.web.GlassFishSingleSignOn)

Example 15 with GlassFishValve

use of org.glassfish.web.valve.GlassFishValve in project Payara by payara.

the class DynamicWebServletRegistrationImpl method addValve.

/**
 * Constructs a <tt>Valve</tt> from the given <tt>valveDescriptor</tt>
 * and adds it to the <tt>Pipeline</tt> of this WebModule.
 * @param valveDescriptor the object containing the information to
 * create the valve.
 */
protected void addValve(org.glassfish.web.deployment.runtime.Valve valveDescriptor) {
    String valveName = valveDescriptor.getAttributeValue(org.glassfish.web.deployment.runtime.Valve.NAME);
    String className = valveDescriptor.getAttributeValue(org.glassfish.web.deployment.runtime.Valve.CLASS_NAME);
    if (valveName == null) {
        logger.log(Level.WARNING, LogFacade.VALVE_MISSING_NAME, getName());
        return;
    }
    if (className == null) {
        logger.log(Level.WARNING, LogFacade.VALVE_MISSING_CLASS_NAME, new Object[] { valveName, getName() });
        return;
    }
    Object valve = loadInstance(className);
    if (valve == null) {
        return;
    }
    if (!(valve instanceof GlassFishValve) && !(valve instanceof Valve)) {
        logger.log(Level.WARNING, LogFacade.VALVE_CLASS_NAME_NO_VALVE, className);
        return;
    }
    WebProperty[] props = valveDescriptor.getWebProperty();
    if (props != null && props.length > 0) {
        for (WebProperty property : props) {
            String propName = getSetterName(property.getAttributeValue(WebProperty.NAME));
            if (propName != null && propName.length() != 0) {
                String value = property.getAttributeValue(WebProperty.VALUE);
                try {
                    Method method = valve.getClass().getMethod(propName, String.class);
                    method.invoke(valve, value);
                } catch (NoSuchMethodException ex) {
                    String msg = rb.getString(LogFacade.VALVE_SPECIFIED_METHOD_MISSING);
                    msg = MessageFormat.format(msg, new Object[] { propName, valveName, getName() });
                    logger.log(Level.SEVERE, msg, ex);
                } catch (Throwable t) {
                    String msg = rb.getString(LogFacade.VALVE_SETTER_CAUSED_EXCEPTION);
                    msg = MessageFormat.format(msg, new Object[] { propName, valveName, getName() });
                    logger.log(Level.SEVERE, msg, t);
                }
            } else {
                logger.log(Level.WARNING, LogFacade.VALVE_MISSING_PROPERTY_NAME, new Object[] { valveName, getName() });
                return;
            }
        }
    }
    if (valve instanceof Valve) {
        super.addValve((Valve) valve);
    } else if (valve instanceof GlassFishValve) {
        super.addValve((GlassFishValve) valve);
    }
}
Also used : WebProperty(org.glassfish.web.deployment.runtime.WebProperty) GlassFishValve(org.glassfish.web.valve.GlassFishValve) Valve(org.apache.catalina.Valve) Method(java.lang.reflect.Method) GlassFishValve(org.glassfish.web.valve.GlassFishValve)

Aggregations

GlassFishValve (org.glassfish.web.valve.GlassFishValve)16 SecurityConstraint (org.apache.catalina.deploy.SecurityConstraint)3 Method (java.lang.reflect.Method)2 ServletException (javax.servlet.ServletException)2 ContainerBase (org.apache.catalina.core.ContainerBase)2 LoginConfig (org.apache.catalina.deploy.LoginConfig)2 ProxyHandler (com.sun.appserv.ProxyHandler)1 Config (com.sun.enterprise.config.serverbeans.Config)1 SecurityService (com.sun.enterprise.config.serverbeans.SecurityService)1 WebServiceEndpoint (com.sun.enterprise.deployment.WebServiceEndpoint)1 LoginConfiguration (com.sun.enterprise.deployment.web.LoginConfiguration)1 SecurityConstraint (com.sun.enterprise.deployment.web.SecurityConstraint)1 UserDataConstraint (com.sun.enterprise.deployment.web.UserDataConstraint)1 WebResourceCollection (com.sun.enterprise.deployment.web.WebResourceCollection)1 RealmInitializer (com.sun.enterprise.security.integration.RealmInitializer)1 GlassFishSingleSignOn (com.sun.enterprise.security.web.GlassFishSingleSignOn)1 LoginConfigDecorator (com.sun.enterprise.web.deploy.LoginConfigDecorator)1 IOException (java.io.IOException)1 String (java.lang.String)1 CertificateException (java.security.cert.CertificateException)1