jdk/src/java.base/share/classes/java/security/AlgorithmConstraints.java
author coleenp
Wed, 30 Aug 2017 19:18:22 -0400
changeset 47098 e704f55561c3
parent 25859 3317bb8137f4
permissions -rw-r--r--
8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp Summary: Use load_acquire for accessing DictionaryEntry::_pd_set since it's accessed outside the SystemDictionary_lock Reviewed-by: zgu, twisti, dholmes, adinn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7040
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
     1
/*
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
     2
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
     4
 *
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    10
 *
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    15
 * accompanied this code).
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    16
 *
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    20
 *
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    23
 * questions.
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    24
 */
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    25
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    26
package java.security;
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    27
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    28
import java.util.Set;
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    29
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    30
/**
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    31
 * This interface specifies constraints for cryptographic algorithms,
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    32
 * keys (key sizes), and other algorithm parameters.
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    33
 * <p>
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    34
 * {@code AlgorithmConstraints} objects are immutable.  An implementation
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    35
 * of this interface should not provide methods that can change the state
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    36
 * of an instance once it has been created.
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    37
 * <p>
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    38
 * Note that {@code AlgorithmConstraints} can be used to represent the
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    39
 * restrictions described by the security properties
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    40
 * {@code jdk.certpath.disabledAlgorithms} and
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    41
 * {@code jdk.tls.disabledAlgorithms}, or could be used by a
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    42
 * concrete {@code PKIXCertPathChecker} to check whether a specified
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    43
 * certificate in the certification path contains the required algorithm
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    44
 * constraints.
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    45
 *
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    46
 * @see javax.net.ssl.SSLParameters#getAlgorithmConstraints
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    47
 * @see javax.net.ssl.SSLParameters#setAlgorithmConstraints(AlgorithmConstraints)
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    48
 *
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    49
 * @since 1.7
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    50
 */
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    51
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    52
public interface AlgorithmConstraints {
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    53
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    54
    /**
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    55
     * Determines whether an algorithm is granted permission for the
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    56
     * specified cryptographic primitives.
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    57
     *
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    58
     * @param primitives a set of cryptographic primitives
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    59
     * @param algorithm the algorithm name
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    60
     * @param parameters the algorithm parameters, or null if no additional
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    61
     *     parameters
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    62
     *
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    63
     * @return true if the algorithm is permitted and can be used for all
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    64
     *     of the specified cryptographic primitives
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    65
     *
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    66
     * @throws IllegalArgumentException if primitives or algorithm is null
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    67
     *     or empty
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    68
     */
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    69
    public boolean permits(Set<CryptoPrimitive> primitives,
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    70
            String algorithm, AlgorithmParameters parameters);
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    71
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    72
    /**
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    73
     * Determines whether a key is granted permission for the specified
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    74
     * cryptographic primitives.
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    75
     * <p>
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    76
     * This method is usually used to check key size and key usage.
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    77
     *
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    78
     * @param primitives a set of cryptographic primitives
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    79
     * @param key the key
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    80
     *
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    81
     * @return true if the key can be used for all of the specified
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    82
     *     cryptographic primitives
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    83
     *
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    84
     * @throws IllegalArgumentException if primitives is null or empty,
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    85
     *     or the key is null
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    86
     */
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    87
    public boolean permits(Set<CryptoPrimitive> primitives, Key key);
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    88
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    89
    /**
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    90
     * Determines whether an algorithm and the corresponding key are granted
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    91
     * permission for the specified cryptographic primitives.
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    92
     *
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    93
     * @param primitives a set of cryptographic primitives
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    94
     * @param algorithm the algorithm name
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    95
     * @param key the key
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    96
     * @param parameters the algorithm parameters, or null if no additional
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    97
     *     parameters
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    98
     *
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
    99
     * @return true if the key and the algorithm can be used for all of the
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
   100
     *     specified cryptographic primitives
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
   101
     *
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
   102
     * @throws IllegalArgumentException if primitives or algorithm is null
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
   103
     *     or empty, or the key is null
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
   104
     */
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
   105
    public boolean permits(Set<CryptoPrimitive> primitives,
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
   106
                String algorithm, Key key, AlgorithmParameters parameters);
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
   107
659824c2a550 6792180: Enhance to reject weak algorithms or conform to crypto recommendations
xuelei
parents:
diff changeset
   108
}