All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.unicon.cas.mfa.authentication.principal.ChainingCredentialsToPrincipalResolver Maven / Gradle / Ivy

Go to download

This module is intended to include all the Java you need to add to a CAS implementation to take advantage of the extended multifactor authentication features in this project.

There is a newer version: 2.0.0-RC3
Show newest version
package net.unicon.cas.mfa.authentication.principal;

import org.jasig.cas.authentication.principal.Credentials;
import org.jasig.cas.authentication.principal.CredentialsToPrincipalResolver;
import org.jasig.cas.authentication.principal.Principal;

import java.util.Iterator;
import java.util.List;

/**
 * This is {@link ChainingCredentialsToPrincipalResolver} that chains a number of
 * principal resolvers together.
 *
 * @author Misagh Moayyed
 */
public final class ChainingCredentialsToPrincipalResolver implements CredentialsToPrincipalResolver {
    private List chain;

    @Override
    public Principal resolvePrincipal(final Credentials credentials) {
        final Iterator it = this.chain.iterator();
        while (it.hasNext()) {
            final CredentialsToPrincipalResolver resolver = it.next();
            if (resolver.supports(credentials)) {
                final Principal p = resolver.resolvePrincipal(credentials);
                if (p != null) {
                    return p;
                }
            }
        }
        return null;
    }

    @Override
    public boolean supports(final Credentials credentials) {
        return true;
    }

    public void setChain(final List chain) {
        this.chain = chain;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy