Search in sources :

Example 1 with IParentAwareSecurityContext

use of org.apereo.portal.security.IParentAwareSecurityContext in project uPortal by Jasig.

the class ChainingSecurityContext method authenticate.

/**
     * We walk the chain of subcontexts assigning principals and opaqueCredentials from the parent.
     * Note that the contexts themselves should resist actually performing the assignment if an
     * assignment has already been made to either the credentials or the UID.
     */
public synchronized void authenticate() throws PortalSecurityException {
    int i;
    Enumeration e = mySubContexts.elements();
    while (e.hasMoreElements()) {
        ISecurityContext sctx = ((Entry) e.nextElement()).getCtx();
        // The principal and credential are now set for all subcontexts in Authentication
        try {
            if (sctx instanceof IParentAwareSecurityContext) {
                ((IParentAwareSecurityContext) sctx).authenticate(this);
            } else {
                sctx.authenticate();
            }
        } catch (Exception ex) {
            log.error("Exception authenticating subcontext " + sctx, ex);
        }
        // Stop attempting to authenticate if authenticated and if the property flag is set
        if (stopWhenAuthenticated && sctx.isAuthenticated()) {
            break;
        }
    }
    // Zero out the actual credentials if it isn't already null
    if (this.myOpaqueCredentials.credentialstring != null) {
        for (i = 0; i < this.myOpaqueCredentials.credentialstring.length; i++) this.myOpaqueCredentials.credentialstring[i] = 0;
        myOpaqueCredentials.credentialstring = null;
    }
    return;
}
Also used : Enumeration(java.util.Enumeration) IParentAwareSecurityContext(org.apereo.portal.security.IParentAwareSecurityContext) ISecurityContext(org.apereo.portal.security.ISecurityContext) PortalSecurityException(org.apereo.portal.security.PortalSecurityException)

Aggregations

Enumeration (java.util.Enumeration)1 IParentAwareSecurityContext (org.apereo.portal.security.IParentAwareSecurityContext)1 ISecurityContext (org.apereo.portal.security.ISecurityContext)1 PortalSecurityException (org.apereo.portal.security.PortalSecurityException)1