Search in sources :

Example 1 with Container

use of org.apache.catalina.Container in project tomcat by apache.

the class SingleSignOn method expire.

private void expire(SingleSignOnSessionKey key) {
    if (engine == null) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.engineNull", key));
        return;
    }
    Container host = engine.findChild(key.getHostName());
    if (host == null) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.hostNotFound", key));
        return;
    }
    Context context = (Context) host.findChild(key.getContextName());
    if (context == null) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.contextNotFound", key));
        return;
    }
    Manager manager = context.getManager();
    if (manager == null) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.managerNotFound", key));
        return;
    }
    Session session = null;
    try {
        session = manager.findSession(key.getSessionId());
    } catch (IOException e) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.managerError", key), e);
        return;
    }
    if (session == null) {
        containerLog.warn(sm.getString("singleSignOn.sessionExpire.sessionNotFound", key));
        return;
    }
    session.expire();
}
Also used : Context(org.apache.catalina.Context) Container(org.apache.catalina.Container) IOException(java.io.IOException) StringManager(org.apache.tomcat.util.res.StringManager) Manager(org.apache.catalina.Manager) Session(org.apache.catalina.Session)

Example 2 with Container

use of org.apache.catalina.Container in project tomcat by apache.

the class SingleSignOn method startInternal.

@Override
protected synchronized void startInternal() throws LifecycleException {
    Container c = getContainer();
    while (c != null && !(c instanceof Engine)) {
        c = c.getParent();
    }
    if (c instanceof Engine) {
        engine = (Engine) c;
    }
    super.startInternal();
}
Also used : Container(org.apache.catalina.Container) Engine(org.apache.catalina.Engine)

Example 3 with Container

use of org.apache.catalina.Container in project tomcat by apache.

the class AuthenticatorBase method reauthenticateFromSSO.

/**
     * Attempts reauthentication to the <code>Realm</code> using the credentials
     * included in argument <code>entry</code>.
     *
     * @param ssoId
     *            identifier of SingleSignOn session with which the caller is
     *            associated
     * @param request
     *            the request that needs to be authenticated
     * @return <code>true</code> if the reauthentication from SSL occurred
     */
protected boolean reauthenticateFromSSO(String ssoId, Request request) {
    if (sso == null || ssoId == null) {
        return false;
    }
    boolean reauthenticated = false;
    Container parent = getContainer();
    if (parent != null) {
        Realm realm = parent.getRealm();
        if (realm != null) {
            reauthenticated = sso.reauthenticate(ssoId, realm, request);
        }
    }
    if (reauthenticated) {
        associate(ssoId, request.getSessionInternal(true));
        if (log.isDebugEnabled()) {
            log.debug(" Reauthenticated cached principal '" + request.getUserPrincipal().getName() + "' with auth type '" + request.getAuthType() + "'");
        }
    }
    return reauthenticated;
}
Also used : Container(org.apache.catalina.Container) Realm(org.apache.catalina.Realm)

Example 4 with Container

use of org.apache.catalina.Container in project tomcat by apache.

the class AuthenticatorBase method startInternal.

/**
     * Start this component and implement the requirements of
     * {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
     *
     * @exception LifecycleException
     *                if this component detects a fatal error that prevents this
     *                component from being used
     */
@Override
protected synchronized void startInternal() throws LifecycleException {
    ServletContext servletContext = context.getServletContext();
    jaspicAppContextID = servletContext.getVirtualServerName() + " " + servletContext.getContextPath();
    // Look up the SingleSignOn implementation in our request processing
    // path, if there is one
    Container parent = context.getParent();
    while ((sso == null) && (parent != null)) {
        Valve[] valves = parent.getPipeline().getValves();
        for (int i = 0; i < valves.length; i++) {
            if (valves[i] instanceof SingleSignOn) {
                sso = (SingleSignOn) valves[i];
                break;
            }
        }
        if (sso == null) {
            parent = parent.getParent();
        }
    }
    if (log.isDebugEnabled()) {
        if (sso != null) {
            log.debug("Found SingleSignOn Valve at " + sso);
        } else {
            log.debug("No SingleSignOn Valve is present");
        }
    }
    sessionIdGenerator = new StandardSessionIdGenerator();
    sessionIdGenerator.setSecureRandomAlgorithm(getSecureRandomAlgorithm());
    sessionIdGenerator.setSecureRandomClass(getSecureRandomClass());
    sessionIdGenerator.setSecureRandomProvider(getSecureRandomProvider());
    super.startInternal();
}
Also used : Container(org.apache.catalina.Container) StandardSessionIdGenerator(org.apache.catalina.util.StandardSessionIdGenerator) ServletContext(javax.servlet.ServletContext) Valve(org.apache.catalina.Valve) SecurityConstraint(org.apache.tomcat.util.descriptor.web.SecurityConstraint)

Example 5 with Container

use of org.apache.catalina.Container in project tomcat by apache.

the class ClusterSingleSignOn method startInternal.

// ------------------------------------------------------- Lifecycle Methods
/**
     * Start this component and implement the requirements
     * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
     *
     * @exception LifecycleException if this component detects a fatal error
     *  that prevents this component from being used
     */
@Override
protected synchronized void startInternal() throws LifecycleException {
    // Load the cluster component, if any
    try {
        if (cluster == null) {
            Container host = getContainer();
            if (host instanceof Host) {
                if (host.getCluster() instanceof CatalinaCluster) {
                    setCluster((CatalinaCluster) host.getCluster());
                }
            }
        }
        if (cluster == null) {
            throw new LifecycleException(sm.getString("clusterSingleSignOn.nocluster"));
        }
        ClassLoader[] cls = new ClassLoader[] { this.getClass().getClassLoader() };
        ReplicatedMap<String, SingleSignOnEntry> cache = new ReplicatedMap<>(this, cluster.getChannel(), rpcTimeout, cluster.getClusterName() + "-SSO-cache", cls, terminateOnStartFailure);
        cache.setChannelSendOptions(mapSendOptions);
        cache.setAccessTimeout(accessTimeout);
        this.cache = cache;
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        throw new LifecycleException(sm.getString("clusterSingleSignOn.clusterLoad.fail"), t);
    }
    super.startInternal();
}
Also used : Container(org.apache.catalina.Container) LifecycleException(org.apache.catalina.LifecycleException) CatalinaCluster(org.apache.catalina.ha.CatalinaCluster) SingleSignOnEntry(org.apache.catalina.authenticator.SingleSignOnEntry) Host(org.apache.catalina.Host) ReplicatedMap(org.apache.catalina.tribes.tipis.ReplicatedMap)

Aggregations

Container (org.apache.catalina.Container)125 Context (org.apache.catalina.Context)26 Host (org.apache.catalina.Host)20 Engine (org.apache.catalina.Engine)18 IOException (java.io.IOException)17 StandardContext (org.apache.catalina.core.StandardContext)17 ObjectName (javax.management.ObjectName)15 StandardHost (org.apache.catalina.core.StandardHost)13 Wrapper (org.apache.catalina.Wrapper)11 ArrayList (java.util.ArrayList)10 Valve (org.apache.catalina.Valve)10 SecurityConstraint (org.apache.tomcat.util.descriptor.web.SecurityConstraint)10 Realm (org.apache.catalina.Realm)9 File (java.io.File)8 LifecycleException (org.apache.catalina.LifecycleException)8 StandardWrapper (org.apache.catalina.core.StandardWrapper)8 ServletContext (javax.servlet.ServletContext)7 ServletException (javax.servlet.ServletException)7 Lifecycle (org.apache.catalina.Lifecycle)7 Service (org.apache.catalina.Service)7