Stay organized with collections
Save and categorize content based on your preferences.
AlgorithmConstraints
public
interface
AlgorithmConstraints
java.security.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.
Summary
Public methods
permits
public abstract boolean permits (Set<CryptoPrimitive> primitives,
String algorithm,
AlgorithmParameters parameters)
Determines whether an algorithm is granted permission for the
specified cryptographic primitives.
Parameters |
primitives |
Set : a set of cryptographic primitives |
algorithm |
String : the algorithm name |
parameters |
AlgorithmParameters : the algorithm parameters, or null if no additional
parameters |
Returns |
boolean |
true if the algorithm is permitted and can be used for all
of the specified cryptographic primitives |
permits
public abstract boolean permits (Set<CryptoPrimitive> primitives,
String algorithm,
Key key,
AlgorithmParameters parameters)
Determines whether an algorithm and the corresponding key are granted
permission for the specified cryptographic primitives.
Parameters |
primitives |
Set : a set of cryptographic primitives |
algorithm |
String : the algorithm name |
key |
Key : the key |
parameters |
AlgorithmParameters : the algorithm parameters, or null if no additional
parameters |
Returns |
boolean |
true if the key and the algorithm can be used for all of the
specified cryptographic primitives |
permits
public abstract boolean permits (Set<CryptoPrimitive> primitives,
Key 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 |
Set : a set of cryptographic primitives |
key |
Key : the key |
Returns |
boolean |
true if the key can be used for all of the specified
cryptographic primitives |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# AlgorithmConstraints\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nAlgorithmConstraints\n====================\n\n\n`\npublic\n\n\ninterface\nAlgorithmConstraints\n`\n\n\n`\n\n\n`\n\n|------------------------------------|\n| java.security.AlgorithmConstraints |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nThis interface specifies constraints for cryptographic algorithms,\nkeys (key sizes), and other algorithm parameters.\n\n\n`AlgorithmConstraints` objects are immutable. An implementation\nof this interface should not provide methods that can change the state\nof an instance once it has been created.\n\n\nNote that `AlgorithmConstraints` can be used to represent the\nrestrictions described by the security properties\n`jdk.certpath.disabledAlgorithms` and\n`jdk.tls.disabledAlgorithms`, or could be used by a\nconcrete `PKIXCertPathChecker` to check whether a specified\ncertificate in the certification path contains the required algorithm\nconstraints. \n**See also:**\n\n- [SSLParameters.getAlgorithmConstraints()](/reference/javax/net/ssl/SSLParameters#getAlgorithmConstraints())\n- [SSLParameters.setAlgorithmConstraints(AlgorithmConstraints)](/reference/javax/net/ssl/SSLParameters#setAlgorithmConstraints(java.security.AlgorithmConstraints))\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract boolean` | ` `[permits](/reference/java/security/AlgorithmConstraints#permits(java.util.Set\u003cjava.security.CryptoPrimitive\u003e,%20java.lang.String,%20java.security.AlgorithmParameters))`(`[Set](/reference/java/util/Set)`\u003c`[CryptoPrimitive](/reference/java/security/CryptoPrimitive)`\u003e primitives, `[String](/reference/java/lang/String)` algorithm, `[AlgorithmParameters](/reference/java/security/AlgorithmParameters)` parameters) ` Determines whether an algorithm is granted permission for the specified cryptographic primitives. |\n| ` abstract boolean` | ` `[permits](/reference/java/security/AlgorithmConstraints#permits(java.util.Set\u003cjava.security.CryptoPrimitive\u003e,%20java.lang.String,%20java.security.Key,%20java.security.AlgorithmParameters))`(`[Set](/reference/java/util/Set)`\u003c`[CryptoPrimitive](/reference/java/security/CryptoPrimitive)`\u003e primitives, `[String](/reference/java/lang/String)` algorithm, `[Key](/reference/java/security/Key)` key, `[AlgorithmParameters](/reference/java/security/AlgorithmParameters)` parameters) ` Determines whether an algorithm and the corresponding key are granted permission for the specified cryptographic primitives. |\n| ` abstract boolean` | ` `[permits](/reference/java/security/AlgorithmConstraints#permits(java.util.Set\u003cjava.security.CryptoPrimitive\u003e,%20java.security.Key))`(`[Set](/reference/java/util/Set)`\u003c`[CryptoPrimitive](/reference/java/security/CryptoPrimitive)`\u003e primitives, `[Key](/reference/java/security/Key)` key) ` Determines whether a key is granted permission for the specified cryptographic primitives. |\n\nPublic methods\n--------------\n\n### permits\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean permits (Set\u003cCryptoPrimitive\u003e primitives, \n String algorithm, \n AlgorithmParameters parameters)\n```\n\nDetermines whether an algorithm is granted permission for the\nspecified cryptographic primitives.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------------|---------------------------------------------------------------------------------------------|\n| `primitives` | `Set`: a set of cryptographic primitives \u003cbr /\u003e |\n| `algorithm` | `String`: the algorithm name \u003cbr /\u003e |\n| `parameters` | `AlgorithmParameters`: the algorithm parameters, or null if no additional parameters \u003cbr /\u003e |\n\n| Returns ||\n|-----------|-------------------------------------------------------------------------------------------------------------|\n| `boolean` | true if the algorithm is permitted and can be used for all of the specified cryptographic primitives \u003cbr /\u003e |\n\n| Throws ||\n|---------------------------------------------------------------------------|---------------------------------------------|\n| [IllegalArgumentException](/reference/java/lang/IllegalArgumentException) | if primitives or algorithm is null or empty |\n\n### permits\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean permits (Set\u003cCryptoPrimitive\u003e primitives, \n String algorithm, \n Key key, \n AlgorithmParameters parameters)\n```\n\nDetermines whether an algorithm and the corresponding key are granted\npermission for the specified cryptographic primitives.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------------|---------------------------------------------------------------------------------------------|\n| `primitives` | `Set`: a set of cryptographic primitives \u003cbr /\u003e |\n| `algorithm` | `String`: the algorithm name \u003cbr /\u003e |\n| `key` | `Key`: the key \u003cbr /\u003e |\n| `parameters` | `AlgorithmParameters`: the algorithm parameters, or null if no additional parameters \u003cbr /\u003e |\n\n| Returns ||\n|-----------|--------------------------------------------------------------------------------------------------------|\n| `boolean` | true if the key and the algorithm can be used for all of the specified cryptographic primitives \u003cbr /\u003e |\n\n| Throws ||\n|---------------------------------------------------------------------------|-----------------------------------------------------------------|\n| [IllegalArgumentException](/reference/java/lang/IllegalArgumentException) | if primitives or algorithm is null or empty, or the key is null |\n\n### permits\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean permits (Set\u003cCryptoPrimitive\u003e primitives, \n Key key)\n```\n\nDetermines whether a key is granted permission for the specified\ncryptographic primitives.\n\n\nThis method is usually used to check key size and key usage.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------------|-------------------------------------------------|\n| `primitives` | `Set`: a set of cryptographic primitives \u003cbr /\u003e |\n| `key` | `Key`: the key \u003cbr /\u003e |\n\n| Returns ||\n|-----------|--------------------------------------------------------------------------------------|\n| `boolean` | true if the key can be used for all of the specified cryptographic primitives \u003cbr /\u003e |\n\n| Throws ||\n|---------------------------------------------------------------------------|----------------------------------------------------|\n| [IllegalArgumentException](/reference/java/lang/IllegalArgumentException) | if primitives is null or empty, or the key is null |"]]