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) 2000, 2003, 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 com.sun.corba.se.impl.orb ; |
duke@1 | 27 | |
duke@1 | 28 | import org.omg.CORBA.portable.OutputStream ; |
duke@1 | 29 | |
duke@1 | 30 | import com.sun.corba.se.spi.orb.ORBVersion ; |
duke@1 | 31 | |
duke@1 | 32 | public class ORBVersionImpl implements ORBVersion { |
duke@1 | 33 | private byte orbType ; |
duke@1 | 34 | |
duke@1 | 35 | public ORBVersionImpl( byte orbType ) |
duke@1 | 36 | { |
duke@1 | 37 | this.orbType = orbType ; |
duke@1 | 38 | } |
duke@1 | 39 | |
duke@1 | 40 | public static final ORBVersion FOREIGN = new ORBVersionImpl( |
duke@1 | 41 | ORBVersion.FOREIGN ) ; |
duke@1 | 42 | |
duke@1 | 43 | public static final ORBVersion OLD = new ORBVersionImpl( |
duke@1 | 44 | ORBVersion.OLD ) ; |
duke@1 | 45 | |
duke@1 | 46 | public static final ORBVersion NEW = new ORBVersionImpl( |
duke@1 | 47 | ORBVersion.NEW ) ; |
duke@1 | 48 | |
duke@1 | 49 | public static final ORBVersion JDK1_3_1_01 = new ORBVersionImpl( |
duke@1 | 50 | ORBVersion.JDK1_3_1_01 ) ; |
duke@1 | 51 | |
duke@1 | 52 | public static final ORBVersion NEWER = new ORBVersionImpl( |
duke@1 | 53 | ORBVersion.NEWER ) ; |
duke@1 | 54 | |
duke@1 | 55 | public static final ORBVersion PEORB = new ORBVersionImpl( |
duke@1 | 56 | ORBVersion.PEORB ) ; |
duke@1 | 57 | |
duke@1 | 58 | public byte getORBType() |
duke@1 | 59 | { |
duke@1 | 60 | return orbType ; |
duke@1 | 61 | } |
duke@1 | 62 | |
duke@1 | 63 | public void write( OutputStream os ) |
duke@1 | 64 | { |
duke@1 | 65 | os.write_octet( (byte)orbType ) ; |
duke@1 | 66 | } |
duke@1 | 67 | |
duke@1 | 68 | public String toString() |
duke@1 | 69 | { |
duke@1 | 70 | return "ORBVersionImpl[" + Byte.toString( orbType ) + "]" ; |
duke@1 | 71 | } |
duke@1 | 72 | |
duke@1 | 73 | public boolean equals( Object obj ) |
duke@1 | 74 | { |
duke@1 | 75 | if (!(obj instanceof ORBVersion)) |
duke@1 | 76 | return false ; |
duke@1 | 77 | |
duke@1 | 78 | ORBVersion version = (ORBVersion)obj ; |
duke@1 | 79 | return version.getORBType() == orbType ; |
duke@1 | 80 | } |
duke@1 | 81 | |
duke@1 | 82 | public int hashCode() |
duke@1 | 83 | { |
duke@1 | 84 | return orbType ; |
duke@1 | 85 | } |
duke@1 | 86 | |
duke@1 | 87 | public boolean lessThan(ORBVersion version) { |
duke@1 | 88 | return orbType < version.getORBType(); |
duke@1 | 89 | } |
duke@1 | 90 | |
duke@1 | 91 | public int compareTo(Object obj) { |
duke@1 | 92 | // The Comparable interface says that this |
duke@1 | 93 | // method throws a ClassCastException if the |
duke@1 | 94 | // given object's type prevents it from being |
duke@1 | 95 | // compared. |
duke@1 | 96 | return getORBType() - ((ORBVersion)obj).getORBType(); |
duke@1 | 97 | } |
duke@1 | 98 | } |