net.unicon.cas.mfa.authentication.DefaultCompositeAuthentication Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cas-mfa-java Show documentation
Show all versions of cas-mfa-java Show documentation
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.
package net.unicon.cas.mfa.authentication;
import net.unicon.cas.mfa.authentication.principal.MutablePrincipal;
import net.unicon.cas.mfa.util.MultiFactorUtils;
import org.jasig.cas.authentication.principal.Principal;
import java.util.Date;
import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
/**
* A {@link CompositeAuthentication} implementation that houses an instance of
* {@link MutablePrincipal} inside, restricts the {@link #getAuthenticatedDate()} to
* the instance at which this authentication is created and exposes a mutable
* instance of authentication attributes via {@link #getAttributes()}.
* @author Misagh Moayyed
*/
public final class DefaultCompositeAuthentication implements CompositeAuthentication {
private static final long serialVersionUID = 6594344317585898494L;
private final MutablePrincipal principal;
private final Date authenticationDate = new Date();
private final Map authenticationAttributes;
/**
* Initialize this instance with a principal and given authentication attributes.
* @param p the principal
* @param attributes attributes for this authentication
*/
public DefaultCompositeAuthentication(final MutablePrincipal p, final Map attributes) {
this.principal = p;
this.authenticationAttributes = attributes;
}
/**
* Initialize this instance with a principal and an empty {@link Hashtable}.
* for attributes.
* @param p the principal
*/
public DefaultCompositeAuthentication(final MutablePrincipal p) {
this(p, new Hashtable());
}
@Override
public Principal getPrincipal() {
return this.principal;
}
@Override
public Date getAuthenticatedDate() {
return this.authenticationDate;
}
@Override
public Map getAttributes() {
return this.authenticationAttributes;
}
@Override
public Set getSatisfiedAuthenticationMethods() {
return MultiFactorUtils.getSatisfiedAuthenticationMethods(this);
}
}