Search in sources :

Example 11 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project wildfly by wildfly.

the class SASTargetInterceptor method receive_request.

@Override
public void receive_request(ServerRequestInfo ri) {
    IIOPLogger.ROOT_LOGGER.tracef("receive_request: %s", ri.operation());
    CurrentRequestInfo threadLocal = threadLocalData.get();
    threadLocal.sasContextReceived = false;
    threadLocal.authenticationTokenReceived = false;
    threadLocal.incomingUsername = empty;
    threadLocal.incomingPassword = empty;
    threadLocal.incomingTargetName = empty;
    threadLocal.incomingIdentity = absent;
    threadLocal.incomingPrincipalName = empty;
    threadLocal.sasReply = null;
    threadLocal.sasReplyIsAccept = false;
    try {
        ServiceContext sc = ri.get_request_service_context(sasContextId);
        Any any = codec.decode_value(sc.context_data, SASContextBodyHelper.type());
        SASContextBody contextBody = SASContextBodyHelper.extract(any);
        if (contextBody != null) {
            if (contextBody.discriminator() == MTMessageInContext.value) {
                // should not happen, as stateful context requests are always negotiated down to stateless in this implementation.
                long contextId = contextBody.in_context_msg().client_context_id;
                threadLocal.sasReply = createMsgCtxError(contextId, 4);
                throw IIOPLogger.ROOT_LOGGER.missingSASContext();
            } else if (contextBody.discriminator() == MTEstablishContext.value) {
                EstablishContext message = contextBody.establish_msg();
                threadLocal.contextId = message.client_context_id;
                threadLocal.sasContextReceived = true;
                if (message.client_authentication_token != null && message.client_authentication_token.length > 0) {
                    IIOPLogger.ROOT_LOGGER.trace("Received client authentication token");
                    InitialContextToken authToken = CSIv2Util.decodeInitialContextToken(message.client_authentication_token, codec);
                    if (authToken == null) {
                        threadLocal.sasReply = createMsgCtxError(message.client_context_id, 2);
                        throw IIOPLogger.ROOT_LOGGER.errorDecodingInitContextToken();
                    }
                    threadLocal.incomingUsername = authToken.username;
                    threadLocal.incomingPassword = authToken.password;
                    threadLocal.incomingTargetName = CSIv2Util.decodeGssExportedName(authToken.target_name);
                    if (threadLocal.incomingTargetName == null) {
                        threadLocal.sasReply = createMsgCtxError(message.client_context_id, 2);
                        throw IIOPLogger.ROOT_LOGGER.errorDecodingTargetInContextToken();
                    }
                    threadLocal.authenticationTokenReceived = true;
                }
                if (message.identity_token != null) {
                    IIOPLogger.ROOT_LOGGER.trace("Received identity token");
                    threadLocal.incomingIdentity = message.identity_token;
                    if (message.identity_token.discriminator() == ITTPrincipalName.value) {
                        // Extract the RFC2743-encoded name from CDR encapsulation.
                        Any a = codec.decode_value(message.identity_token.principal_name(), GSS_NT_ExportedNameHelper.type());
                        byte[] encodedName = GSS_NT_ExportedNameHelper.extract(a);
                        // Decode the principal name.
                        threadLocal.incomingPrincipalName = CSIv2Util.decodeGssExportedName(encodedName);
                        if (threadLocal.incomingPrincipalName == null) {
                            threadLocal.sasReply = createMsgCtxError(message.client_context_id, 2);
                            throw IIOPLogger.ROOT_LOGGER.errorDecodingPrincipalName();
                        }
                    }
                }
                threadLocal.sasReply = (threadLocal.contextId == 0) ? msgCtx0Accepted : createMsgCtxAccepted(threadLocal.contextId);
                threadLocal.sasReplyIsAccept = true;
            }
        }
    } catch (BAD_PARAM e) {
    // no service context with sasContextId: do nothing.
    } catch (FormatMismatch e) {
        throw IIOPLogger.ROOT_LOGGER.errorDecodingContextData(this.name(), e);
    } catch (TypeMismatch e) {
        throw IIOPLogger.ROOT_LOGGER.errorDecodingContextData(this.name(), e);
    }
}
Also used : ServiceContext(org.omg.IOP.ServiceContext) InitialContextToken(org.omg.GSSUP.InitialContextToken) BAD_PARAM(org.omg.CORBA.BAD_PARAM) SASContextBody(org.omg.CSI.SASContextBody) CompleteEstablishContext(org.omg.CSI.CompleteEstablishContext) EstablishContext(org.omg.CSI.EstablishContext) MTEstablishContext(org.omg.CSI.MTEstablishContext) Any(org.omg.CORBA.Any) FormatMismatch(org.omg.IOP.CodecPackage.FormatMismatch) TypeMismatch(org.omg.IOP.CodecPackage.TypeMismatch)

Example 12 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project wildfly by wildfly.

the class CNCtx method callBindOrRebind.

/**
     * Performs bind or rebind in the context depending on whether the
     * flag rebind is set. The only objects allowed to be bound are of
     * types org.omg.CORBA.Object, org.omg.CosNaming.NamingContext.
     * You can use a state factory to turn other objects (such as
     * Remote) into these acceptable forms.
     * <p/>
     * Uses the COS Naming apis bind/rebind or
     * bind_context/rebind_context.
     *
     * @param pth    NameComponent[] object
     * @param obj    Object to be bound.
     * @param rebind perform rebind ? if true performs a rebind.
     * @throws NotFound      No objects under the name.
     * @throws org.omg.CosNaming.NamingContextPackage.CannotProceed Unable to obtain a continuation context
     * @throws org.omg.CosNaming.NamingContextPackage.AlreadyBound  An object is already bound to this name.
     */
private void callBindOrRebind(NameComponent[] pth, Name name, java.lang.Object obj, boolean rebind) throws NamingException {
    if (_nc == null)
        throw IIOPLogger.ROOT_LOGGER.notANamingContext(name.toString());
    try {
        // Call state factories to convert
        obj = NamingManager.getStateToBind(obj, name, this, _env);
        if (obj instanceof CNCtx) {
            // Use naming context object reference
            obj = ((CNCtx) obj)._nc;
        }
        if (obj instanceof org.omg.CosNaming.NamingContext) {
            NamingContext nobj = NamingContextHelper.narrow((org.omg.CORBA.Object) obj);
            if (rebind)
                _nc.rebind_context(pth, nobj);
            else
                _nc.bind_context(pth, nobj);
        } else if (obj instanceof org.omg.CORBA.Object) {
            if (rebind)
                _nc.rebind(pth, (org.omg.CORBA.Object) obj);
            else
                _nc.bind(pth, (org.omg.CORBA.Object) obj);
        } else
            throw IIOPLogger.ROOT_LOGGER.notACorbaObject();
    } catch (BAD_PARAM e) {
        // probably narrow() failed?
        NamingException ne = new NotContextException(name.toString());
        ne.setRootCause(e);
        throw ne;
    } catch (Exception e) {
        throw org.wildfly.iiop.openjdk.naming.jndi.ExceptionMapper.mapException(e, this, pth);
    }
}
Also used : NotContextException(javax.naming.NotContextException) BAD_PARAM(org.omg.CORBA.BAD_PARAM) NamingException(javax.naming.NamingException) NamingContext(org.omg.CosNaming.NamingContext) ConfigurationException(javax.naming.ConfigurationException) NamingException(javax.naming.NamingException) NameNotFoundException(javax.naming.NameNotFoundException) CannotProceedException(javax.naming.CannotProceedException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) NotContextException(javax.naming.NotContextException)

Example 13 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project wildfly by wildfly.

the class TxServerInterceptor method receive_request_service_contexts.

public void receive_request_service_contexts(ServerRequestInfo ri) {
    IIOPLogger.ROOT_LOGGER.tracef("Intercepting receive_request_service_contexts, operation: %s", ri.operation());
    try {
        ServiceContext sc = ri.get_request_service_context(txContextId);
        Any any = codec.decode_value(sc.context_data, PropagationContextHelper.type());
        ri.set_slot(slotId, any);
    } catch (BAD_PARAM e) {
    // no service context with txContextId: do nothing
    } catch (FormatMismatch e) {
        throw IIOPLogger.ROOT_LOGGER.errorDecodingContextData(this.name(), e);
    } catch (TypeMismatch e) {
        throw IIOPLogger.ROOT_LOGGER.errorDecodingContextData(this.name(), e);
    } catch (InvalidSlot e) {
        throw IIOPLogger.ROOT_LOGGER.errorSettingSlotInTxInterceptor(e);
    }
}
Also used : ServiceContext(org.omg.IOP.ServiceContext) BAD_PARAM(org.omg.CORBA.BAD_PARAM) InvalidSlot(org.omg.PortableInterceptor.InvalidSlot) Any(org.omg.CORBA.Any) FormatMismatch(org.omg.IOP.CodecPackage.FormatMismatch) TypeMismatch(org.omg.IOP.CodecPackage.TypeMismatch)

Example 14 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project wildfly by wildfly.

the class CSIv2IORInterceptor method establish_components.

@Override
public void establish_components(IORInfo info) {
    // check if CSIv2 policy is in effect for this IOR.
    CSIv2Policy csiv2Policy = null;
    try {
        csiv2Policy = (CSIv2Policy) info.get_effective_policy(CSIv2Policy.TYPE);
    } catch (BAD_PARAM e) {
        IIOPLogger.ROOT_LOGGER.debug("CSIv2Policy not found in IORInfo");
    } catch (Exception e) {
        IIOPLogger.ROOT_LOGGER.failedToFetchCSIv2Policy(e);
    }
    if (csiv2Policy != null) {
        // if csiv2Policy effective, stuff a copy of the TaggedComponents already created by the CSIv2Policy into the IOR's IIOP profile.
        TaggedComponent sslComponent = csiv2Policy.getSSLTaggedComponent();
        // if interop with IONA ASP is on, don't add the SSL component to the IOR.
        if (sslComponent != null) {
            info.add_ior_component_to_profile(sslComponent, TAG_INTERNET_IOP.value);
        }
        TaggedComponent csiv2Component = csiv2Policy.getSecurityTaggedComponent();
        if (csiv2Component != null) {
            info.add_ior_component_to_profile(csiv2Component, TAG_INTERNET_IOP.value);
        }
    } else {
        if (defaultSSLComponent != null) {
            // otherwise stuff the default SSL component (with the minimum set of SSL options) into the IOR's IIOP profile.
            info.add_ior_component_to_profile(defaultSSLComponent, TAG_INTERNET_IOP.value);
        }
        if (defaultCSIComponent != null) {
            // and stuff the default CSI component (with the minimum set of CSI options) into the IOR's IIOP profile.
            info.add_ior_component_to_profile(defaultCSIComponent, TAG_INTERNET_IOP.value);
        }
    }
}
Also used : TaggedComponent(org.omg.IOP.TaggedComponent) BAD_PARAM(org.omg.CORBA.BAD_PARAM)

Example 15 with BAD_PARAM

use of org.omg.CORBA.BAD_PARAM in project wildfly by wildfly.

the class CSIv2Util method getMatchingSecurityMech.

/**
     * <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.
     */
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);
    }
}
Also used : SAS_ContextSec(org.omg.CSIIOP.SAS_ContextSec) AS_ContextSec(org.omg.CSIIOP.AS_ContextSec) CompoundSecMechList(org.omg.CSIIOP.CompoundSecMechList) TaggedComponent(org.omg.IOP.TaggedComponent) CompoundSecMech(org.omg.CSIIOP.CompoundSecMech) BAD_PARAM(org.omg.CORBA.BAD_PARAM) SAS_ContextSec(org.omg.CSIIOP.SAS_ContextSec) Any(org.omg.CORBA.Any)

Aggregations

BAD_PARAM (org.omg.CORBA.BAD_PARAM)31 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)13 BadParametersException (com.cosylab.acs.maci.BadParametersException)13 CoreException (com.cosylab.acs.maci.CoreException)13 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)13 UNKNOWN (org.omg.CORBA.UNKNOWN)13 NO_RESOURCES (org.omg.CORBA.NO_RESOURCES)12 Any (org.omg.CORBA.Any)9 Object (org.omg.CORBA.Object)8 FormatMismatch (org.omg.IOP.CodecPackage.FormatMismatch)8 TypeMismatch (org.omg.IOP.CodecPackage.TypeMismatch)8 ServiceContext (org.omg.IOP.ServiceContext)8 URI (java.net.URI)7 URISyntaxException (java.net.URISyntaxException)7 SASContextBody (org.omg.CSI.SASContextBody)7 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)6 AcsJNarrowFailedEx (alma.ACSErrTypeCORBA.wrappers.AcsJNarrowFailedEx)4 AcsJCORBAProblemEx (alma.ACSErrTypeCommon.wrappers.AcsJCORBAProblemEx)4 Component (com.cosylab.acs.maci.Component)4 ComponentInfo (si.ijs.maci.ComponentInfo)4