/** * <p> * Make a deep copy of an {@code IOP:TaggedComponent}. * </p> * * @param tc the {@code TaggedComponent} to be copied. * @return a reference to the created copy. */ public static TaggedComponent createCopy(TaggedComponent tc) { TaggedComponent copy = null; if (tc != null) { byte[] buf = new byte[tc.component_data.length]; System.arraycopy(tc.component_data, 0, buf, 0, tc.component_data.length); copy = new TaggedComponent(tc.tag, buf); } return copy; }
@Override public void send_reply(ServerRequestInfo ri) { IIOPLogger.ROOT_LOGGER.tracef("send_reply: %s", ri.operation()); CurrentRequestInfo threadLocal = (CurrentRequestInfo) threadLocalData.get(); if (threadLocal.sasReply != null) { try { ServiceContext sc = new ServiceContext(sasContextId, codec.encode_value(threadLocal.sasReply)); ri.add_reply_service_context(sc, true); } catch (InvalidTypeForEncoding e) { throw IIOPLogger.ROOT_LOGGER.unexpectedException(e); } } }
public void post_init(ORBInitInfo info) { try { // Use CDR encapsulation with GIOP 1.0 encoding Encoding encoding = new Encoding(ENCODING_CDR_ENCAPS.value, (byte) 1, /* GIOP version */ (byte) 0 /* GIOP revision*/); Codec codec = info.codec_factory().create_codec(encoding); info.add_ior_interceptor(new TxIORInterceptor(codec)); } catch (Exception e) { throw IIOPLogger.ROOT_LOGGER.unexpectedException(e); } } }
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); } } }
Any any; try { any = codec.decode_value(encodedInitialContextToken, InitialContextTokenHelper.type()); } catch (Exception e) { return null;
@Override public void post_init(ORBInitInfo info) { try { // use CDR encapsulation with GIOP 1.0 encoding. Encoding encoding = new Encoding(ENCODING_CDR_ENCAPS.value, (byte) 1, /* GIOP version */ (byte) 0 /* GIOP revision*/); Codec codec = info.codec_factory().create_codec(encoding); // add IOR interceptor for CSIv2. info.add_ior_interceptor(new CSIv2IORInterceptor(codec)); // register CSIv2-related policy factories. info.register_policy_factory(CSIv2Policy.TYPE, new CSIv2PolicyFactory(codec)); } catch (Exception e) { throw IIOPLogger.ROOT_LOGGER.unexpectedException(e); } } }
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);
@Override public void send_exception(ServerRequestInfo ri) { IIOPLogger.ROOT_LOGGER.tracef("send_exception: %s", ri.operation()); CurrentRequestInfo threadLocal = (CurrentRequestInfo) threadLocalData.get(); // The check below was added for interoperability with IONA's ASP 6.0, which throws an // ArrayIndexOutOfBoundsException when it receives an IIOP reply carrying both an application exception // and a SAS reply CompleteEstablishContext. The flag serves the purpose of refraining fromsending an SAS // accept (CompleteEstablishContext) reply together with an exception. // // The CSIv2 spec does not explicitly disallow an SAS accept in an IIOP exception reply. boolean interopIONA = Boolean.valueOf(CorbaORBService.getORBProperty(Constants.INTEROP_IONA)); if (threadLocal.sasReply != null && !interopIONA) { try { ServiceContext sc = new ServiceContext(sasContextId, codec.encode_value(threadLocal.sasReply)); ri.add_reply_service_context(sc, true); } catch (InvalidTypeForEncoding e) { throw IIOPLogger.ROOT_LOGGER.unexpectedException(e); } } }
@Override public void receive_exception(ClientRequestInfo ri) throws ForwardRequest { try { ServiceContext sc = ri.get_reply_service_context(SAS_CONTEXT_ID); Any msg = codec.decode_value(sc.context_data, SASContextBodyHelper.type()); SASContextBody contextBody = SASContextBodyHelper.extract(msg); // At this point contextBody may contain either a CompleteEstablishContext message or a ContextError message. // Neither message requires any treatment. We decoded the context body just to check that it contains // a well-formed message. IIOPLogger.ROOT_LOGGER.tracef("receive_exception: got SAS reply, type %d", contextBody.discriminator()); } catch (BAD_PARAM e) { // no service context with sasContextId: do nothing. } catch (FormatMismatch | TypeMismatch e) { throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0, CompletionStatus.COMPLETED_MAYBE); } }
public void post_init(ORBInitInfo info) { try { // Use CDR encapsulation with GIOP 1.0 encoding Encoding encoding = new Encoding(ENCODING_CDR_ENCAPS.value, (byte) 1, /* GIOP version */ (byte) 0 /* GIOP revision*/); Codec codec = info.codec_factory().create_codec(encoding); // Get a reference to the PICurrent org.omg.CORBA.Object obj = info.resolve_initial_references("PICurrent"); org.omg.PortableInterceptor.Current piCurrent = org.omg.PortableInterceptor.CurrentHelper.narrow(obj); // Initialize the fields slot id, codec, and piCurrent // in the interceptor class TxServerInterceptor.init(info.allocate_slot_id(), codec, piCurrent); // Create and register interceptor TxServerInterceptor interceptor = new TxServerInterceptor(); info.add_server_request_interceptor(interceptor); } catch (Exception e) { throw IIOPLogger.ROOT_LOGGER.unexpectedException(e); } }
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);
@Override public void receive_exception(ClientRequestInfo ri) { try { ServiceContext sc = ri.get_reply_service_context(sasContextId); Any msg = codec.decode_value(sc.context_data, SASContextBodyHelper.type()); SASContextBody contextBody = SASContextBodyHelper.extract(msg); // At this point contextBody may contain either a CompleteEstablishContext message or a ContextError message. // Neither message requires any treatment. We decoded the contextbody just to check that it contains a // well-formed message. IIOPLogger.ROOT_LOGGER.tracef("receive_exception: got SAS reply, type %d", contextBody.discriminator()); } catch (BAD_PARAM e) { // no service context with sasContextId: do nothing. } catch (FormatMismatch e) { throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0, CompletionStatus.COMPLETED_MAYBE); } catch (TypeMismatch e) { throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0, CompletionStatus.COMPLETED_MAYBE); } }
@Override public void post_init(ORBInitInfo info) { try { org.omg.CORBA.Object obj; // Use CDR encapsulations with GIOP 1.0 encoding. Encoding encoding = new Encoding(ENCODING_CDR_ENCAPS.value, (byte) 1, /* GIOP version */ (byte) 0 /* GIOP revision*/); Codec codec = info.codec_factory().create_codec(encoding); // Create and register client interceptor. obj = info.resolve_initial_references("SASCurrent"); SASCurrentImpl sasCurrentImpl = (SASCurrentImpl) obj; SASClientInterceptor clientInterceptor = new SASClientInterceptor(codec); info.add_client_request_interceptor(clientInterceptor); // Create and register server interceptor. SASTargetInterceptor serverInterceptor = new SASTargetInterceptor(codec); info.add_server_request_interceptor(serverInterceptor); // Initialize the SASCurrent implementation. sasCurrentImpl.init(serverInterceptor); } catch (Exception e) { throw IIOPLogger.ROOT_LOGGER.unexpectedException(e); } } }
@Override public void receive_exception(ClientRequestInfo ri) { try { ServiceContext sc = ri.get_reply_service_context(sasContextId); Any msg = codec.decode_value(sc.context_data, SASContextBodyHelper.type()); SASContextBody contextBody = SASContextBodyHelper.extract(msg); // At this point contextBody may contain either a CompleteEstablishContext message or a ContextError message. // Neither message requires any treatment. We decoded the context body just to check that it contains // a well-formed message. IIOPLogger.ROOT_LOGGER.tracef("receive_exception: got SAS reply, type %d", contextBody.discriminator()); } catch (BAD_PARAM e) { // no service context with sasContextId: do nothing. } catch (FormatMismatch e) { throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0, CompletionStatus.COMPLETED_MAYBE); } catch (TypeMismatch e) { throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0, CompletionStatus.COMPLETED_MAYBE); } }
@Override public void post_init(ORBInitInfo info) { try { org.omg.CORBA.Object obj; // Use CDR encapsulations with GIOP 1.0 encoding. Encoding encoding = new Encoding(ENCODING_CDR_ENCAPS.value, (byte) 1, /* GIOP version */ (byte) 0 /* GIOP revision*/); Codec codec = info.codec_factory().create_codec(encoding); // Create and register client interceptor. obj = info.resolve_initial_references("SASCurrent"); SASCurrentImpl sasCurrentImpl = (SASCurrentImpl) obj; ElytronSASClientInterceptor clientInterceptor = new ElytronSASClientInterceptor(codec); info.add_client_request_interceptor(clientInterceptor); // Create and register server interceptor. SASTargetInterceptor serverInterceptor = new SASTargetInterceptor(codec); info.add_server_request_interceptor(serverInterceptor); // Initialize the SASCurrent implementation. sasCurrentImpl.init(serverInterceptor); } catch (Exception e) { throw IIOPLogger.ROOT_LOGGER.unexpectedException(e); } } }
@Override public void receive_reply(ClientRequestInfo ri) { try { ServiceContext sc = ri.get_reply_service_context(SAS_CONTEXT_ID); Any msg = codec.decode_value(sc.context_data, SASContextBodyHelper.type()); SASContextBody contextBody = SASContextBodyHelper.extract(msg); // At this point contextBody should contain a CompleteEstablishContext message, which does not require any // treatment. ContextError messages should arrive via receive_exception(). IIOPLogger.ROOT_LOGGER.tracef("receive_reply: got SAS reply, type %d", contextBody.discriminator()); if (contextBody.discriminator() == MTContextError.value) { // should not happen. throw IIOPLogger.ROOT_LOGGER.unexpectedContextErrorInSASReply(0, CompletionStatus.COMPLETED_YES); } } catch (BAD_PARAM e) { // no service context with sasContextId: do nothing } catch (FormatMismatch | TypeMismatch e) { throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0, CompletionStatus.COMPLETED_YES); } }
Encoding encoding = new Encoding(ENCODING_CDR_ENCAPS.value, (byte) 1, /* GIOP version */ (byte) 0 /* GIOP revision*/); Codec codec = info.codec_factory().create_codec(encoding);
@Override public void receive_reply(ClientRequestInfo ri) { try { ServiceContext sc = ri.get_reply_service_context(sasContextId); Any msg = codec.decode_value(sc.context_data, SASContextBodyHelper.type()); SASContextBody contextBody = SASContextBodyHelper.extract(msg); // At this point contextBody should contain a CompleteEstablishContext message, which does not require any // treatment. ContextError messages should arrive via receive_exception(). IIOPLogger.ROOT_LOGGER.tracef("receive_reply: got SAS reply, type %d", contextBody.discriminator()); if (contextBody.discriminator() == MTContextError.value) { // should not happen. throw IIOPLogger.ROOT_LOGGER.unexpectedContextErrorInSASReply(0, CompletionStatus.COMPLETED_YES); } } catch (BAD_PARAM e) { // no service context with sasContextId: do nothing } catch (FormatMismatch e) { throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0, CompletionStatus.COMPLETED_YES); } catch (TypeMismatch e) { throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0, CompletionStatus.COMPLETED_YES); } }
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); } }
@Override public void receive_reply(ClientRequestInfo ri) { try { ServiceContext sc = ri.get_reply_service_context(sasContextId); Any msg = codec.decode_value(sc.context_data, SASContextBodyHelper.type()); SASContextBody contextBody = SASContextBodyHelper.extract(msg); // At this point contextBody should contain a CompleteEstablishContext message, which does not require any // treatment. ContextError messages should arrive via receive_exception(). IIOPLogger.ROOT_LOGGER.tracef("receive_reply: got SAS reply, type %d", contextBody.discriminator()); if (contextBody.discriminator() == MTContextError.value) { // should not happen. throw IIOPLogger.ROOT_LOGGER.unexpectedContextErrorInSASReply(0, CompletionStatus.COMPLETED_YES); } } catch (BAD_PARAM e) { // no service context with sasContextId: do nothing. } catch (FormatMismatch e) { throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0,CompletionStatus.COMPLETED_YES); } catch (TypeMismatch e) { throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0,CompletionStatus.COMPLETED_YES); } }