author | chegar |
Mon, 18 Oct 2010 16:51:26 +0100 | |
changeset 6906 | d57020b6118f |
parent 5506 | 202f599c92aa |
child 7271 | 17d3fc18872d |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
26 |
package com.sun.net.httpserver; |
|
6906
d57020b6118f
6992545: FindBugs scan - Malicious code vulnerability Warnings in com.sun.net.httpserver.HttpsParameters.*
chegar
parents:
5506
diff
changeset
|
27 |
import java.net.InetSocketAddress; |
2 | 28 |
import javax.net.ssl.SSLParameters; |
29 |
||
30 |
/** |
|
31 |
* Represents the set of parameters for each https |
|
32 |
* connection negotiated with clients. One of these |
|
33 |
* is created and passed to |
|
34 |
* {@link HttpsConfigurator#configure(HttpsParameters)} |
|
35 |
* for every incoming https connection, |
|
36 |
* in order to determine the parameters to use. |
|
37 |
* <p> |
|
38 |
* The underlying SSL parameters may be established either |
|
39 |
* via the set/get methods of this class, or else via |
|
40 |
* a {@link javax.net.ssl.SSLParameters} object. SSLParameters |
|
41 |
* is the preferred method, because in the future, |
|
42 |
* additional configuration capabilities may be added to that class, and |
|
43 |
* it is easier to determine the set of supported parameters and their |
|
44 |
* default values with SSLParameters. Also, if an SSLParameters object is |
|
45 |
* provided via |
|
46 |
* {@link #setSSLParameters(SSLParameters)} then those parameter settings |
|
47 |
* are used, and any settings made in this object are ignored. |
|
48 |
* @since 1.6 |
|
49 |
*/ |
|
50 |
public abstract class HttpsParameters { |
|
51 |
||
52 |
private String[] cipherSuites; |
|
53 |
private String[] protocols; |
|
54 |
private boolean wantClientAuth; |
|
55 |
private boolean needClientAuth; |
|
56 |
||
57 |
protected HttpsParameters() {} |
|
58 |
||
59 |
/** |
|
60 |
* Returns the HttpsConfigurator for this HttpsParameters. |
|
61 |
*/ |
|
62 |
public abstract HttpsConfigurator getHttpsConfigurator(); |
|
63 |
||
64 |
/** |
|
65 |
* Returns the address of the remote client initiating the |
|
66 |
* connection. |
|
67 |
*/ |
|
68 |
public abstract InetSocketAddress getClientAddress(); |
|
69 |
||
70 |
/** |
|
71 |
* Sets the SSLParameters to use for this HttpsParameters. |
|
72 |
* The parameters must be supported by the SSLContext contained |
|
73 |
* by the HttpsConfigurator associated with this HttpsParameters. |
|
74 |
* If no parameters are set, then the default behavior is to use |
|
75 |
* the default parameters from the associated SSLContext. |
|
76 |
* @param params the SSLParameters to set. If <code>null</code> |
|
77 |
* then the existing parameters (if any) remain unchanged. |
|
78 |
* @throws IllegalArgumentException if any of the parameters are |
|
79 |
* invalid or unsupported. |
|
80 |
*/ |
|
81 |
public abstract void setSSLParameters (SSLParameters params); |
|
82 |
||
83 |
/** |
|
84 |
* Returns a copy of the array of ciphersuites or null if none |
|
85 |
* have been set. |
|
86 |
* |
|
87 |
* @return a copy of the array of ciphersuites or null if none |
|
88 |
* have been set. |
|
89 |
*/ |
|
90 |
public String[] getCipherSuites() { |
|
6906
d57020b6118f
6992545: FindBugs scan - Malicious code vulnerability Warnings in com.sun.net.httpserver.HttpsParameters.*
chegar
parents:
5506
diff
changeset
|
91 |
return cipherSuites != null ? cipherSuites.clone() : null; |
2 | 92 |
} |
93 |
||
94 |
/** |
|
95 |
* Sets the array of ciphersuites. |
|
96 |
* |
|
97 |
* @param cipherSuites the array of ciphersuites (or null) |
|
98 |
*/ |
|
99 |
public void setCipherSuites(String[] cipherSuites) { |
|
6906
d57020b6118f
6992545: FindBugs scan - Malicious code vulnerability Warnings in com.sun.net.httpserver.HttpsParameters.*
chegar
parents:
5506
diff
changeset
|
100 |
this.cipherSuites = cipherSuites != null ? cipherSuites.clone() : null; |
2 | 101 |
} |
102 |
||
103 |
/** |
|
104 |
* Returns a copy of the array of protocols or null if none |
|
105 |
* have been set. |
|
106 |
* |
|
107 |
* @return a copy of the array of protocols or null if none |
|
108 |
* have been set. |
|
109 |
*/ |
|
110 |
public String[] getProtocols() { |
|
6906
d57020b6118f
6992545: FindBugs scan - Malicious code vulnerability Warnings in com.sun.net.httpserver.HttpsParameters.*
chegar
parents:
5506
diff
changeset
|
111 |
return protocols != null ? protocols.clone() : null; |
2 | 112 |
} |
113 |
||
114 |
/** |
|
115 |
* Sets the array of protocols. |
|
116 |
* |
|
117 |
* @param protocols the array of protocols (or null) |
|
118 |
*/ |
|
119 |
public void setProtocols(String[] protocols) { |
|
6906
d57020b6118f
6992545: FindBugs scan - Malicious code vulnerability Warnings in com.sun.net.httpserver.HttpsParameters.*
chegar
parents:
5506
diff
changeset
|
120 |
this.protocols = protocols != null ? protocols.clone() : null; |
2 | 121 |
} |
122 |
||
123 |
/** |
|
124 |
* Returns whether client authentication should be requested. |
|
125 |
* |
|
126 |
* @return whether client authentication should be requested. |
|
127 |
*/ |
|
128 |
public boolean getWantClientAuth() { |
|
129 |
return wantClientAuth; |
|
130 |
} |
|
131 |
||
132 |
/** |
|
133 |
* Sets whether client authentication should be requested. Calling |
|
134 |
* this method clears the <code>needClientAuth</code> flag. |
|
135 |
* |
|
136 |
* @param wantClientAuth whether client authentication should be requested |
|
137 |
*/ |
|
138 |
public void setWantClientAuth(boolean wantClientAuth) { |
|
139 |
this.wantClientAuth = wantClientAuth; |
|
140 |
} |
|
141 |
||
142 |
/** |
|
143 |
* Returns whether client authentication should be required. |
|
144 |
* |
|
145 |
* @return whether client authentication should be required. |
|
146 |
*/ |
|
147 |
public boolean getNeedClientAuth() { |
|
148 |
return needClientAuth; |
|
149 |
} |
|
150 |
||
151 |
/** |
|
152 |
* Sets whether client authentication should be required. Calling |
|
153 |
* this method clears the <code>wantClientAuth</code> flag. |
|
154 |
* |
|
155 |
* @param needClientAuth whether client authentication should be required |
|
156 |
*/ |
|
157 |
public void setNeedClientAuth(boolean needClientAuth) { |
|
158 |
this.needClientAuth = needClientAuth; |
|
159 |
} |
|
160 |
} |