1 /*
2 * Copyright (c) 2005, 2012, 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
24 */
25
26 package javax.xml.ws.spi.http;
27
28 import javax.xml.ws.handler.MessageContext;
29 import java.io.InputStream;
30 import java.io.OutputStream;
31 import java.io.IOException;
32 import java.net.InetSocketAddress;
33 import java.util.List;
34 import java.util.Map;
35 import java.util.Set;
36 import java.security.Principal;
37
38 /**
39 * This class encapsulates a HTTP request received and a
40 * response to be generated in one exchange. It provides methods
41 * for examining the request from the client, and for building and
42 * sending the response.
43 * <p>
44 * A <code>HttpExchange</code> must be closed to free or reuse
45 * underlying resources. The effect of failing to close an exchange
46 * is undefined.
47 *
48 * @author Jitendra Kotamraju
49 * @since 1.7, JAX-WS 2.2
50 */
51 public abstract class HttpExchange {
52
53 /**
54 * Standard property: cipher suite value when the request is received
55 * over HTTPS
56 * <p>Type: String
57 */
58 public static final String REQUEST_CIPHER_SUITE =
59 "javax.xml.ws.spi.http.request.cipher.suite";
60
61 /**
62 * Standard property: bit size of the algorithm when the request is
63 * received over HTTPS
64 * <p>Type: Integer
260 * after the web service path but before the query string in the
261 * request URI
262 * <tt>null</tt> if there is no extra path in the request URI
263 */
264 public abstract String getPathInfo();
265
266 /**
267 * Returns the query string that is contained in the request URI
268 * after the path.
269 *
270 * <p>
271 * This can be used for {@link MessageContext#QUERY_STRING}
272 *
273 * @return undecoded query string of request URI, or
274 * <tt>null</tt> if the request URI doesn't have one
275 */
276 public abstract String getQueryString();
277
278 /**
279 * Returns an attribute that is associated with this
280 * <code>HttpExchange</code>. JAX-WS handlers and endpoints may then
281 * access the attribute via {@link MessageContext}.
282 * <p>
283 * Servlet containers must expose {@link MessageContext#SERVLET_CONTEXT},
284 * {@link MessageContext#SERVLET_REQUEST}, and
285 * {@link MessageContext#SERVLET_RESPONSE}
286 * as attributes.
287 *
288 * <p>If the request has been received by the container using HTTPS, the
289 * following information must be exposed as attributes. These attributes
290 * are {@link #REQUEST_CIPHER_SUITE}, and {@link #REQUEST_KEY_SIZE}.
291 * If there is a SSL certificate associated with the request, it must
292 * be exposed using {@link #REQUEST_X509CERTIFICATE}
293 *
294 * @param name attribute name
295 * @return the attribute value, or <tt>null</tt> if the attribute doesn't
296 * exist
297 */
298 public abstract Object getAttribute(String name);
299
300 /**
301 * Gives all the attribute names that are associated with
302 * this <code>HttpExchange</code>.
303 *
304 * @return set of all attribute names
305 * @see #getAttribute(String)
306 */
307 public abstract Set<String> getAttributeNames();
308
309 /**
310 * Returns the {@link Principal} that represents the authenticated
311 * user for this <code>HttpExchange</code>.
312 *
313 * @return Principal for an authenticated user, or
314 * <tt>null</tt> if not authenticated
315 */
316 public abstract Principal getUserPrincipal();
317
318 /**
319 * Indicates whether an authenticated user is included in the specified
320 * logical "role".
321 *
322 * @param role specifies the name of the role
323 * @return <tt>true</tt> if the user making this request belongs to a
324 * given role
325 */
326 public abstract boolean isUserInRole(String role);
327
328 }
|
1 /*
2 * Copyright (c) 2005, 2015, 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
24 */
25
26 package javax.xml.ws.spi.http;
27
28 import javax.xml.ws.handler.MessageContext;
29 import java.io.InputStream;
30 import java.io.OutputStream;
31 import java.io.IOException;
32 import java.net.InetSocketAddress;
33 import java.util.List;
34 import java.util.Map;
35 import java.util.Set;
36 import java.security.Principal;
37
38 /**
39 * This class encapsulates a HTTP request received and a
40 * response to be generated in one exchange. It provides methods
41 * for examining the request from the client, and for building and
42 * sending the response.
43 * <p>
44 * A {@code HttpExchange} must be closed to free or reuse
45 * underlying resources. The effect of failing to close an exchange
46 * is undefined.
47 *
48 * @author Jitendra Kotamraju
49 * @since 1.7, JAX-WS 2.2
50 */
51 public abstract class HttpExchange {
52
53 /**
54 * Standard property: cipher suite value when the request is received
55 * over HTTPS
56 * <p>Type: String
57 */
58 public static final String REQUEST_CIPHER_SUITE =
59 "javax.xml.ws.spi.http.request.cipher.suite";
60
61 /**
62 * Standard property: bit size of the algorithm when the request is
63 * received over HTTPS
64 * <p>Type: Integer
260 * after the web service path but before the query string in the
261 * request URI
262 * <tt>null</tt> if there is no extra path in the request URI
263 */
264 public abstract String getPathInfo();
265
266 /**
267 * Returns the query string that is contained in the request URI
268 * after the path.
269 *
270 * <p>
271 * This can be used for {@link MessageContext#QUERY_STRING}
272 *
273 * @return undecoded query string of request URI, or
274 * <tt>null</tt> if the request URI doesn't have one
275 */
276 public abstract String getQueryString();
277
278 /**
279 * Returns an attribute that is associated with this
280 * {@code HttpExchange}. JAX-WS handlers and endpoints may then
281 * access the attribute via {@link MessageContext}.
282 * <p>
283 * Servlet containers must expose {@link MessageContext#SERVLET_CONTEXT},
284 * {@link MessageContext#SERVLET_REQUEST}, and
285 * {@link MessageContext#SERVLET_RESPONSE}
286 * as attributes.
287 *
288 * <p>If the request has been received by the container using HTTPS, the
289 * following information must be exposed as attributes. These attributes
290 * are {@link #REQUEST_CIPHER_SUITE}, and {@link #REQUEST_KEY_SIZE}.
291 * If there is a SSL certificate associated with the request, it must
292 * be exposed using {@link #REQUEST_X509CERTIFICATE}
293 *
294 * @param name attribute name
295 * @return the attribute value, or <tt>null</tt> if the attribute doesn't
296 * exist
297 */
298 public abstract Object getAttribute(String name);
299
300 /**
301 * Gives all the attribute names that are associated with
302 * this {@code HttpExchange}.
303 *
304 * @return set of all attribute names
305 * @see #getAttribute(String)
306 */
307 public abstract Set<String> getAttributeNames();
308
309 /**
310 * Returns the {@link Principal} that represents the authenticated
311 * user for this {@code HttpExchange}.
312 *
313 * @return Principal for an authenticated user, or
314 * <tt>null</tt> if not authenticated
315 */
316 public abstract Principal getUserPrincipal();
317
318 /**
319 * Indicates whether an authenticated user is included in the specified
320 * logical "role".
321 *
322 * @param role specifies the name of the role
323 * @return <tt>true</tt> if the user making this request belongs to a
324 * given role
325 */
326 public abstract boolean isUserInRole(String role);
327
328 }
|