History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/sun/security/provider/certpath/SunCertPathBuilderParameters.java (1 of 18352 files). Show all

Unified · Split

java/pkg/sun/security/provider/certpath/SunCertPathBuilderParameters.java+131−0
@@ -0,0 +1,131 @@
1+/*
2+ * Copyright (c) 2000, 2003, 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+
26+package sun.security.provider.certpath;
27+
28+import java.util.Set;
29+
30+import java.security.InvalidAlgorithmParameterException;
31+import java.security.KeyStore;
32+import java.security.KeyStoreException;
33+import java.security.cert.*;
34+
35+/**
36+ * This class specifies the set of parameters used as input for the Sun
37+ * certification path build algorithm. It is identical to PKIXBuilderParameters
38+ * with the addition of a <code>buildForward</code> parameter which allows
39+ * the caller to specify whether or not the path should be constructed in
40+ * the forward direction.
41+ *
42+ * The default for the <code>buildForward</code> parameter is
43+ * true, which means that the build algorithm should construct paths
44+ * from the target subject back to the trusted anchor.
45+ *
46+ * @since 1.4
47+ * @author Sean Mullan
48+ * @author Yassir Elley
49+ */
50+public class SunCertPathBuilderParameters extends PKIXBuilderParameters {
51+
52+ private boolean buildForward = true;
53+
54+ /**
55+ * Creates an instance of <code>SunCertPathBuilderParameters</code> with the
56+ * specified parameter values.
57+ *
58+ * @param trustAnchors a <code>Set</code> of <code>TrustAnchor</code>s
59+ * @param targetConstraints a <code>CertSelector</code> specifying the
60+ * constraints on the target certificate
61+ * @throws InvalidAlgorithmParameterException if the specified
62+ * <code>Set</code> is empty <code>(trustAnchors.isEmpty() == true)</code>
63+ * @throws NullPointerException if the specified <code>Set</code> is
64+ * <code>null</code>
65+ * @throws ClassCastException if any of the elements in the <code>Set</code>
66+ * are not of type <code>java.security.cert.TrustAnchor</code>
67+ */
68+ public SunCertPathBuilderParameters(Set<TrustAnchor> trustAnchors,
69+ CertSelector targetConstraints) throws InvalidAlgorithmParameterException
70+ {
71+ super(trustAnchors, targetConstraints);
72+ setBuildForward(true);
73+ }
74+
75+ /**
76+ * Creates an instance of <code>SunCertPathBuilderParameters</code> that
77+ * uses the specified <code>KeyStore</code> to populate the set
78+ * of most-trusted CA certificates.
79+ *
80+ * @param keystore A keystore from which the set of most-trusted
81+ * CA certificates will be populated.
82+ * @param targetConstraints a <code>CertSelector</code> specifying the
83+ * constraints on the target certificate
84+ * @throws KeyStoreException if the keystore has not been initialized.
85+ * @throws InvalidAlgorithmParameterException if the keystore does
86+ * not contain at least one trusted certificate entry
87+ * @throws NullPointerException if the keystore is <code>null</code>
88+ */
89+ public SunCertPathBuilderParameters(KeyStore keystore,
90+ CertSelector targetConstraints)
91+ throws KeyStoreException, InvalidAlgorithmParameterException
92+ {
93+ super(keystore, targetConstraints);
94+ setBuildForward(true);
95+ }
96+
97+ /**
98+ * Returns the value of the buildForward flag.
99+ *
100+ * @return the value of the buildForward flag
101+ */
102+ public boolean getBuildForward() {
103+ return this.buildForward;
104+ }
105+
106+ /**
107+ * Sets the value of the buildForward flag. If true, paths
108+ * are built from the target subject to the trusted anchor.
109+ * If false, paths are built from the trusted anchor to the
110+ * target subject. The default value if not specified is true.
111+ *
112+ * @param buildForward the value of the buildForward flag
113+ */
114+ public void setBuildForward(boolean buildForward) {
115+ this.buildForward = buildForward;
116+ }
117+
118+ /**
119+ * Returns a formatted string describing the parameters.
120+ *
121+ * @return a formatted string describing the parameters.
122+ */
123+ public String toString() {
124+ StringBuffer sb = new StringBuffer();
125+ sb.append("[\n");
126+ sb.append(super.toString());
127+ sb.append(" Build Forward Flag: " + String.valueOf(buildForward) + "\n");
128+ sb.append("]\n");
129+ return sb.toString();
130+ }
131+}