iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/csiv2/CSIv2Util.java
public static CompoundSecMech getMatchingSecurityMech(ClientRequestInfo ri, Codec codec, short clientSupports,
                                                          short clientRequires) {
        CompoundSecMechList csmList;
        try {
            TaggedComponent tc = ri.get_effective_component(org.omg.IOP.TAG_CSI_SEC_MECH_LIST.value);

            Any any = codec.decode_value(tc.component_data, CompoundSecMechListHelper.type());
            csmList = CompoundSecMechListHelper.extract(any);

            // look for the first matching security mech.
            for (int i = 0; i < csmList.mechanism_list.length; i++) {
                CompoundSecMech securityMech = csmList.mechanism_list[i];
                AS_ContextSec authConfig = securityMech.as_context_mech;

                if ((EstablishTrustInTarget.value & (clientRequires ^ authConfig.target_supports)
                        & ~authConfig.target_supports) != 0) {
                    // client requires EstablishTrustInTarget, but target does not support it: skip this securityMech.
                    continue;
                }

                if ((EstablishTrustInClient.value & (authConfig.target_requires ^ clientSupports)
                        & ~clientSupports) != 0) {
                    // target requires EstablishTrustInClient, but client does not support it: skip this securityMech.
                    continue;
                }

                SAS_ContextSec identityConfig = securityMech.sas_context_mech;

                if ((IdentityAssertion.value & (identityConfig.target_requires ^ clientSupports)
                        & ~clientSupports) != 0) {
                    // target requires IdentityAssertion, but client does not support it: skip this securityMech
                    continue;
                }

                // found matching securityMech.
                return securityMech;
            }
            // no matching securityMech was found.
            return null;
        } catch (BAD_PARAM e) {
            // no component with TAG_CSI_SEC_MECH_LIST was found.
            return null;
        } catch (org.omg.IOP.CodecPackage.TypeMismatch e) {
            // unexpected exception in codec
            throw IIOPLogger.ROOT_LOGGER.unexpectedException(e);
        } catch (org.omg.IOP.CodecPackage.FormatMismatch e) {
            // unexpected exception in codec
            throw IIOPLogger.ROOT_LOGGER.unexpectedException(e);
        }
    }
public static CompoundSecMech getMatchingSecurityMech(ClientRequestInfo ri, Codec codec, short clientSupports,
                                                          short clientRequires) {
        CompoundSecMechList csmList;
        try {
            TaggedComponent tc = ri.get_effective_component(org.omg.IOP.TAG_CSI_SEC_MECH_LIST.value);

            Any any = codec.decode_value(tc.component_data, CompoundSecMechListHelper.type());
            csmList = CompoundSecMechListHelper.extract(any);

            // look for the first matching security mech.
            for (int i = 0; i < csmList.mechanism_list.length; i++) {
                CompoundSecMech securityMech = csmList.mechanism_list[i];
                AS_ContextSec authConfig = securityMech.as_context_mech;

                if ((EstablishTrustInTarget.value & (clientRequires ^ authConfig.target_supports)
                        & ~authConfig.target_supports) != 0) {
                    // client requires EstablishTrustInTarget, but target does not support it: skip this securityMech.
                    continue;
                }

                if ((EstablishTrustInClient.value & (authConfig.target_requires ^ clientSupports)
                        & ~clientSupports) != 0) {
                    // target requires EstablishTrustInClient, but client does not support it: skip this securityMech.
                    continue;
                }

                SAS_ContextSec identityConfig = securityMech.sas_context_mech;

                if ((IdentityAssertion.value & (identityConfig.target_requires ^ clientSupports)
                        & ~clientSupports) != 0) {
                    // target requires IdentityAssertion, but client does not support it: skip this securityMech
                    continue;
                }

                // found matching securityMech.
                return securityMech;
            }
            // no matching securityMech was found.
            return null;
        } catch (BAD_PARAM e) {
            // no component with TAG_CSI_SEC_MECH_LIST was found.
            return null;
        } catch (org.omg.IOP.CodecPackage.TypeMismatch e) {
            // unexpected exception in codec
            throw IIOPLogger.ROOT_LOGGER.unexpectedException(e);
        } catch (org.omg.IOP.CodecPackage.FormatMismatch e) {
            // unexpected exception in codec
            throw IIOPLogger.ROOT_LOGGER.unexpectedException(e);
        }
    }
public static CompoundSecMech getMatchingSecurityMech ( ClientRequestInfo ri , Codec codec , short clientSupports , short clientRequires ) { CompoundSecMechList csmList ; try { TaggedComponent tc = ri . get_effective_component ( org . omg . IOP . TAG_CSI_SEC_MECH_LIST . value ) ; Any any = codec . decode_value ( tc . component_data , CompoundSecMechListHelper . type ( ) ) ; csmList = CompoundSecMechListHelper . extract ( any ) ; // look for the first matching security mech. for ( int i = 0 ; i < csmList . mechanism_list . length ; i ++ ) { CompoundSecMech securityMech = csmList . mechanism_list [ i ] ; AS_ContextSec authConfig = securityMech . as_context_mech ; if ( ( EstablishTrustInTarget . value & ( clientRequires ^ authConfig . target_supports ) & ~ authConfig . target_supports ) != 0 ) { // client requires EstablishTrustInTarget, but target does not support it: skip this securityMech. continue ; } if ( ( EstablishTrustInClient . value & ( authConfig . target_requires ^ clientSupports ) & ~ clientSupports ) != 0 ) { // target requires EstablishTrustInClient, but client does not support it: skip this securityMech. continue ; } SAS_ContextSec identityConfig = securityMech . sas_context_mech ; if ( ( IdentityAssertion . value & ( identityConfig . target_requires ^ clientSupports ) & ~ clientSupports ) != 0 ) { // target requires IdentityAssertion, but client does not support it: skip this securityMech continue ; } // found matching securityMech. return securityMech ; } // no matching securityMech was found. return null ; } catch ( BAD_PARAM e ) { // no component with TAG_CSI_SEC_MECH_LIST was found. return null ; } catch ( org . omg . IOP . CodecPackage . TypeMismatch e ) { // unexpected exception in codec throw IIOPLogger . ROOT_LOGGER . unexpectedException ( e ) ; } catch ( org . omg . IOP . CodecPackage . FormatMismatch e ) { // unexpected exception in codec throw IIOPLogger . ROOT_LOGGER . unexpectedException ( e ) ; } }
<p>
Helper method to be called from a client request interceptor. The {@code ri} parameter refers to the current
request. This method returns the first {@code CompoundSecMech} found in the target IOR such that
<ul>
<li>all {@code CompoundSecMech} requirements are satisfied by the options in the {@code clientSupports}
parameter, and</li>
<li>every requirement in the {@code clientRequires} parameter is satisfied by the {@code CompoundSecMech}.
</li>
</ul>
The method returns null if the target IOR contains no {@code CompoundSecMech}s or if no matching
{@code CompoundSecMech} is found.
</p>
<p>
Since this method is intended to be called from a client request interceptor, it converts unexpected exceptions
into {@code MARSHAL} exceptions.
</p>

@param ri             a reference to the current {@code ClientRequestInfo}.
@param codec          the {@code Codec} used to decode the CSIv2 components.
@param clientSupports the client supported transport options that must be satisfied by the {@code CompoundSecMech}.
@param clientRequires the client required transport options that must be satisfied by the {@code CompoundSecMech}.
@return the {@code CompoundSecMech} instance that satisfies all client options, or {@code null} if no such object
can be found.
<p > Helper method to be called from a client request interceptor . The { @code ri } parameter refers to the current request . This method returns the first { @code CompoundSecMech } found in the target IOR such that <ul > <li > all { @code CompoundSecMech } requirements are satisfied by the options in the { @code clientSupports } parameter and< / li > <li > every requirement in the { @code clientRequires } parameter is satisfied by the { @code CompoundSecMech } . < / li > < / ul > The method returns null if the target IOR contains no { @code CompoundSecMech } s or if no matching { @code CompoundSecMech } is found . < / p > <p > Since this method is intended to be called from a client request interceptor it converts unexpected exceptions into { @code MARSHAL } exceptions . < / p >