use of org.glassfish.enterprise.iiop.api.IIOPSSLUtil in project Payara by payara.
the class IIOPSSLSocketFactory method init.
/**
* serveralias/clientalias cannot be set at the same time.
* this method encapsulates the common code for both the client side and
* server side to create a SSLContext
* it is called once for each serveralias and once for each clientalias
*/
private SSLInfo init(String alias, boolean ssl2Enabled, String ssl2Ciphers, boolean ssl3Enabled, String ssl3TlsCiphers, boolean tlsEnabled, boolean tlsEnabled11, boolean tlsEnabled12, boolean tlsEnabled13) throws Exception {
String protocol;
if (tlsEnabled13) {
protocol = TLS13;
} else if (tlsEnabled12) {
protocol = TLS12;
} else if (tlsEnabled11) {
protocol = TLS11;
} else if (tlsEnabled) {
protocol = TLS;
} else if (ssl3Enabled) {
protocol = SSL3;
} else if (ssl2Enabled) {
protocol = SSL2;
} else {
// default
protocol = SSL;
}
String[] ssl3TlsCipherArr = null;
if (tlsEnabled11 || tlsEnabled12 || tlsEnabled13 || tlsEnabled || ssl3Enabled) {
ssl3TlsCipherArr = getEnabledCipherSuites(ssl3TlsCiphers, false, ssl3Enabled, tlsEnabled, tlsEnabled11, tlsEnabled12, tlsEnabled13);
}
String[] ssl2CipherArr = null;
if (ssl2Enabled) {
ssl2CipherArr = getEnabledCipherSuites(ssl2Ciphers, true, false, false, false, false, false);
}
SSLContext ctx = SSLContext.getInstance(protocol);
if (Globals.getDefaultHabitat() != null) {
IIOPSSLUtil sslUtil = Globals.getDefaultHabitat().getService(IIOPSSLUtil.class);
KeyManager[] mgrs = sslUtil.getKeyManagers(alias);
ctx.init(mgrs, sslUtil.getTrustManagers(), sslUtil.getInitializedSecureRandom());
} else {
// do nothing
// ctx.init(mgrs, sslUtil.getTrustManagers(), sslUtil.getInitializedSecureRandom());
}
SSLInfo newInfo = new SSLInfo(ctx, ssl3TlsCipherArr, ssl2CipherArr);
if (ssl3Enabled) {
newInfo.addProtocol(SSL3);
}
if (tlsEnabled) {
newInfo.addProtocol(TLS);
}
if (tlsEnabled11) {
newInfo.addProtocol(TLS11);
}
if (tlsEnabled12) {
newInfo.addProtocol(TLS12);
}
if (tlsEnabled13) {
newInfo.addProtocol(TLS13);
}
return newInfo;
}
use of org.glassfish.enterprise.iiop.api.IIOPSSLUtil in project Payara by payara.
the class CSIv2SSLTaggedComponentHandlerImpl method extract.
@Override
public List<SocketInfo> extract(IOR ior) {
List<SocketInfo> socketInfo = null;
try {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "{0}.extract->:", baseMsg);
}
// IIOPProfileTemplate iiopProfileTemplate = (IIOPProfileTemplate)ior.getProfile().getTaggedProfileTemplate();
// IIOPAddress primary = iiopProfileTemplate.getPrimaryAddress() ;
// String host = primary.getHost().toLowerCase(Locale.ENGLISH);
IIOPSSLUtil sslUtil = null;
if (Globals.getDefaultHabitat() != null) {
sslUtil = Globals.getDefaultHabitat().getService(IIOPSSLUtil.class);
socketInfo = (List<SocketInfo>) sslUtil.getSSLPortsAsSocketInfo(ior);
}
if (socketInfo == null) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "{0}.extract: did not find SSL SocketInfo", baseMsg);
}
} else {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "{0}.extract: found SSL socketInfo", baseMsg);
}
}
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "{0}.extract: Connection Context", baseMsg);
}
} catch (Exception ex) {
_logger.log(Level.WARNING, "Exception getting SocketInfo", ex);
} finally {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "{0}.extract<-: {1}", new Object[] { baseMsg, socketInfo });
}
}
return socketInfo;
}
use of org.glassfish.enterprise.iiop.api.IIOPSSLUtil in project Payara by payara.
the class CSIv2SSLTaggedComponentHandlerImpl method insert.
// //////////////////////////////////////////////////
//
// CSIv2SSLTaggedComponentHandler
//
@Override
public TaggedComponent insert(IORInfo iorInfo, List<ClusterInstanceInfo> clusterInstanceInfo) {
TaggedComponent result = null;
try {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "{0}.insert->:", baseMsg);
}
List<com.sun.corba.ee.spi.folb.SocketInfo> socketInfos = new ArrayList<com.sun.corba.ee.spi.folb.SocketInfo>();
for (ClusterInstanceInfo clInstInfo : clusterInstanceInfo) {
for (com.sun.corba.ee.spi.folb.SocketInfo sinfo : clInstInfo.endpoints()) {
if (sinfo.type().equals("SSL") || sinfo.type().equals("SSL_MUTUALAUTH")) {
socketInfos.add(sinfo);
}
}
}
IIOPSSLUtil sslUtil = null;
if (Globals.getDefaultHabitat() != null) {
sslUtil = Globals.getDefaultHabitat().getService(IIOPSSLUtil.class);
return sslUtil.createSSLTaggedComponent(iorInfo, socketInfos);
} else {
return null;
}
} finally {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "{0}.insert<-: {1}", new Object[] { baseMsg, result });
}
}
}
Aggregations