# AlgorithmConstraints

public interface **AlgorithmConstraints** This interface specifies constraints for cryptographic algorithms,
keys (key sizes), and other algorithm parameters.


`AlgorithmConstraints` objects are immutable. An implementation
of this interface should not provide methods that can change the state
of an instance once it has been created.


Note that `AlgorithmConstraints` can be used to represent the
restrictions described by the security properties
`jdk.certpath.disabledAlgorithms` and
`jdk.tls.disabledAlgorithms`, or could be used by a
concrete `PKIXCertPathChecker` to check whether a specified
certificate in the certification path contains the required algorithm
constraints.

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLParameters.html#getAlgorithmConstraints()`
- `https://developers.google.com/j2objc/javadoc/jre/reference/javax/net/ssl/SSLParameters.html#setAlgorithmConstraints(java.security.AlgorithmConstraints)`

### Public Method Summary

|---|---|
| abstract boolean | [permits](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AlgorithmConstraints.html#permits(java.util.Set<java.security.CryptoPrimitive>,%20java.lang.String,%20java.security.AlgorithmParameters))([Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[CryptoPrimitive](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/CryptoPrimitive.html)\> primitives, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) algorithm, [AlgorithmParameters](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AlgorithmParameters.html) parameters) Determines whether an algorithm is granted permission for the specified cryptographic primitives. |
| abstract boolean | [permits](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AlgorithmConstraints.html#permits(java.util.Set<java.security.CryptoPrimitive>,%20java.lang.String,%20java.security.Key,%20java.security.AlgorithmParameters))([Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[CryptoPrimitive](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/CryptoPrimitive.html)\> primitives, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) algorithm, [Key](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Key.html) key, [AlgorithmParameters](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AlgorithmParameters.html) parameters) Determines whether an algorithm and the corresponding key are granted permission for the specified cryptographic primitives. |
| abstract boolean | [permits](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AlgorithmConstraints.html#permits(java.util.Set<java.security.CryptoPrimitive>,%20java.security.Key))([Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[CryptoPrimitive](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/CryptoPrimitive.html)\> primitives, [Key](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Key.html) key) Determines whether a key is granted permission for the specified cryptographic primitives. |

## Public Methods

#### public abstract boolean
**permits**
([Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[CryptoPrimitive](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/CryptoPrimitive.html)\> primitives, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) algorithm, [AlgorithmParameters](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AlgorithmParameters.html) parameters)

Determines whether an algorithm is granted permission for the
specified cryptographic primitives.

##### Parameters

| primitives | a set of cryptographic primitives |
| algorithm | the algorithm name |
| parameters | the algorithm parameters, or null if no additional parameters |
|---|---|

##### Returns

- true if the algorithm is permitted and can be used for all of the specified cryptographic primitives

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if primitives or algorithm is null or empty |
|---|---|

#### public abstract boolean
**permits**
([Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[CryptoPrimitive](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/CryptoPrimitive.html)\> primitives, [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) algorithm, [Key](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Key.html) key, [AlgorithmParameters](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/AlgorithmParameters.html) parameters)

Determines whether an algorithm and the corresponding key are granted
permission for the specified cryptographic primitives.

##### Parameters

| primitives | a set of cryptographic primitives |
| algorithm | the algorithm name |
| key | the key |
| parameters | the algorithm parameters, or null if no additional parameters |
|---|---|

##### Returns

- true if the key and the algorithm can be used for all of the specified cryptographic primitives

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if primitives or algorithm is null or empty, or the key is null |
|---|---|

#### public abstract boolean
**permits**
([Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[CryptoPrimitive](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/CryptoPrimitive.html)\> primitives, [Key](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/Key.html) key)

Determines whether a key is granted permission for the specified
cryptographic primitives.


This method is usually used to check key size and key usage.

##### Parameters

| primitives | a set of cryptographic primitives |
| key | the key |
|---|---|

##### Returns

- true if the key can be used for all of the specified cryptographic primitives

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if primitives is null or empty, or the key is null |
|---|---|