Fri, 24 Sep 2010 22:42:14 -0700
6891766: Vulnerabilities in use of reflection in CORBA
Reviewed-by: hawtin
duke@1 | 1 | /* |
ohair@158 | 2 | * Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@158 | 7 | * published by the Free Software Foundation. Oracle designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@158 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
ohair@158 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@158 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@158 | 23 | * questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package org.omg.CORBA; |
duke@1 | 27 | |
duke@1 | 28 | /** |
duke@1 | 29 | * An object that captures the explicit state of a request |
duke@1 | 30 | * for the Dynamic Skeleton Interface (DSI). This class, the |
duke@1 | 31 | * cornerstone of the DSI, is analogous to the <code>Request</code> |
duke@1 | 32 | * object in the DII. |
duke@1 | 33 | * <P> |
duke@1 | 34 | * The ORB is responsible for creating this embodiment of a request, |
duke@1 | 35 | * and delivering it to a Dynamic Implementation Routine (DIR). |
duke@1 | 36 | * A dynamic servant (a DIR) is created by implementing the |
duke@1 | 37 | * <code>DynamicImplementation</code> class, |
duke@1 | 38 | * which has a single <code>invoke</code> method. This method accepts a |
duke@1 | 39 | * <code>ServerRequest</code> object. |
duke@1 | 40 | * |
duke@1 | 41 | * The abstract class <code>ServerRequest</code> defines |
duke@1 | 42 | * methods for accessing the |
duke@1 | 43 | * method name, the arguments and the context of the request, as |
duke@1 | 44 | * well as methods for setting the result of the request either as a |
duke@1 | 45 | * return value or an exception. <p> |
duke@1 | 46 | * |
duke@1 | 47 | * A subtlety with accessing the arguments of the request is that the |
duke@1 | 48 | * DIR needs to provide type information about the |
duke@1 | 49 | * expected arguments, since there is no compiled information about |
duke@1 | 50 | * these. This information is provided through an <code>NVList</code>, |
duke@1 | 51 | * which is a list of <code>NamedValue</code> objects. |
duke@1 | 52 | * Each <code>NamedValue</code> object |
duke@1 | 53 | * contains an <code>Any</code> object, which in turn |
duke@1 | 54 | * has a <code>TypeCode</code> object representing the type |
duke@1 | 55 | * of the argument. <p> |
duke@1 | 56 | * |
duke@1 | 57 | * Similarly, type information needs to be provided for the response, |
duke@1 | 58 | * for either the expected result or for an exception, so the methods |
duke@1 | 59 | * <code>result</code> and <code>except</code> take an <code>Any</code> |
duke@1 | 60 | * object as a parameter. <p> |
duke@1 | 61 | * |
duke@1 | 62 | * @see org.omg.CORBA.DynamicImplementation |
duke@1 | 63 | * @see org.omg.CORBA.NVList |
duke@1 | 64 | * @see org.omg.CORBA.NamedValue |
duke@1 | 65 | * |
duke@1 | 66 | */ |
duke@1 | 67 | |
duke@1 | 68 | public abstract class ServerRequest { |
duke@1 | 69 | |
duke@1 | 70 | /** |
duke@1 | 71 | * Retrieves the name of the operation being |
duke@1 | 72 | * invoked. According to OMG IDL's rules, these names must be unique |
duke@1 | 73 | * among all operations supported by this object's "most-derived" |
duke@1 | 74 | * interface. Note that the operation names for getting and setting |
duke@1 | 75 | * attributes are <code>_get_<attribute_name></code> |
duke@1 | 76 | * and <code>_set_<attribute_name></code>, |
duke@1 | 77 | * respectively. |
duke@1 | 78 | * |
duke@1 | 79 | * @return the name of the operation to be invoked |
duke@1 | 80 | * @deprecated use operation() |
duke@1 | 81 | */ |
duke@1 | 82 | @Deprecated |
duke@1 | 83 | public String op_name() |
duke@1 | 84 | { |
duke@1 | 85 | return operation(); |
duke@1 | 86 | } |
duke@1 | 87 | |
duke@1 | 88 | |
duke@1 | 89 | /** |
duke@1 | 90 | * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception. |
duke@1 | 91 | * <P> |
duke@1 | 92 | * Retrieves the name of the operation being |
duke@1 | 93 | * invoked. According to OMG IDL's rules, these names must be unique |
duke@1 | 94 | * among all operations supported by this object's "most-derived" |
duke@1 | 95 | * interface. Note that the operation names for getting and setting |
duke@1 | 96 | * attributes are <code>_get_<attribute_name></code> |
duke@1 | 97 | * and <code>_set_<attribute_name></code>, |
duke@1 | 98 | * respectively. |
duke@1 | 99 | * |
duke@1 | 100 | * @return the name of the operation to be invoked |
duke@1 | 101 | * @see <a href="package-summary.html#unimpl"><code>CORBA</code> |
duke@1 | 102 | * package comments for unimplemented features</a> |
duke@1 | 103 | */ |
duke@1 | 104 | public String operation() |
duke@1 | 105 | { |
duke@1 | 106 | throw new org.omg.CORBA.NO_IMPLEMENT(); |
duke@1 | 107 | } |
duke@1 | 108 | |
duke@1 | 109 | |
duke@1 | 110 | /** |
duke@1 | 111 | * Specifies method parameter types and retrieves "in" and "inout" |
duke@1 | 112 | * argument values. |
duke@1 | 113 | * <P> |
duke@1 | 114 | * Note that this method is deprecated; use the method |
duke@1 | 115 | * <code>arguments</code> in its place. |
duke@1 | 116 | * <P> |
duke@1 | 117 | * Unless it calls the method <code>set_exception</code>, |
duke@1 | 118 | * the DIR must call this method exactly once, even if the |
duke@1 | 119 | * method signature contains no parameters. Once the method <code> |
duke@1 | 120 | * arguments</code> or <code>set_exception</code> |
duke@1 | 121 | * has been called, calling <code>arguments</code> on the same |
duke@1 | 122 | * <code>ServerRequest</code> object |
duke@1 | 123 | * will result in a <code>BAD_INV_ORDER</code> system exception. |
duke@1 | 124 | * The DIR must pass in to the method <code>arguments</code> |
duke@1 | 125 | * an NVList initialized with TypeCodes and Flags |
duke@1 | 126 | * describing the parameter types for the operation, in the order in which |
duke@1 | 127 | * they appear in the IDL specification (left to right). A |
duke@1 | 128 | * potentially-different NVList will be returned from |
duke@1 | 129 | * <code>arguments</code>, with the |
duke@1 | 130 | * "in" and "inout" argument values supplied. If it does not call |
duke@1 | 131 | * the method <code>set_exception</code>, |
duke@1 | 132 | * the DIR must supply the returned NVList with return |
duke@1 | 133 | * values for any "out" arguments before returning, and may also change |
duke@1 | 134 | * the return values for any "inout" arguments. |
duke@1 | 135 | * |
duke@1 | 136 | * @param params the arguments of the method, in the |
duke@1 | 137 | * form of an <code>NVList</code> object |
duke@1 | 138 | * @deprecated use the method <code>arguments</code> |
duke@1 | 139 | */ |
duke@1 | 140 | @Deprecated |
duke@1 | 141 | public void params(NVList params) |
duke@1 | 142 | { |
duke@1 | 143 | arguments(params); |
duke@1 | 144 | } |
duke@1 | 145 | |
duke@1 | 146 | /** |
duke@1 | 147 | * Specifies method parameter types and retrieves "in" and "inout" |
duke@1 | 148 | * argument values. |
duke@1 | 149 | * Unless it calls the method <code>set_exception</code>, |
duke@1 | 150 | * the DIR must call this method exactly once, even if the |
duke@1 | 151 | * method signature contains no parameters. Once the method <code> |
duke@1 | 152 | * arguments</code> or <code>set_exception</code> |
duke@1 | 153 | * has been called, calling <code>arguments</code> on the same |
duke@1 | 154 | * <code>ServerRequest</code> object |
duke@1 | 155 | * will result in a <code>BAD_INV_ORDER</code> system exception. |
duke@1 | 156 | * The DIR must pass in to the method <code>arguments</code> |
duke@1 | 157 | * an NVList initialized with TypeCodes and Flags |
duke@1 | 158 | * describing the parameter types for the operation, in the order in which |
duke@1 | 159 | * they appear in the IDL specification (left to right). A |
duke@1 | 160 | * potentially-different NVList will be returned from |
duke@1 | 161 | * <code>arguments</code>, with the |
duke@1 | 162 | * "in" and "inout" argument values supplied. If it does not call |
duke@1 | 163 | * the method <code>set_exception</code>, |
duke@1 | 164 | * the DIR must supply the returned NVList with return |
duke@1 | 165 | * values for any "out" arguments before returning, and it may also change |
duke@1 | 166 | * the return values for any "inout" arguments. |
duke@1 | 167 | * |
duke@1 | 168 | * @param args the arguments of the method, in the |
duke@1 | 169 | * form of an NVList |
duke@1 | 170 | * @see <a href="package-summary.html#unimpl"><code>CORBA</code> |
duke@1 | 171 | * package comments for unimplemented features</a> |
duke@1 | 172 | */ |
duke@1 | 173 | public void arguments(org.omg.CORBA.NVList args) { |
duke@1 | 174 | throw new org.omg.CORBA.NO_IMPLEMENT(); |
duke@1 | 175 | } |
duke@1 | 176 | |
duke@1 | 177 | |
duke@1 | 178 | |
duke@1 | 179 | /** |
duke@1 | 180 | * Specifies any return value for the call. |
duke@1 | 181 | * <P> |
duke@1 | 182 | * Note that this method is deprecated; use the method |
duke@1 | 183 | * <code>set_result</code> in its place. |
duke@1 | 184 | * <P> |
duke@1 | 185 | * Unless the method |
duke@1 | 186 | * <code>set_exception</code> is called, if the invoked method |
duke@1 | 187 | * has a non-void result type, the method <code>set_result</code> |
duke@1 | 188 | * must be called exactly once before the DIR returns. |
duke@1 | 189 | * If the operation has a void result type, the method |
duke@1 | 190 | * <code>set_result</code> may optionally be |
duke@1 | 191 | * called once with an <code>Any</code> object whose type is |
duke@1 | 192 | * <code>tk_void</code>. Calling the method <code>set_result</code> before |
duke@1 | 193 | * the method <code>arguments</code> has been called or after |
duke@1 | 194 | * the method <code>set_result</code> or <code>set_exception</code> has been |
duke@1 | 195 | * called will result in a BAD_INV_ORDER exception. Calling the method |
duke@1 | 196 | * <code>set_result</code> without having previously called |
duke@1 | 197 | * the method <code>ctx</code> when the IDL operation contains a |
duke@1 | 198 | * context expression, or when the NVList passed to arguments did not |
duke@1 | 199 | * describe all parameters passed by the client, may result in a MARSHAL |
duke@1 | 200 | * system exception. |
duke@1 | 201 | * |
duke@1 | 202 | * @param any an <code>Any</code> object containing the return value to be set |
duke@1 | 203 | * @deprecated use the method <code>set_result</code> |
duke@1 | 204 | */ |
duke@1 | 205 | @Deprecated |
duke@1 | 206 | public void result(Any any) |
duke@1 | 207 | { |
duke@1 | 208 | set_result(any); |
duke@1 | 209 | } |
duke@1 | 210 | |
duke@1 | 211 | |
duke@1 | 212 | /** |
duke@1 | 213 | * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception. |
duke@1 | 214 | * <P> |
duke@1 | 215 | * Specifies any return value for the call. Unless the method |
duke@1 | 216 | * <code>set_exception</code> is called, if the invoked method |
duke@1 | 217 | * has a non-void result type, the method <code>set_result</code> |
duke@1 | 218 | * must be called exactly once before the DIR returns. |
duke@1 | 219 | * If the operation has a void result type, the method |
duke@1 | 220 | * <code>set_result</code> may optionally be |
duke@1 | 221 | * called once with an <code>Any</code> object whose type is |
duke@1 | 222 | * <code>tk_void</code>. Calling the method <code>set_result</code> before |
duke@1 | 223 | * the method <code>arguments</code> has been called or after |
duke@1 | 224 | * the method <code>set_result</code> or <code>set_exception</code> has been |
duke@1 | 225 | * called will result in a BAD_INV_ORDER exception. Calling the method |
duke@1 | 226 | * <code>set_result</code> without having previously called |
duke@1 | 227 | * the method <code>ctx</code> when the IDL operation contains a |
duke@1 | 228 | * context expression, or when the NVList passed to arguments did not |
duke@1 | 229 | * describe all parameters passed by the client, may result in a MARSHAL |
duke@1 | 230 | * system exception. |
duke@1 | 231 | * |
duke@1 | 232 | * @param any an <code>Any</code> object containing the return value to be set |
duke@1 | 233 | * @see <a href="package-summary.html#unimpl"><code>CORBA</code> |
duke@1 | 234 | * package comments for unimplemented features</a> |
duke@1 | 235 | */ |
duke@1 | 236 | public void set_result(org.omg.CORBA.Any any) |
duke@1 | 237 | { |
duke@1 | 238 | throw new org.omg.CORBA.NO_IMPLEMENT(); |
duke@1 | 239 | } |
duke@1 | 240 | |
duke@1 | 241 | |
duke@1 | 242 | /** |
duke@1 | 243 | * The DIR may call set_exception at any time to return an exception to the |
duke@1 | 244 | * client. The Any passed to set_exception must contain either a system |
duke@1 | 245 | * exception or a user exception specified in the raises expression |
duke@1 | 246 | * of the invoked operation's IDL definition. Passing in an Any that does |
duke@1 | 247 | * not |
duke@1 | 248 | * contain an exception will result in a BAD_PARAM system exception. Passing |
duke@1 | 249 | * in an unlisted user exception will result in either the DIR receiving a |
duke@1 | 250 | * BAD_PARAM system exception or in the client receiving an |
duke@1 | 251 | * UNKNOWN_EXCEPTION system exception. |
duke@1 | 252 | * |
duke@1 | 253 | * @param any the <code>Any</code> object containing the exception |
duke@1 | 254 | * @deprecated use set_exception() |
duke@1 | 255 | */ |
duke@1 | 256 | @Deprecated |
duke@1 | 257 | public void except(Any any) |
duke@1 | 258 | { |
duke@1 | 259 | set_exception(any); |
duke@1 | 260 | } |
duke@1 | 261 | |
duke@1 | 262 | /** |
duke@1 | 263 | * Throws an <code>org.omg.CORBA.NO_IMPLEMENT</code> exception. |
duke@1 | 264 | * <P> |
duke@1 | 265 | * Returns the given exception to the client. This method |
duke@1 | 266 | * is invoked by the DIR, which may call it at any time. |
duke@1 | 267 | * The <code>Any</code> object passed to this method must |
duke@1 | 268 | * contain either a system |
duke@1 | 269 | * exception or one of the user exceptions specified in the |
duke@1 | 270 | * invoked operation's IDL definition. Passing in an |
duke@1 | 271 | * <code>Any</code> object that does not contain an exception |
duke@1 | 272 | * will cause a BAD_PARAM system exception to be thrown. Passing |
duke@1 | 273 | * in an unlisted user exception will result in either the DIR receiving a |
duke@1 | 274 | * BAD_PARAM system exception or in the client receiving an |
duke@1 | 275 | * UNKNOWN_EXCEPTION system exception. |
duke@1 | 276 | * |
duke@1 | 277 | * @param any the <code>Any</code> object containing the exception |
duke@1 | 278 | * @exception BAD_PARAM if the given <code>Any</code> object does not |
duke@1 | 279 | * contain an exception or the exception is an |
duke@1 | 280 | * unlisted user exception |
duke@1 | 281 | * @exception UNKNOWN_EXCEPTION if the given exception is an unlisted |
duke@1 | 282 | * user exception and the DIR did not |
duke@1 | 283 | * receive a BAD_PARAM exception |
duke@1 | 284 | * @see <a href="package-summary.html#unimpl"><code>CORBA</code> |
duke@1 | 285 | * package comments for unimplemented features</a> |
duke@1 | 286 | */ |
duke@1 | 287 | public void set_exception(Any any) |
duke@1 | 288 | { |
duke@1 | 289 | throw new org.omg.CORBA.NO_IMPLEMENT(); |
duke@1 | 290 | } |
duke@1 | 291 | |
duke@1 | 292 | /** |
duke@1 | 293 | * Returns the context information specified in IDL for the operation |
duke@1 | 294 | * when the operation is not an attribute access and the operation's IDL |
duke@1 | 295 | * definition contains a context expression; otherwise it returns |
duke@1 | 296 | * a nil <code>Context</code> reference. Calling the method |
duke@1 | 297 | * <code>ctx</code> before the method <code>arguments</code> has |
duke@1 | 298 | * been called or after the method <code>ctx</code>, |
duke@1 | 299 | * <code>set_result</code>, or <code>set_exception</code> |
duke@1 | 300 | * has been called will result in a |
duke@1 | 301 | * BAD_INV_ORDER system exception. |
duke@1 | 302 | * |
duke@1 | 303 | * @return the context object that is to be used |
duke@1 | 304 | * to resolve any context strings whose |
duke@1 | 305 | * values need to be sent with the invocation. |
duke@1 | 306 | * @exception BAD_INV_ORDER if (1) the method <code>ctx</code> is called |
duke@1 | 307 | * before the method <code>arguments</code> or |
duke@1 | 308 | * (2) the method <code>ctx</code> is called |
duke@1 | 309 | * after calling <code>set_result</code> or |
duke@1 | 310 | * <code>set_exception</code> |
duke@1 | 311 | */ |
duke@1 | 312 | public abstract Context ctx(); |
duke@1 | 313 | |
duke@1 | 314 | } |