use of org.omg.CSIIOP.TransportAddress in project wildfly by wildfly.
the class CSIV2IORToSocketInfo method getSocketInfo.
public List getSocketInfo(IOR ior) {
List result = new ArrayList();
IIOPProfileTemplate iiopProfileTemplate = (IIOPProfileTemplate) ior.getProfile().getTaggedProfileTemplate();
IIOPAddress primary = iiopProfileTemplate.getPrimaryAddress();
String hostname = primary.getHost().toLowerCase(Locale.ENGLISH);
int primaryPort = primary.getPort();
// NOTE: we could check for 0 (i.e., CSIv2) but, for a
// non-CSIv2-configured client ORB talking to a CSIv2 configured
// server ORB you might end up with an empty contact info list
// which would then report a failure which would not be as
// instructive as leaving a ContactInfo with a 0 port in the list.
SocketInfo socketInfo;
TransportAddress sslAddress = selectSSLTransportAddress(ior);
SSL ssl = getSSL(ior);
if (sslAddress != null) {
socketInfo = createSSLSocketInfo(hostname, sslAddress.port);
} else if (ssl != null) {
socketInfo = createSSLSocketInfo(hostname, ssl.port);
} else {
// FIXME not all corba object export ssl port
// if (clientRequiresSsl) {
// throw new RuntimeException("Client requires SSL but target does not support it");
// }
socketInfo = createSocketInfo(hostname, primaryPort);
}
result.add(socketInfo);
addAlternateSocketInfos(iiopProfileTemplate, result);
return result;
}
use of org.omg.CSIIOP.TransportAddress in project wildfly by wildfly.
the class CSIv2Util method createTransportAddress.
/**
* <p>
* Create a {@code TransportAddress[]} with a single {@code TransportAddress}.
* </p>
*
* @param host a {@code String} representing the address host.
* @param port an {@code int} representing the address port.
* @return the constructed {@code TransportAddress} array.
*/
public static TransportAddress[] createTransportAddress(String host, int port) {
// idl type is unsigned sort, so we need this trick
short short_port = (port > 32767) ? (short) (port - 65536) : (short) port;
TransportAddress ta = new TransportAddress(host, short_port);
TransportAddress[] taList = new TransportAddress[1];
taList[0] = ta;
return taList;
}
use of org.omg.CSIIOP.TransportAddress in project wildfly by wildfly.
the class CSIv2Util method createTransportMech.
/**
* <p>
* Create a transport mechanism {@code TaggedComponent} to be stuffed into a {@code CompoundSecMech}.
* </p>
* <p>
* If no {@code TransportConfig} metadata is specified, or ssl port is negative, or the specified metadata indicates
* that transport config is not supported, then a {@code TAG_NULL_TAG} (empty) {@code TaggedComponent} will be returned.
* </p>
* <p>
* Otherwise a {@code org.omg.CSIIOP.TLS_SEC_TRANS}, tagged as {@code TAG_TLS_SEC_TRANS} will be returned, indicating support
* for TLS/SSL as a CSIv2 transport mechanism.
* </p>
* <p>
* Multiple {@code TransportAddress} may be included in the SSL info (host/port pairs), but we only include one.
* </p>
*
* @param tconfig the transport configuration metadata.
* @param codec the {@code Codec} used to encode the transport configuration.
* @param sslPort an {@code int} representing the SSL port.
* @param orb a reference to the running {@code ORB}.
* @return the constructed {@code TaggedComponent}.
*/
public static TaggedComponent createTransportMech(IORTransportConfigMetaData tconfig, Codec codec, int sslPort, ORB orb) {
TaggedComponent tc;
// what we support and require as a target.
int support = 0;
int require = 0;
if (tconfig != null) {
require = createTargetRequires(tconfig);
support = createTargetSupports(tconfig);
}
if (tconfig == null || support == 0 || sslPort == 0) {
// no support for transport security.
tc = new TaggedComponent(TAG_NULL_TAG.value, new byte[0]);
} else {
// my ip address.
String host = CorbaORBService.getORBProperty(Constants.ORB_ADDRESS);
// this will create only one transport address.
TransportAddress[] taList = createTransportAddress(host, sslPort);
TLS_SEC_TRANS tst = new TLS_SEC_TRANS((short) support, (short) require, taList);
// The tricky part, we must encode TLS_SEC_TRANS into an octet sequence.
try {
Any any = orb.create_any();
TLS_SEC_TRANSHelper.insert(any, tst);
byte[] b = codec.encode_value(any);
tc = new TaggedComponent(TAG_TLS_SEC_TRANS.value, b);
} catch (InvalidTypeForEncoding e) {
throw IIOPLogger.ROOT_LOGGER.unexpectedException(e);
}
}
return tc;
}
Aggregations