44 * for the syntax of the disabled algorithm string. |
44 * for the syntax of the disabled algorithm string. |
45 */ |
45 */ |
46 public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { |
46 public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints { |
47 |
47 |
48 // the known security property, jdk.certpath.disabledAlgorithms |
48 // the known security property, jdk.certpath.disabledAlgorithms |
49 public final static String PROPERTY_CERTPATH_DISABLED_ALGS = |
49 public static final String PROPERTY_CERTPATH_DISABLED_ALGS = |
50 "jdk.certpath.disabledAlgorithms"; |
50 "jdk.certpath.disabledAlgorithms"; |
51 |
51 |
52 // the known security property, jdk.tls.disabledAlgorithms |
52 // the known security property, jdk.tls.disabledAlgorithms |
53 public final static String PROPERTY_TLS_DISABLED_ALGS = |
53 public static final String PROPERTY_TLS_DISABLED_ALGS = |
54 "jdk.tls.disabledAlgorithms"; |
54 "jdk.tls.disabledAlgorithms"; |
55 |
55 |
56 private final static Map<String, String[]> disabledAlgorithmsMap = |
56 private static final Map<String, String[]> disabledAlgorithmsMap = |
57 new HashMap<>(); |
57 new HashMap<>(); |
58 private final static Map<String, KeySizeConstraints> keySizeConstraintsMap = |
58 private static final Map<String, KeySizeConstraints> keySizeConstraintsMap = |
59 new HashMap<>(); |
59 new HashMap<>(); |
60 |
60 |
61 private final String[] disabledAlgorithms; |
61 private final String[] disabledAlgorithms; |
62 private final KeySizeConstraints keySizeConstraints; |
62 private final KeySizeConstraints keySizeConstraints; |
63 |
63 |
78 keySizeConstraints = getKeySizeConstraints(disabledAlgorithms, |
78 keySizeConstraints = getKeySizeConstraints(disabledAlgorithms, |
79 propertyName); |
79 propertyName); |
80 } |
80 } |
81 |
81 |
82 @Override |
82 @Override |
83 final public boolean permits(Set<CryptoPrimitive> primitives, |
83 public final boolean permits(Set<CryptoPrimitive> primitives, |
84 String algorithm, AlgorithmParameters parameters) { |
84 String algorithm, AlgorithmParameters parameters) { |
85 |
85 |
86 if (primitives == null || primitives.isEmpty()) { |
86 if (primitives == null || primitives.isEmpty()) { |
87 throw new IllegalArgumentException( |
87 throw new IllegalArgumentException( |
88 "No cryptographic primitive specified"); |
88 "No cryptographic primitive specified"); |
90 |
90 |
91 return checkAlgorithm(disabledAlgorithms, algorithm, decomposer); |
91 return checkAlgorithm(disabledAlgorithms, algorithm, decomposer); |
92 } |
92 } |
93 |
93 |
94 @Override |
94 @Override |
95 final public boolean permits(Set<CryptoPrimitive> primitives, Key key) { |
95 public final boolean permits(Set<CryptoPrimitive> primitives, Key key) { |
96 return checkConstraints(primitives, "", key, null); |
96 return checkConstraints(primitives, "", key, null); |
97 } |
97 } |
98 |
98 |
99 @Override |
99 @Override |
100 final public boolean permits(Set<CryptoPrimitive> primitives, |
100 public final boolean permits(Set<CryptoPrimitive> primitives, |
101 String algorithm, Key key, AlgorithmParameters parameters) { |
101 String algorithm, Key key, AlgorithmParameters parameters) { |
102 |
102 |
103 if (algorithm == null || algorithm.length() == 0) { |
103 if (algorithm == null || algorithm.length() == 0) { |
104 throw new IllegalArgumentException("No algorithm name specified"); |
104 throw new IllegalArgumentException("No algorithm name specified"); |
105 } |
105 } |