Search in sources :

Example 1 with GlassFishSingleSignOn

use of com.sun.enterprise.security.web.GlassFishSingleSignOn 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)

Aggregations

GlassFishSingleSignOn (com.sun.enterprise.security.web.GlassFishSingleSignOn)1 SingleSignOn (org.apache.catalina.authenticator.SingleSignOn)1 GlassFishValve (org.glassfish.web.valve.GlassFishValve)1 Property (org.jvnet.hk2.config.types.Property)1