Skip to content

Commit

Permalink
Merge pull request #3438 from arjantijms/PAYARA-2959-iiop-ssl
Browse files Browse the repository at this point in the history
PAYARA-2959 Taking deployment groups into account for SSL/IIOP
  • Loading branch information
arjantijms authored Nov 29, 2018
2 parents 293e4d7 + 44b99bd commit 043f135
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/

// Portions Copyright [2018] [Payara Foundation and/or its affiliates]
package org.glassfish.enterprise.iiop.api;

import org.jvnet.hk2.annotations.Contract;
Expand Down Expand Up @@ -76,4 +76,6 @@ public interface GlassFishORBFactory {
public boolean isEjbCall (ServerRequestInfo sri);

public String getIIOPEndpoints() ;

boolean isClusterActive();
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* holder.
*/

// Portions Copyright [2017] [Payara Foundation and/or its affiliates]
// Portions Copyright [2017-2018] [Payara Foundation and/or its affiliates]

package org.glassfish.enterprise.iiop.impl;

Expand Down Expand Up @@ -137,4 +137,9 @@ public boolean isEjbCall (ServerRequestInfo sri) {
public String getIIOPEndpoints() {
return gfORBManager.getIIOPEndpoints() ;
}

@Override
public boolean isClusterActive() {
return gfORBManager.isClusterActive();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ public boolean isEjbAdapterName(String[] adapterName) {

return result;
}

public boolean isClusterActive() {
return gmsClient != null && gmsClient.isGMSAvailable();
}

/**
* Returns whether the operationName corresponds to an "is_a" call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2017] [Payara Foundation and/or its affiliates]
// Portions Copyright [2017-2018] [Payara Foundation and/or its affiliates]

package org.glassfish.enterprise.iiop.impl;

Expand Down Expand Up @@ -188,17 +188,21 @@ public GroupInfoService getGroupInfoService() {
}

public boolean isGMSAvailable() {
boolean result = false;
if (cluster != null && cluster.isEnabled()) {
result = true;
}
return result;
return isDeploymentGroupsActive() || isTraditionalClusterActive();
}

////////////////////////////////////////////////////
//
// Implementation
//

private boolean isDeploymentGroupsActive() {
return cluster != null && cluster.isEnabled() && cluster.getClusterMembers().size() > 1;
}

private boolean isTraditionalClusterActive() {
return myServer.getCluster() != null;
}

private void removeMember(final String signal)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@

import fish.payara.nucleus.cluster.PayaraCluster;
import java.lang.ref.WeakReference;

import org.glassfish.enterprise.iiop.api.GlassFishORBFactory;
import org.glassfish.enterprise.iiop.api.GlassFishORBHelper;
import org.glassfish.enterprise.iiop.impl.GlassFishORBManager;
import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.internal.api.Globals;

import com.sun.enterprise.config.serverbeans.Servers;

import javax.inject.Inject;
import javax.inject.Provider;

Expand All @@ -61,6 +66,9 @@ public class Lookups {

@Inject
private Provider<GlassFishORBHelper> glassFishORBHelperProvider;

@Inject
private Provider<GlassFishORBFactory> glassFishORBFactoryProvider;

@Inject
private Provider<SecurityContextUtil> securityContextUtilProvider;
Expand Down Expand Up @@ -167,4 +175,8 @@ private static synchronized SecurityContextUtil _getSecurityContextUtil() {
static PayaraCluster getCluster() {
return checkSingleton() ? singleton.payaraCluster.get() : null;
}

static GlassFishORBFactory getGlassFishORBFactory() {
return checkSingleton() ? singleton.glassFishORBFactoryProvider.get() : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,23 @@

import org.glassfish.orb.admin.config.IiopListener;
import java.util.logging.*;

import static java.util.logging.Level.FINE;

import java.util.List;

import org.omg.IOP.Codec;
import org.omg.IOP.TaggedComponent;
import org.omg.PortableInterceptor.IORInfo;

import com.sun.logging.*;
import com.sun.enterprise.config.serverbeans.Server;
import com.sun.enterprise.config.serverbeans.Servers;
import com.sun.enterprise.deployment.EjbDescriptor;
import fish.payara.nucleus.cluster.PayaraCluster;

import org.glassfish.enterprise.iiop.api.GlassFishORBFactory;
import org.glassfish.enterprise.iiop.impl.GlassFishORBManager;
import org.glassfish.enterprise.iiop.util.IIOPUtils;
import org.omg.CORBA.ORB;

Expand All @@ -68,16 +76,16 @@ public class SecIORInterceptor extends org.omg.CORBA.LocalObject implements org.
}

private Codec codec;

private PayaraCluster cluster;
private GlassFishORBFactory orbFactory;

// private GlassFishORBHelper helper = null;
private ORB orb;

public SecIORInterceptor(Codec c, ORB orb) {
codec = c;
this.orb = orb;
cluster = Lookups.getCluster();

orbFactory = Lookups.getGlassFishORBFactory();
}

@Override
Expand Down Expand Up @@ -106,33 +114,31 @@ public void establish_components(IORInfo iorInfo) {

private void addCSIv2Components(IORInfo iorInfo) {
EjbDescriptor desc = null;

try {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, ".addCSIv2Components->: " + " " + iorInfo);
if (_logger.isLoggable(FINE)) {
_logger.log(FINE, ".addCSIv2Components->: " + " " + iorInfo);
}

if (cluster != null && cluster.isEnabled()) {
if (orbFactory != null && orbFactory.isClusterActive()) {

// If this app server instance is part of a dynamic cluster (that is,
// one that supports RMI-IIOP failover and load balancing, DO NOT
// create the CSIv2 components here. Instead, handle this in the
// ORB's ServerGroupManager, in conjunctions with the
// If this app server instance is part of a dynamic cluster (that is, one
// that supports RMI-IIOP fail-over and load balancing, or a deployment
// group exists (hazelcast cluster with more than one member, then DO NOT
// create the CSIv2 components here.
//
// Instead, handle this in the ORB's ServerGroupManager, in conjunctions with the
// CSIv2SSLTaggedComponentHandler.
return;
// See org.glassfish.enterprise.iiop.impl.GlassFishORBManager.setFOLBProperties(Properties)

return;
}

if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, ".addCSIv2Components ");
}

// ORB orb = helper.getORB();
int sslMutualAuthPort = getServerPort("SSL_MUTUALAUTH");
// try {
// sslMutualAuthPort = ((com.sun.corba.ee.spi.legacy.interceptor.IORInfoExt)iorInfo).
// getServerPort("SSL_MUTUALAUTH");
// } catch (com.sun.corba.ee.spi.legacy.interceptor.UnknownType ute) {
// _logger.log(Level.FINE,"UnknownType exception", ute);
// }

if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, ".addCSIv2Components: sslMutualAuthPort: " + sslMutualAuthPort);
Expand All @@ -143,14 +149,9 @@ private void addCSIv2Components(IORInfo iorInfo) {

// Create CSIv2 tagged component
int sslport = getServerPort("SSL");
// try {
// sslport = ((com.sun.corba.ee.spi.legacy.interceptor.IORInfoExt)iorInfo).
// getServerPort("SSL");
// } catch (com.sun.corba.ee.spi.legacy.interceptor.UnknownType ute) {
// _logger.log(Level.FINE,"UnknownType exception", ute);
// }
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, ".addCSIv2Components: sslport: " + sslport);

if (_logger.isLoggable(FINE)) {
_logger.log(FINE, ".addCSIv2Components: sslport: " + sslport);
}

TaggedComponent csiv2Comp = null;
Expand Down

0 comments on commit 043f135

Please sign in to comment.