jdk/src/java.base/share/classes/java/security/AlgorithmParametersSpi.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:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
     2
 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2589
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2589
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2589
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2589
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2589
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.security;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.security.spec.AlgorithmParameterSpec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.security.spec.InvalidParameterSpecException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    34
 * for the {@code AlgorithmParameters} class, which is used to manage
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * algorithm parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <p> All the abstract methods in this class must be implemented by each
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * cryptographic service provider who wishes to supply parameter management
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * for a particular algorithm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @author Jan Luehe
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * @see AlgorithmParameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @see java.security.spec.AlgorithmParameterSpec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @see java.security.spec.DSAParameterSpec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
public abstract class AlgorithmParametersSpi {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * Initializes this parameters object using the parameters
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    55
     * specified in {@code paramSpec}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * @param paramSpec the parameter specification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * @exception InvalidParameterSpecException if the given parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * specification is inappropriate for the initialization of this parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    protected abstract void engineInit(AlgorithmParameterSpec paramSpec)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        throws InvalidParameterSpecException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * Imports the specified parameters and decodes them
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * according to the primary decoding format for parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * The primary decoding format for parameters is ASN.1, if an ASN.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * specification for this type of parameters exists.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * @param params the encoded parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @exception IOException on decoding errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    protected abstract void engineInit(byte[] params)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /**
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    80
     * Imports the parameters from {@code params} and
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * decodes them according to the specified decoding format.
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    82
     * If {@code format} is null, the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * primary decoding format for parameters is used. The primary decoding
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * format is ASN.1, if an ASN.1 specification for these parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * exists.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @param params the encoded parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @param format the name of the decoding format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * @exception IOException on decoding errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    protected abstract void engineInit(byte[] params, String format)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * Returns a (transparent) specification of this parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * object.
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
    99
     * {@code paramSpec} identifies the specification class in which
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * the parameters should be returned. It could, for example, be
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   101
     * {@code DSAParameterSpec.class}, to indicate that the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * parameters should be returned in an instance of the
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   103
     * {@code DSAParameterSpec} class.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *
19828
b4f91bc595fe 8024432: Fix doclint issues in java.security
juh
parents: 18579
diff changeset
   105
     * @param <T> the type of the parameter specification to be returned
b4f91bc595fe 8024432: Fix doclint issues in java.security
juh
parents: 18579
diff changeset
   106
     *
2589
af4853bc7e87 6827153: Miscellaneous typos in javadoc
martin
parents: 2
diff changeset
   107
     * @param paramSpec the specification class in which
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * the parameters should be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @return the parameter specification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @exception InvalidParameterSpecException if the requested parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * specification is inappropriate for this parameter object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    protected abstract
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        <T extends AlgorithmParameterSpec>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        T engineGetParameterSpec(Class<T> paramSpec)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        throws InvalidParameterSpecException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * Returns the parameters in their primary encoding format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * The primary encoding format for parameters is ASN.1, if an ASN.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * specification for this type of parameters exists.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @return the parameters encoded using their primary encoding format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @exception IOException on encoding errors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    protected abstract byte[] engineGetEncoded() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * Returns the parameters encoded in the specified format.
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 5506
diff changeset
   133
     * If {@code format} is null, the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * primary encoding format for parameters is used. The primary encoding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * format is ASN.1, if an ASN.1 specification for these parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * exists.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @param format the name of the encoding format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * @return the parameters encoded using the specified encoding scheme.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * @exception IOException on encoding errors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    protected abstract byte[] engineGetEncoded(String format)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * Returns a formatted string describing the parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @return a formatted string describing the parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    protected abstract String engineToString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
}