use of org.omg.IOP.TaggedComponent in project wildfly by wildfly.
the class CSIv2Util method createSSLTaggedComponent.
/**
* <p>
* Return a top-level {@code IOP::TaggedComponent} to be stuffed into an IOR, containing a structure
* {@code SSLIOP::SSL}, tagged as {@code TAG_SSL_SEC_TRANS}.
* </p>
* <p>
* Should be called with non-null metadata, in which case we probably don't want to include security info in the IOR.
* </p>
*
* @param metadata the metadata object that contains the SSL configuration info.
* @param codec the {@code Codec} used to encode the SSL component.
* @param sslPort an {@code int} representing the SSL port.
* @param orb a reference to the running {@code ORB}.
* @return a {@code TaggedComponent} representing the encoded SSL component.
*/
public static TaggedComponent createSSLTaggedComponent(IORSecurityConfigMetaData metadata, Codec codec, int sslPort, ORB orb) {
if (metadata == null) {
IIOPLogger.ROOT_LOGGER.debug("Method createSSLTaggedComponent() called with null metadata");
return null;
}
if (sslPort == 0) {
// no support for transport security.
return null;
}
TaggedComponent tc;
try {
int supports = createTargetSupports(metadata.getTransportConfig());
int requires = createTargetRequires(metadata.getTransportConfig());
SSL ssl = new SSL((short) supports, (short) requires, (short) sslPort);
Any any = orb.create_any();
SSLHelper.insert(any, ssl);
byte[] componentData = codec.encode_value(any);
tc = new TaggedComponent(TAG_SSL_SEC_TRANS.value, componentData);
} catch (InvalidTypeForEncoding e) {
throw IIOPLogger.ROOT_LOGGER.unexpectedException(e);
}
return tc;
}
use of org.omg.IOP.TaggedComponent in project wildfly by wildfly.
the class CSIv2Util method createSecurityTaggedComponent.
/**
* <p>
* Return a top-level {@code IOP:TaggedComponent} to be stuffed into an IOR, containing a {@code org.omg.CSIIOP}.
* {@code CompoundSecMechList}, tagged as {@code TAG_CSI_SEC_MECH_LIST}. Only one such component can exist inside
* an IOR.
* </p>
* <p>
* Should be called with non-null metadata, in which case we probably don't want to include security info in the IOR.
* </p>
*
* @param metadata the metadata object that contains the CSIv2 security configuration info.
* @param codec the {@code Codec} used to encode the CSIv2 security component.
* @param sslPort an {@code int} representing the SSL port.
* @param orb a reference to the running {@code ORB}.
* @return a {@code TaggedComponent} representing the encoded CSIv2 security component.
*/
public static TaggedComponent createSecurityTaggedComponent(IORSecurityConfigMetaData metadata, Codec codec, int sslPort, ORB orb) {
if (metadata == null) {
IIOPLogger.ROOT_LOGGER.debug("Method createSecurityTaggedComponent() called with null metadata");
return null;
}
TaggedComponent tc;
// get the the supported security mechanisms.
CompoundSecMech[] mechList = createCompoundSecMechanisms(metadata, codec, sslPort, orb);
// the above is wrapped into a org.omg.CSIIOP.CompoundSecMechList structure, which is NOT a CompoundSecMech[].
// we don't support stateful/reusable security contexts (false).
CompoundSecMechList csmList = new CompoundSecMechList(false, mechList);
// finally, the CompoundSecMechList must be encoded as a TaggedComponent
try {
Any any = orb.create_any();
CompoundSecMechListHelper.insert(any, csmList);
byte[] b = codec.encode_value(any);
tc = new TaggedComponent(TAG_CSI_SEC_MECH_LIST.value, b);
} catch (InvalidTypeForEncoding e) {
throw IIOPLogger.ROOT_LOGGER.unexpectedException(e);
}
return tc;
}
use of org.omg.IOP.TaggedComponent in project wildfly by wildfly.
the class CSIV2IORToSocketInfo method getSSL.
private SSL getSSL(IOR ior) {
Iterator iter = ior.getProfile().getTaggedProfileTemplate().iteratorById(TAG_SSL_SEC_TRANS.value);
if (!iter.hasNext()) {
return null;
}
ORB orb = ior.getORB();
TaggedComponent compList = ((com.sun.corba.se.spi.ior.TaggedComponent) iter.next()).getIOPComponent(orb);
CDRInputStream in = doPrivileged(new PrivilegedAction<CDRInputStream>() {
@Override
public CDRInputStream run() {
return new EncapsInputStream(orb, compList.component_data, compList.component_data.length);
}
});
in.consumeEndian();
SSL ssl = SSLHelper.read(in);
boolean targetRequiresSsl = ssl.target_requires > 0;
boolean targetSupportsSsl = ssl.target_supports > 0;
if (!targetSupportsSsl && clientRequiresSsl) {
throw IIOPLogger.ROOT_LOGGER.serverDoesNotSupportSsl();
}
return targetSupportsSsl && (targetRequiresSsl || clientRequiresSsl) ? ssl : null;
}
use of org.omg.IOP.TaggedComponent in project wildfly by wildfly.
the class TxIORInterceptor method establish_components.
public void establish_components(IORInfo info) {
try {
// Invocation Policy = EITHER
Any any = ORB.init().create_any();
any.insert_short(EITHER);
byte[] taggedComponentData = codec.encode_value(any);
info.add_ior_component(new TaggedComponent(TAG_INV_POLICY, taggedComponentData));
// OTS Policy = ADAPTS
any = ORB.init().create_any();
any.insert_short(ADAPTS);
taggedComponentData = codec.encode_value(any);
info.add_ior_component(new TaggedComponent(TAG_OTS_POLICY, taggedComponentData));
} catch (InvalidTypeForEncoding e) {
throw IIOPLogger.ROOT_LOGGER.errorEncodingContext(e);
}
}
use of org.omg.IOP.TaggedComponent in project wildfly by wildfly.
the class CSIV2IORToSocketInfo method extractTlsSecTrans.
private TLS_SEC_TRANS extractTlsSecTrans(IOR ior, CompoundSecMech mech) {
TaggedComponent comp = mech.transport_mech;
if (comp.tag != TAG_TLS_SEC_TRANS.value) {
return null;
}
ORB orb = ior.getORB();
CDRInputStream in = doPrivileged(new PrivilegedAction<CDRInputStream>() {
@Override
public CDRInputStream run() {
return new EncapsInputStream(orb, comp.component_data, comp.component_data.length);
}
});
in.consumeEndian();
return TLS_SEC_TRANSHelper.read(in);
}
Aggregations