1 /*
2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */

25 package java.security.spec;
26
27 import java.util.Objects;
28
29 /**
30  * This class is used to specify any algorithm parameters that are determined
31  * by a standard name. This class also holds constants for standard parameter
32  * set names. The names of these constants exactly match the corresponding
33  * parameter set name. For example, NamedParameterSpec.X25519 represents the
34  * parameter set identified by the string "X25519". These strings are defined
35  * in the <a href=
36  * "{@docRoot}/../specs/security/standard-names.html#parameter-spec-names">
37  *          Java Security Standard Algorithm Names Specification</a>.
38  *
39  * @since 11
40  *
41  */

42 public class NamedParameterSpec implements AlgorithmParameterSpec {
43
44    /**
45     * The X25519 parameters
46     */

47     public static final NamedParameterSpec X25519
48         = new NamedParameterSpec("X25519");
49    /**
50     * The X448 parameters
51     */

52     public static final NamedParameterSpec X448
53         = new NamedParameterSpec("X448");
54
55     private String name;
56
57     /**
58      * Creates a parameter specification using a standard (or predefined)
59      * name {@code stdName}. For the
60      * list of supported names, please consult the documentation
61      * of the provider whose implementation will be used.
62      *
63      * @param stdName the standard name of the algorithm parameters
64      *
65      * @throws NullPointerException if {@code stdName}
66      * is null.
67      */

68     public NamedParameterSpec(String stdName) {
69         Objects.requireNonNull(stdName, "stdName must not be null");
70
71         this.name = stdName;
72     }
73
74     /**
75      * Returns the standard name that determines the algorithm parameters.
76      * @return the standard name.
77      */

78     public String getName() {
79         return name;
80     }
81 }
82