Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 1997-2016 Oracle and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2016-2022] [Payara Foundation and/or its affiliates]
package org.glassfish.enterprise.iiop.impl;
import com.sun.corba.ee.impl.javax.rmi.CORBA.StubDelegateImpl;
import com.sun.corba.ee.impl.javax.rmi.CORBA.Util;
import com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject;
import com.sun.corba.ee.impl.orb.ORBImpl;
import com.sun.corba.ee.impl.orb.ORBSingleton;
import com.sun.corba.ee.spi.oa.rfm.ReferenceFactoryManager;
import com.sun.corba.ee.spi.osgi.ORBFactory;
import com.sun.corba.ee.spi.misc.ORBConstants;
import com.sun.corba.ee.spi.orb.ORB;
import com.sun.corba.ee.impl.folb.InitialGroupInfoService;
import com.sun.logging.LogDomains;
import org.glassfish.orb.admin.config.IiopListener;
import org.glassfish.orb.admin.config.Orb;
import org.glassfish.orb.admin.config.IiopService;
import com.sun.enterprise.config.serverbeans.SslClientConfig;
import org.glassfish.grizzly.config.dom.Ssl;
import org.glassfish.hk2.api.ServiceLocator;
import java.util.Arrays;
import org.glassfish.api.admin.ProcessEnvironment;
import org.glassfish.api.admin.ProcessEnvironment.ProcessType;
import org.glassfish.enterprise.iiop.api.GlassFishORBLifeCycleListener;
import org.glassfish.enterprise.iiop.api.GlassFishORBHelper;
import org.glassfish.enterprise.iiop.util.IIOPUtils;
import com.sun.enterprise.util.Utility;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.sun.enterprise.module.HK2Module;
import com.sun.enterprise.module.ModulesRegistry;
import org.jvnet.hk2.config.types.Property;
/**
* This class initializes the ORB with a list of (standard) properties
* and provides a few convenience methods to get the ORB etc.
*/
public final class GlassFishORBManager {
static final Logger logger = LogDomains.getLogger(
GlassFishORBManager.class, LogDomains.CORBA_LOGGER, false);
private static void fineLog(String fmt, Object... args) {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, fmt, args);
}
}
private static void finestLog(String fmt, Object... args) {
if (logger.isLoggable(Level.FINEST)) {
logger.log(Level.FINEST, fmt, args);
}
}
private static final Properties EMPTY_PROPERTIES = new Properties();
// Various pluggable classes defined in the app server that are used
// by the ORB.
private static final String ORB_CLASS =
ORBImpl.class.getName();
private static final String ORB_SINGLETON_CLASS =
ORBSingleton.class.getName();
private static final String ORB_EE_CLASS =
"com.sun.corba.ee.impl.orb.ORBImpl";
private static final String ORB_EE_SINGLETON_CLASS =
"com.sun.corba.ee.impl.orb.ORBSingleton";
private static final String PEORB_CONFIG_CLASS =
PEORBConfigurator.class.getName();
private static final String IIOP_SSL_SOCKET_FACTORY_CLASS =
IIOPSSLSocketFactory.class.getName();
private static final String RMI_UTIL_CLASS =
Util.class.getName();
private static final String RMI_STUB_CLASS =
StubDelegateImpl.class.getName();
private static final String RMI_PRO_CLASS =
PortableRemoteObject.class.getName();
// JNDI constants
public static final String JNDI_PROVIDER_URL_PROPERTY =
"java.naming.provider.url";
public static final String JNDI_CORBA_ORB_PROPERTY =
"java.naming.corba.orb";
// RMI-IIOP delegate constants
public static final String ORB_UTIL_CLASS_PROPERTY =
"javax.rmi.CORBA.UtilClass";
public static final String RMIIIOP_STUB_DELEGATE_CLASS_PROPERTY =
"javax.rmi.CORBA.StubClass";
public static final String RMIIIOP_PRO_DELEGATE_CLASS_PROPERTY =
"javax.rmi.CORBA.PortableRemoteObjectClass";
// ORB constants: OMG standard
public static final String OMG_ORB_CLASS_PROPERTY =
"org.omg.CORBA.ORBClass";
public static final String OMG_ORB_SINGLETON_CLASS_PROPERTY =
"org.omg.CORBA.ORBSingletonClass";
// ORB constants: Sun specific
public static final String SUN_ORB_SOCKET_FACTORY_CLASS_PROPERTY =
ORBConstants.SOCKET_FACTORY_CLASS_PROPERTY;
// ORB configuration constants
private static final String DEFAULT_SERVER_ID = "100";
private static final String ACC_DEFAULT_SERVER_ID = "101";
private static final String USER_DEFINED_ORB_SERVER_ID_PROPERTY =
"org.glassfish.orb.iiop.orbserverid";
private static final String DEFAULT_MAX_CONNECTIONS = "1024";
private static final String GLASSFISH_INITIALIZER =
GlassFishORBInitializer.class.getName();
private static final String SUN_GIOP_DEFAULT_FRAGMENT_SIZE = "1024";
private static final String SUN_GIOP_DEFAULT_BUFFER_SIZE = "1024";
public static final String DEFAULT_ORB_INIT_HOST = "localhost";
// This will only apply for stand-alone java clients, since
// in the server the orb port comes from domain.xml, and in an appclient
// the port is set from the sun-acc.xml. It's set to the same
// value as the default orb port in domain.xml as a convenience.
// That way the code only needs to do a "new InitialContext()"
// without setting any jvm properties and the naming service will be
// found. Of course, if the port was changed in domain.xml for some
// reason the code will still have to set org.omg.CORBA.ORBInitialPort.
public static final String DEFAULT_ORB_INIT_PORT = "3700";
private static final String ORB_SSL_STANDALONE_CLIENT_REQUIRED =
"com.sun.CSIV2.ssl.standalone.client.required";
// We need this to get the ORB monitoring set up correctly
public static final String S1AS_ORB_ID = "S1AS-ORB";
private static final String DISABLE_SSL_CHECK = "fish.payara.orb.disable-ssl-check";
// Set in constructor
private ServiceLocator services;
private IIOPUtils iiopUtils;
// the ORB instance
private ORB orb = null;
// The ReferenceFactoryManager from the orb.
private ReferenceFactoryManager rfm = null;
private int orbInitialPort = -1;
private List iiopListeners = null;
private Orb orbBean = null;
private IiopService iiopService = null;
private Properties csiv2Props = new Properties();
private ProcessType processType;
private IiopFolbGmsClient gmsClient;
private static boolean disableSSLCheck;
/**
* Keep this class private to the package. Eventually we need to
* move all public statics or change them to package private.
* All external orb/iiop access should go through orb-connector module
*/
GlassFishORBManager(ServiceLocator h) {
fineLog("GlassFishORBManager: Constructing GlassFishORBManager: h {0}",
h);
services = h;
iiopUtils = services.getService(IIOPUtils.class);
ProcessEnvironment processEnv = services.getService(
ProcessEnvironment.class);
processType = processEnv.getProcessType();
initProperties();
}
/**
* Returns whether an adapterName (from ServerRequestInfo.adapter_name)
* represents an EJB or not.
*
* @param adapterName The adapter name
* @return whether this adapter is an EJB or not
*/
public boolean isEjbAdapterName(String[] adapterName) {
boolean result = false;
if (rfm != null) {
result = rfm.isRfmName(adapterName);
}
return result;
}
public boolean isClusterActive() {
return gmsClient != null && gmsClient.isGMSAvailable();
}
/**
* Returns whether the operationName corresponds to an "is_a" call
* or not (used to implement PortableRemoteObject.narrow.
*/
boolean isIsACall(String operationName) {
return operationName.equals("_is_a");
}
/**
* Return the shared ORB instance for the app server.
* If the ORB is not already initialized, it is created
* with the standard server properties, which can be
* overridden by Properties passed in the props argument.
*/
synchronized ORB getORB(Properties props) {
try {
finestLog("GlassFishORBManager.getORB->: {0}", orb);
if (orb == null) {
initORB(props);
}
return orb;
} finally {
finestLog("GlassFishORBManager.getORB<-: {0}", orb);
}
}
Properties getCSIv2Props() {
// Return a copy of the CSIv2Props
return new Properties(csiv2Props);
}
void setCSIv2Prop(String name, String value) {
csiv2Props.setProperty(name, value);
}
int getORBInitialPort() {
return orbInitialPort;
}
public static boolean disableSSLCheck() {
return disableSSLCheck;
}
private void initProperties() {
fineLog("GlassFishORBManager: initProperties: processType {0}",
processType);
if (processType != ProcessType.ACC) {
String sslClientRequired = System.getProperty(
ORB_SSL_STANDALONE_CLIENT_REQUIRED);
if (sslClientRequired != null
&& sslClientRequired.equals("true")) {
csiv2Props.put(
GlassFishORBHelper.ORB_SSL_CLIENT_REQUIRED, "true");
}
}
disableSSLCheck = Boolean.getBoolean(DISABLE_SSL_CHECK);
if (!processType.isServer()) {
// No access to domain.xml. Just init properties.
// In this case iiopListener beans will be null.
checkORBInitialPort(EMPTY_PROPERTIES);
} else {
iiopService = iiopUtils.getIiopService();
iiopListeners = iiopService.getIiopListener();
assert iiopListeners != null;
// checkORBInitialPort looks at iiopListenerBeans, if present
checkORBInitialPort(EMPTY_PROPERTIES);
orbBean = iiopService.getOrb();
assert (orbBean != null);
// Initialize IOR security config for non-EJB CORBA objects
//iiopServiceBean.isClientAuthenticationRequired()));
csiv2Props.put(GlassFishORBHelper.ORB_CLIENT_AUTH_REQUIRED,
String.valueOf(
iiopService.getClientAuthenticationRequired()));
// If there is at least one non-SSL listener, then it means
// SSL is not required for CORBA objects.
boolean corbaSSLRequired = true;
for (IiopListener bean : iiopListeners) {
if (bean.getSsl() == null) {
corbaSSLRequired = false;
break;
}
}
csiv2Props.put(GlassFishORBHelper.ORB_SSL_SERVER_REQUIRED,
String.valueOf(corbaSSLRequired));
}
}
/**
* Set ORB-related system properties that are required in case
* user code in the app server or app client container creates a
* new ORB instance. The default result of calling
* ORB.init( String[], Properties ) must be a fully usuable, consistent
* ORB. This avoids difficulties with having the ORB class set
* to a different ORB than the RMI-IIOP delegates.
*/
private void setORBSystemProperties() {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction