src/java.corba/share/classes/com/sun/corba/se/impl/ior/IORTypeCheckRegistryImpl.java
author msheppar
Sun, 03 Sep 2017 16:08:13 +0100
changeset 48554 592e22777742
permissions -rw-r--r--
8160104: CORBA communication improvements Reviewed-by: rriggs, dfuchs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48554
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
     1
/*
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
     4
 *
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    10
 *
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    15
 * accompanied this code).
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    16
 *
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    20
 *
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    23
 * questions.
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    24
 */
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    25
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    26
package com.sun.corba.se.impl.ior;
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    27
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    28
import java.util.Set;
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    29
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    30
import com.sun.corba.se.impl.orbutil.ORBUtility;
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    31
import com.sun.corba.se.spi.ior.IORTypeCheckRegistry;
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    32
import com.sun.corba.se.spi.orb.ORB;
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    33
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    34
public class IORTypeCheckRegistryImpl implements IORTypeCheckRegistry {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    35
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    36
    private final Set<String> iorTypeNames;
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    37
    private static final Set<String> builtinIorTypeNames;
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    38
    private ORB theOrb;
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    39
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    40
    static {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    41
        builtinIorTypeNames = initBuiltinIorTypeNames();
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    42
    }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    43
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    44
    public IORTypeCheckRegistryImpl( String filterProperties, ORB orb) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    45
        theOrb = orb;
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    46
        iorTypeNames = parseIorClassNameList(filterProperties);
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    47
    }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    48
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    49
    /*
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    50
     *
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    51
     * A note on the validation flow:
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    52
     * 1. against the filter class name list
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    53
     * 2. against the builtin class name list
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    54
     */
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    55
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    56
    @Override
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    57
    public boolean isValidIORType(String iorClassName) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    58
        dprintTransport(".isValidIORType : iorClassName == " + iorClassName);
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    59
        return validateIorTypeByName(iorClassName);
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    60
    }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    61
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    62
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    63
    private boolean validateIorTypeByName(String iorClassName) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    64
        dprintTransport(".validateIorTypeByName : iorClassName == " + iorClassName);
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    65
        boolean isValidType;
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    66
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    67
        isValidType = checkIorTypeNames(iorClassName);
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    68
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    69
        if (!isValidType) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    70
            isValidType = checkBuiltinClassNames(iorClassName);
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    71
        }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    72
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    73
        dprintTransport(".validateIorTypeByName : isValidType == " + isValidType);
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    74
        return isValidType;
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    75
    }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    76
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    77
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    78
    /*
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    79
     * check if the class name corresponding to an IOR Type name
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    80
     * is in the ior class name list as generated from the filter property.
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    81
     * So if the IOR type is recorded in the registry then allow the creation of the
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    82
     * stub factory and let it resolve and load the class. That is if current
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    83
     * type check deliberation permits.
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    84
     * IOR Type names are configured by the filter property
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    85
     */
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    86
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    87
    private boolean checkIorTypeNames(
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    88
            String theIorClassName) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    89
        return (iorTypeNames != null) && (iorTypeNames.contains(theIorClassName));
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    90
    }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    91
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    92
    /*
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    93
     * Check the IOR interface class name against the set of
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    94
     * class names that correspond to the builtin JDK IDL stub classes.
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    95
     */
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    96
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    97
    private boolean  checkBuiltinClassNames(
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    98
            String theIorClassName) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
    99
        return builtinIorTypeNames.contains(theIorClassName);
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   100
    }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   101
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   102
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   103
    private Set<String> parseIorClassNameList(String filterProperty) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   104
        Set<String> _iorTypeNames = null;
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   105
        if (filterProperty != null) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   106
            String[] tempIorClassNames = filterProperty.split(";");
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   107
            _iorTypeNames = Set.<String>of(tempIorClassNames);
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   108
            if (theOrb.orbInitDebugFlag) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   109
                dprintConfiguredIorTypeNames();
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   110
            }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   111
        }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   112
        return _iorTypeNames;
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   113
    }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   114
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   115
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   116
    private static Set<String> initBuiltinIorTypeNames() {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   117
        Set<Class<?>> builtInCorbaStubTypes = initBuiltInCorbaStubTypes();
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   118
        String [] tempBuiltinIorTypeNames = new String[builtInCorbaStubTypes.size()];
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   119
        int i = 0;
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   120
        for (Class<?> _stubClass: builtInCorbaStubTypes) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   121
            tempBuiltinIorTypeNames[i++] = _stubClass.getName();
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   122
        }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   123
        return  Set.<String>of(tempBuiltinIorTypeNames);
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   124
    }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   125
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   126
    private static Set<Class<?>> initBuiltInCorbaStubTypes() {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   127
        Class<?> tempBuiltinCorbaStubTypes[] = {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   128
                com.sun.corba.se.spi.activation.Activator.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   129
                com.sun.corba.se.spi.activation._ActivatorStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   130
                com.sun.corba.se.spi.activation._InitialNameServiceStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   131
                com.sun.corba.se.spi.activation._LocatorStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   132
                com.sun.corba.se.spi.activation._RepositoryStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   133
                com.sun.corba.se.spi.activation._ServerManagerStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   134
                com.sun.corba.se.spi.activation._ServerStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   135
                org.omg.CosNaming.BindingIterator.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   136
                org.omg.CosNaming._BindingIteratorStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   137
                org.omg.CosNaming.NamingContextExt.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   138
                org.omg.CosNaming._NamingContextExtStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   139
                org.omg.CosNaming.NamingContext.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   140
                org.omg.CosNaming._NamingContextStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   141
                org.omg.DynamicAny.DynAnyFactory.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   142
                org.omg.DynamicAny._DynAnyFactoryStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   143
                org.omg.DynamicAny.DynAny.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   144
                org.omg.DynamicAny._DynAnyStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   145
                org.omg.DynamicAny.DynArray.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   146
                org.omg.DynamicAny._DynArrayStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   147
                org.omg.DynamicAny.DynEnum.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   148
                org.omg.DynamicAny._DynEnumStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   149
                org.omg.DynamicAny.DynFixed.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   150
                org.omg.DynamicAny._DynFixedStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   151
                org.omg.DynamicAny.DynSequence.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   152
                org.omg.DynamicAny._DynSequenceStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   153
                org.omg.DynamicAny.DynStruct.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   154
                org.omg.DynamicAny._DynStructStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   155
                org.omg.DynamicAny.DynUnion.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   156
                org.omg.DynamicAny._DynUnionStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   157
                org.omg.DynamicAny._DynValueStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   158
                org.omg.DynamicAny.DynValue.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   159
                org.omg.PortableServer.ServantActivator.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   160
                org.omg.PortableServer._ServantActivatorStub.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   161
                org.omg.PortableServer.ServantLocator.class,
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   162
                org.omg.PortableServer._ServantLocatorStub.class };
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   163
        return Set.<Class<?>>of(tempBuiltinCorbaStubTypes);
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   164
    }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   165
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   166
    private void dprintConfiguredIorTypeNames() {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   167
        if (iorTypeNames != null) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   168
            for (String iorTypeName : iorTypeNames) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   169
                ORBUtility.dprint(this, ".dprintConfiguredIorTypeNames: " + iorTypeName);
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   170
            }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   171
        }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   172
    }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   173
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   174
    private void dprintTransport(String msg) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   175
        if (theOrb.transportDebugFlag) {
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   176
            ORBUtility.dprint(this, msg);
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   177
        }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   178
    }
592e22777742 8160104: CORBA communication improvements
msheppar
parents:
diff changeset
   179
}