org.bouncycastle.crypto.constraints.ServicesConstraint Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-jdk15to18 Show documentation
Show all versions of bcprov-jdk15to18 Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.8.
package org.bouncycastle.crypto.constraints;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.logging.Logger;
import org.bouncycastle.crypto.CryptoServicesConstraints;
import org.bouncycastle.util.Strings;
/**
* Base class for a constraint, serves to provide storage for the set of exceptions (if any).
*/
abstract public class ServicesConstraint
implements CryptoServicesConstraints
{
protected static final Logger LOG = Logger.getLogger(ServicesConstraint.class.getName());
private final Set exceptions;
protected ServicesConstraint(Set exceptions)
{
if (exceptions.isEmpty())
{
this.exceptions = Collections.EMPTY_SET;
}
else
{
this.exceptions = new HashSet(exceptions.size());
for (Iterator it = exceptions.iterator(); it.hasNext();)
{
this.exceptions.add(Strings.toUpperCase(it.next().toString()));
}
Utils.addAliases(this.exceptions);
}
}
protected boolean isException(String algorithm)
{
if (exceptions.isEmpty())
{
return false;
}
return exceptions.contains(Strings.toUpperCase(algorithm));
}
}