Search in sources :

Example 1 with TaggedComponent

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;
}
Also used : TaggedComponent(org.omg.IOP.TaggedComponent) SSL(org.omg.SSLIOP.SSL) Any(org.omg.CORBA.Any) InvalidTypeForEncoding(org.omg.IOP.CodecPackage.InvalidTypeForEncoding)

Example 2 with TaggedComponent

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;
}
Also used : CompoundSecMechList(org.omg.CSIIOP.CompoundSecMechList) TaggedComponent(org.omg.IOP.TaggedComponent) CompoundSecMech(org.omg.CSIIOP.CompoundSecMech) Any(org.omg.CORBA.Any) InvalidTypeForEncoding(org.omg.IOP.CodecPackage.InvalidTypeForEncoding)

Example 3 with TaggedComponent

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;
}
Also used : TaggedComponent(org.omg.IOP.TaggedComponent) CDRInputStream(com.sun.corba.se.impl.encoding.CDRInputStream) EncapsInputStream(com.sun.corba.se.impl.encoding.EncapsInputStream) Iterator(java.util.Iterator) SSL(org.omg.SSLIOP.SSL) ORB(com.sun.corba.se.spi.orb.ORB)

Example 4 with TaggedComponent

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);
    }
}
Also used : TaggedComponent(org.omg.IOP.TaggedComponent) Any(org.omg.CORBA.Any) InvalidTypeForEncoding(org.omg.IOP.CodecPackage.InvalidTypeForEncoding)

Example 5 with TaggedComponent

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);
}
Also used : TaggedComponent(org.omg.IOP.TaggedComponent) CDRInputStream(com.sun.corba.se.impl.encoding.CDRInputStream) EncapsInputStream(com.sun.corba.se.impl.encoding.EncapsInputStream) ORB(com.sun.corba.se.spi.orb.ORB)

Aggregations

TaggedComponent (org.omg.IOP.TaggedComponent)11 Any (org.omg.CORBA.Any)5 InvalidTypeForEncoding (org.omg.IOP.CodecPackage.InvalidTypeForEncoding)4 CDRInputStream (com.sun.corba.se.impl.encoding.CDRInputStream)3 EncapsInputStream (com.sun.corba.se.impl.encoding.EncapsInputStream)3 ORB (com.sun.corba.se.spi.orb.ORB)3 CompoundSecMech (org.omg.CSIIOP.CompoundSecMech)3 Iterator (java.util.Iterator)2 BAD_PARAM (org.omg.CORBA.BAD_PARAM)2 AS_ContextSec (org.omg.CSIIOP.AS_ContextSec)2 CompoundSecMechList (org.omg.CSIIOP.CompoundSecMechList)2 SAS_ContextSec (org.omg.CSIIOP.SAS_ContextSec)2 SSL (org.omg.SSLIOP.SSL)2 TAG_TLS_SEC_TRANS (org.omg.CSIIOP.TAG_TLS_SEC_TRANS)1 TLS_SEC_TRANS (org.omg.CSIIOP.TLS_SEC_TRANS)1 TransportAddress (org.omg.CSIIOP.TransportAddress)1