Ejemplo n.º 1
0
  private static void printSSLTaggedComponent(TaggedComponent taggedComponent, PrintWriter out) {
    org.omg.SSLIOP.SSL ssl = null;
    if (taggedComponent.tag == 20) {
      CDRInputStream in = new CDRInputStream(taggedComponent.component_data);
      try {
        in.openEncapsulatedArray();
        ssl = org.omg.SSLIOP.SSLHelper.read(in);
      } catch (Exception ex) {
        return;
      }
      int ssl_port = ssl.port;
      if (ssl_port < 0) {
        ssl_port += 65536;
      }

      out.print("\t\ttarget_supports\t:\t");
      // dump               ( ssl.target_supports );
      decodeAssociationOption(ssl.target_supports, out);
      out.println();
      out.print("\t\ttarget_requires\t:\t");
      // dump               ( ssl.target_requires );
      decodeAssociationOption(ssl.target_requires, out);
      out.println();
      out.println("\t\tSSL Port\t:\t" + ssl_port);
    }
  }
Ejemplo n.º 2
0
 /**
  * Verifies that the default encoding (UTF-16) works for wstrings in giop 1.1, which uses the
  * length indicator to specify the number of characters rather than bytes and require a two-byte
  * null terminator. Wide characters in 1.1 do not take width bytes
  */
 @Test
 public void testDefaultEncodingWCharGiop1_1() throws Exception {
   byte[] codedText = {
     0,
     0,
     0,
     5, // string length in bytes, not chars
     0x30,
     (byte) (0xDF & 0xff), // Mitsubishi, in Katakana
     0x30,
     (byte) (0xC4 & 0xff),
     0x30,
     (byte) (0xFA & 0xff),
     0x30,
     (byte) (0xB7 & 0xff),
     0,
     0, // two-byte null terminator
     0x5,
     (byte) (0xD1 & 0xff), // Hebrew letter beis
   };
   CDRInputStream stream = new CDRInputStream(orb, codedText);
   stream.setGIOPMinor(1);
   assertEquals("wstring value", "\u30DF\u30C4\u30FA\u30B7", stream.read_wstring());
   assertEquals("wchar 1", '\u05D1', stream.read_wchar());
   stream.close();
 }
Ejemplo n.º 3
0
  /**
   * Test that jacorb handles some self-constructed broken typecodes well. The constructed typecode
   * is in principal recursive, but not flagged as such.
   */
  public void testBrokenRecursiveTypecode() {
    Any innerAny = orb.create_any();
    innerAny.insert_long(4711);

    StructMember[] members = {new StructMember("myAny", innerAny.type(), null)};

    TypeCode innerTc =
        orb.create_struct_tc(
            "IDL:Anonymous:1.0", // repository ID
            "Anonymous", // Struct name
            members);

    TypeCode outerTc =
        orb.create_struct_tc(
            "IDL:Anonymous:1.0", // repository ID
            "Anonymous", // Struct name
            new StructMember[] {new StructMember("foo", innerTc, null)});

    org.jacorb.orb.CDROutputStream out = new org.jacorb.orb.CDROutputStream(orb);
    out.write_TypeCode(outerTc);
    org.jacorb.orb.CDRInputStream in = new org.jacorb.orb.CDRInputStream(orb, out.getBufferCopy());

    out = new org.jacorb.orb.CDROutputStream(orb);

    // need to write out typecode, to check it's consistency completely
    out.write_TypeCode(in.read_TypeCode());
  }
Ejemplo n.º 4
0
 /** Decodes a CDR encapsulation of a UtcT. */
 public static UtcT fromCDR(byte[] buffer) {
   final CDRInputStream in = new CDRInputStream(buffer);
   try {
     in.openEncapsulatedArray();
     return UtcTHelper.read(in);
   } finally {
     in.close();
   }
 }
Ejemplo n.º 5
0
  private static void printJavaCodebaseComponent(TaggedComponent taggedComponent, PrintWriter out) {
    final CDRInputStream in = new CDRInputStream(taggedComponent.component_data);

    try {
      in.openEncapsulatedArray();
      String codebase = in.read_string();

      out.println("\t\tCodebase: " + codebase);
    } finally {
      in.close();
    }
  }
Ejemplo n.º 6
0
 /** Verifies that the UTF-8 encoding works for strings in giop 1.1. */
 @Test
 public void testUTF8EncodingCharGiop1_1() throws Exception {
   byte[] codedText = {
     0, 0, 0, 5, // string length in bytes, including null pointer
     'a', 's', 'd', 'f', 0, // one-byte null terminator
     'x'
   };
   CDRInputStream stream = new CDRInputStream(orb, codedText);
   selectCodeSets(stream, "UTF8", "UTF8");
   stream.setGIOPMinor(1);
   assertEquals("sstring value", "asdf", stream.read_string());
   assertEquals("char 1", 'x', stream.read_char());
   stream.close();
 }
Ejemplo n.º 7
0
  private static void printTagGroupTaggedComponent(
      TaggedComponent taggedComponent, PrintWriter out) {
    final CDRInputStream is =
        new CDRInputStream((org.omg.CORBA.ORB) null, taggedComponent.component_data);

    is.openEncapsulatedArray();
    TagGroupTaggedComponent tagGroup = TagGroupTaggedComponentHelper.read(is);
    is.close();

    out.println(
        "\t\tVersion: " + tagGroup.group_version.major + ":" + tagGroup.group_version.minor);
    out.println("\t\tDomain: " + tagGroup.group_domain_id);
    out.println("\t\tObjectGroupID: " + tagGroup.object_group_id);
    out.println("\t\tObject Version: " + tagGroup.object_group_ref_version);
  }
Ejemplo n.º 8
0
 @Test
 public void testFailOnNullEncodedString() throws Exception {
   byte[] codedText = {0, 0, 0, 0};
   CDRInputStream stream = new CDRInputStream(orb, codedText);
   try {
     stream.read_string();
     fail("Null encoded string should have failed with an exception");
   } catch (MARSHAL e) {
     assertNotNull(e.getMessage());
     assertTrue(
         "Not a MARSHALL exception: " + e.getMessage(),
         e.getMessage().matches("^.*invalid string size: 0.*$"));
   } finally {
     stream.close();
   }
 }
Ejemplo n.º 9
0
  public Any decode(byte[] data) throws FormatMismatch {
    final CDRInputStream in = new CDRInputStream(orb, data);

    try {
      in.setGIOPMinor(giopMinor);

      in.openEncapsulatedArray();
      Any result = in.read_any();

      // not necessary, since stream is never used again
      // in.closeEncapsulation();

      return result;
    } finally {
      in.close();
    }
  }
Ejemplo n.º 10
0
  private static void printOrbTypeComponent(TaggedComponent taggedComponent, PrintWriter out) {
    final CDRInputStream is = new CDRInputStream(taggedComponent.component_data);

    try {
      is.openEncapsulatedArray();
      int type = is.read_long();

      out.print("\t\tType: " + type);
      if (type == ORBConstants.JACORB_ORB_ID) {
        out.println(" (JacORB)");
      } else {
        out.println(" (Foreign)");
      }
    } finally {
      is.close();
    }
  }
Ejemplo n.º 11
0
  protected TypeCode doReadTypeCodeInternal(
      CDRInputStream in,
      Map recursiveTCMap,
      Map repeatedTCMap,
      Integer startPosition,
      int kind,
      String repositoryID) {
    final String name = validateName(in.read_string());
    final int member_count = in.read_long();

    StructMember[] members = new StructMember[member_count];
    for (int i = 0; i < member_count; i++) {
      members[i] =
          new StructMember(in.read_string(), in.read_TypeCode(recursiveTCMap, repeatedTCMap), null);
    }
    return orb.create_exception_tc(repositoryID, name, members, false);
  }
Ejemplo n.º 12
0
  public Any decode_value(byte[] data, TypeCode tc) throws FormatMismatch, TypeMismatch {
    final CDRInputStream in = new CDRInputStream(orb, data);

    try {
      in.setGIOPMinor(giopMinor);

      in.openEncapsulatedArray();
      Any result = orb.create_any();
      result.read_value(in, tc);

      // not necessary, since stream is never used again
      // in.closeEncasupaltion();

      return result;
    } finally {
      in.close();
    }
  }
Ejemplo n.º 13
0
  /**
   * Verifies that the UTF-8 works for wchar, wchar arrays, and wstrings. Reading the wstring forces
   * alignment of the 4-byte length. Note that byte-ordering is fixed by the encoding.
   */
  @Test
  public void testUTF8EncodingWChar() throws Exception {
    byte[] codedText = {
      1,
      'x', // Latin-l lowercase x
      2,
      (byte) (0xD7 & 0xff),
      (byte) (0x90 & 0xff), // Hebrew letter aleph
      3,
      (byte) (0xE3 & 0xff),
      (byte) (0x81 & 0xff),
      (byte) (0x91 & 0xff), // Hiragana syllable ha
      3,
      (byte) (0xE3 & 0xff),
      (byte) (0x81 & 0xff),
      (byte) (0xB4 & 0xff), // Hiragana syllable pi
      2,
      (byte) (0xD7 & 0xff),
      (byte) (0x91 & 0xff), // Hebrew letter beis
      2,
      (byte) (0xD7 & 0xff),
      (byte) (0x92 & 0xff), // Hebrew letter gimmel
      2,
      (byte) (0xD7 & 0xff),
      (byte) (0x93 & 0xff), // Hebrew letter dalet
      45,
      73, // bytes ignored by 'long' alignment
      0,
      0,
      0,
      12, // string length in bytes, not chars
      (byte) (0xE3 & 0xff),
      (byte) (0x83 & 0xff),
      (byte) (0x9F & 0xff), // Mitsubishi, in Katakana
      (byte) (0xE3 & 0xff),
      (byte) (0x83 & 0xff),
      (byte) (0x84 & 0xff),
      (byte) (0xE3 & 0xff),
      (byte) (0x83 & 0xff),
      (byte) (0xBA & 0xff),
      (byte) (0xE3 & 0xff),
      (byte) (0x82 & 0xff),
      (byte) (0xB7 & 0xff),
    };
    CDRInputStream stream = new CDRInputStream(orb, codedText);
    selectCodeSets(stream, "ISO8859_1", "UTF8");
    assertEquals("wchar 1", 'x', stream.read_wchar());
    assertEquals("wchar 2", '\u05D0', stream.read_wchar());
    assertEquals("wchar 3", '\u3051', stream.read_wchar());
    assertEquals("wchar 4", '\u3074', stream.read_wchar());

    char[] buffer = new char[4];
    buffer[0] = '\u05D0';
    stream.read_wchar_array(buffer, 1, 3);
    assertEquals("wchar array", "\u05D0\u05D1\u05D2\u05D3", new String(buffer));
    assertEquals("wstring value", "\u30DF\u30C4\u30FA\u30B7", stream.read_wstring());
    stream.close();
  }
Ejemplo n.º 14
0
  private static void printCodeSetComponent(TaggedComponent taggedComponent, PrintWriter out) {
    final CDRInputStream is = new CDRInputStream(taggedComponent.component_data);

    try {
      is.openEncapsulatedArray();

      org.omg.CONV_FRAME.CodeSetComponentInfo codeSet = CodeSetComponentInfoHelper.read(is);

      if (codeSet != null) {
        out.println(
            "\t\tForChar native code set Id: "
                + CodeSet.csName(codeSet.ForCharData.native_code_set));
        out.print("\t\tChar Conversion Code Sets: ");
        for (int ji = 0; ji < codeSet.ForCharData.conversion_code_sets.length; ji++) {
          out.println(CodeSet.csName(codeSet.ForCharData.conversion_code_sets[ji]));

          if (ji < (codeSet.ForCharData.conversion_code_sets.length - 1)) {
            out.print(", ");
          }
        }
        if (codeSet.ForCharData.conversion_code_sets.length == 0) {
          out.print("\n");
        }

        out.println(
            "\t\tForWChar native code set Id: "
                + CodeSet.csName(codeSet.ForWcharData.native_code_set));
        out.print("\t\tWChar Conversion Code Sets: ");
        for (int ji = 0; ji < codeSet.ForWcharData.conversion_code_sets.length; ji++) {
          out.println(CodeSet.csName(codeSet.ForWcharData.conversion_code_sets[ji]));

          if (ji < (codeSet.ForWcharData.conversion_code_sets.length - 1)) {
            out.print(", ");
          }
        }
        if (codeSet.ForCharData.conversion_code_sets.length == 0) {
          out.print("\n");
        }
      }
    } finally {
      is.close();
    }
  }
  /**
   * entry method to the TypeCode reader logic
   *
   * @param logger used to log informational/debug information
   * @param in the InputStream from which should be read from
   * @param recursiveTCMap Map that should be used to store the buffer positions of not completely
   *     read in TypeCodes
   * @param repeatedTCMap Map that should be used to store the buffer positions of completely read
   *     in TypeCodes
   */
  public TypeCode readTypeCode(
      Logger logger, CDRInputStream in, Map recursiveTCMap, Map repeatedTCMap) {
    in.mark(0);

    final int kind = in.read_long();
    final int start_pos = in.get_pos() - 4;

    try {
      in.reset();
    } catch (IOException e) {
      assert false;
      throw new RuntimeException("should not happen");
    }

    if (logger.isDebugEnabled()) {
      logger.debug(
          in.getIndentString() + "read TypeCode kind " + kind + " at startposition " + start_pos);
    }

    final TypeCode result = doReadTypeCode(in, recursiveTCMap, repeatedTCMap, kind);

    if (logger.isDebugEnabled()) {
      logger.debug(
          in.getIndentString()
              + "return "
              + result
              + " ("
              + result.getClass().getName()
              + "@"
              + System.identityHashCode(result)
              + ")");
    }

    return result;
  }
Ejemplo n.º 16
0
  private static void printTlsSecTrans(byte[] tagData, PrintWriter out) {
    CDRInputStream in = new CDRInputStream(tagData);

    try {
      in.openEncapsulatedArray();
      TLS_SEC_TRANS tls = TLS_SEC_TRANSHelper.read(in);
      out.println("\t\t\tTLS SEC TRANS target requires: " + tls.target_requires);
      out.println("\t\t\tTLS SEC TRANS target supports: " + tls.target_supports);

      for (int i = 0; i < tls.addresses.length; i++) {
        int ssl_port = tls.addresses[i].port;
        if (ssl_port < 0) {
          ssl_port += 65536;
        }
        out.println("\t\t\tTLS SEC TRANS address: " + tls.addresses[i].host_name + ":" + ssl_port);
      }
    } catch (Exception ex) {
      out.print("\t\t\tTLS SEC TRANS: ");
      dumpHex(tagData, out);
      out.println();
    }
  }
Ejemplo n.º 17
0
  private static void printAlternateAddress(
      ORB orb, TaggedComponent taggedComponent, PrintWriter out) {
    final CDRInputStream is = new CDRInputStream(taggedComponent.component_data);

    try {
      is.openEncapsulatedArray();
      String hostname = is.read_string();
      short port = is.read_ushort();

      IIOPAddress result = new IIOPAddress(hostname, port);
      try {
        result.configure(((org.jacorb.orb.ORB) orb).getConfiguration());
      } catch (ConfigurationException ce) {
        ((org.jacorb.orb.ORB) orb)
            .getConfiguration()
            .getLogger("PrintIOR")
            .warn("ConfigurationException", ce);
      }

      out.println("\t\tAddress: " + result.toString());
    } finally {
      is.close();
    }
  }
Ejemplo n.º 18
0
  /**
   * Verifies that the default encoding (UTF-16) works for wchar, wchar arrays, and wstrings with no
   * byte-order-marker. Reading the wstring forces alignment of the 4-byte length.
   */
  @Test
  public void testDefaultEncodingWChar() throws Exception {
    byte[] codedText = {
      2,
      0x5,
      (byte) (0xD0 & 0xff), // Hebrew letter aleph
      2,
      0x30,
      0x51, // Hiragana syllable ha
      2,
      0x30,
      0x74, // Hiragana syllable pi
      2, // Hebrew letter beis: length byte
      (byte) (0xFE & 0xff), //   Big-endian indicator
      (byte) (0xFF & 0xff),
      0x5,
      (byte) (0xD1 & 0xff), //   UTF16 encoding (big-endian)
      2, // Hebrew letter gimmel: length byte
      (byte) (0xFF & 0xff), //   Little-endian indicator
      (byte) (0xFE & 0xff),
      (byte) (0xD2 & 0xff),
      0x5, //   UTF16 encoding (little-endian)
      2,
      0x5,
      (byte) (0xD3 & 0xff), // Hebrew letter dalet
      45,
      23, // bytes ignored by 'long' alignment
      0,
      0,
      0,
      8, // string length in bytes, not chars
      0x30,
      (byte) (0xDF & 0xff), // Mitsubishi, in Katakana
      0x30,
      (byte) (0xC4 & 0xff),
      0x30,
      (byte) (0xFA & 0xff),
      0x30,
      (byte) (0xB7 & 0xff),
    };
    CDRInputStream stream = new CDRInputStream(orb, codedText);
    assertEquals("wchar 1", '\u05D0', stream.read_wchar());
    assertEquals("wchar 2", '\u3051', stream.read_wchar());
    assertEquals("wchar 3", '\u3074', stream.read_wchar());

    char[] buffer = new char[4];
    buffer[0] = '\u05D0';
    stream.read_wchar_array(buffer, 1, 3);
    assertEquals("wchar array", "\u05D0\u05D1\u05D2\u05D3", new String(buffer));
    assertEquals("wstring value", "\u30DF\u30C4\u30FA\u30B7", stream.read_wstring());
    stream.close();
  }
Ejemplo n.º 19
0
  /**
   * Verifies that the default encoding (ISO8859_1) works for char, char arrays, and strings.
   * Reading the string forces alignment of the 4-byte length, and ignores any null terminator.
   */
  @Test
  public void testDefaultEncodingChar() throws Exception {
    byte[] codedText = {'a', 's', 'd', 'f', 'x', 'y', 'z', '*', 0, 0, 0, 5, 'C', 'A', 'F', 'E', 0};
    CDRInputStream stream = new CDRInputStream(orb, codedText);
    assertEquals("char 1", 'a', stream.read_char());
    assertEquals("char 2", 's', stream.read_char());
    assertEquals("char 3", 'd', stream.read_char());
    assertEquals("char 4", 'f', stream.read_char());

    char[] buffer = new char[4];
    buffer[0] = 'w';
    stream.read_char_array(buffer, 1, 3);
    assertEquals("char array", "wxyz", new String(buffer));
    assertEquals("string value", "CAFE", stream.read_string());
    stream.close();
  }
Ejemplo n.º 20
0
  /**
   * Run method. Inherited from runnable, this method is used to stay listening to the socket for
   * new messages.
   */
  @Override
  public void run() {
    // create incomplete table if doesn't exist
    if (incompleteMessages == null) {
      incompleteMessages = new HashMap<String, FragmentedMessage>();
    }

    // allocates a buffer
    byte[] buffer = new byte[packetMaxSize];

    while (connected) {
      try {
        // if the number of messages in incomplete table is greater than a
        // specified threshold we inspect this table to clear incomplete packets
        // collections.
        if (incompleteMessages.size() > incompleteMessagesThreshold) {
          dropIncompleteMessages();
        }

        // creates a new datagram to be read
        DatagramPacket packet = new DatagramPacket(buffer, buffer.length);

        try {
          // wait for the datagram
          socket.receive(packet);
        } catch (SocketTimeoutException ste) {
          continue;
        } catch (InterruptedIOException e) {
          throw new org.omg.CORBA.TRANSIENT("Interrupted I/O: " + e);
        } catch (IOException se) {
          throw to_COMM_FAILURE(se);
        }
        // the packet was received successfully.
        CDRInputStream in = new CDRInputStream(configuration.getORB(), packet.getData());

        // Read the header
        //
        // Manually read in the stream rather than using the generated
        // PacketHeader_1_0Helper
        // as we may need to alter endian half way through.
        org.omg.MIOP.PacketHeader_1_0 header = new org.omg.MIOP.PacketHeader_1_0();
        header.magic = new char[4];
        in.read_char_array(header.magic, 0, 4);

        // Verify the message is MIOP
        if (!MulticastUtil.matchMIOPMagic(header.magic)) {
          // if it isn't a MIOP message I can ignore it
          continue;
        }

        // We know it is MIOP from now on.
        header.hdr_version = in.read_octet();
        header.flags = in.read_octet();

        // Set endian for the stream
        in.setLittleEndian((0x01 & header.flags) != 0);

        header.packet_length = in.read_ushort();
        header.packet_number = in.read_ulong();
        header.number_of_packets = in.read_ulong();
        header.Id = org.omg.MIOP.UniqueIdHelper.read(in);

        int pos = in.get_pos();
        // difference to next MulticastUtil.BOUNDARY (which is an 8 byte boundary)
        int header_padding = MulticastUtil.BOUNDARY - (pos % MulticastUtil.BOUNDARY);
        header_padding = (header_padding == MulticastUtil.BOUNDARY) ? 0 : header_padding;

        // skip header_padding bytes anyway, because if no body is
        // present, nobody will try to read it
        in.skip(header_padding);

        // read the GIOP data
        byte data[] = new byte[header.packet_length];
        if (in.available() < data.length) {
          throw new MARSHAL(
              "Impossible length in MIOP header. Header denotes length of "
                  + header.packet_length
                  + " but only "
                  + in.available()
                  + " is available.");
        }
        in.read_octet_array(data, 0, header.packet_length);

        String messageId = new String(header.Id);
        FragmentedMessage message = incompleteMessages.get(messageId);

        // verify if it's the first message to arrive
        if (message == null) {
          // If this is the first fragment of the message create a  fragmented message
          message = new FragmentedMessage();
          try {
            message.configure(configuration);
          } catch (ConfigurationException e) {
            logger.error("couldn't create a Fragmented message", e);
            throw new IllegalArgumentException("wrong configuration: " + e);
          }
          incompleteMessages.put(messageId, message);
        }

        if (logger.isDebugEnabled()) {
          logger.debug(
              "Received message number "
                  + (header.packet_number + 1)
                  + " out of "
                  + header.number_of_packets
                  + " and adding fragment of size "
                  + data.length);
        }
        message.addFragment(header, data);

        // verify if it's the last message to arrive
        if (message.isComplete()) {
          synchronized (this) {
            incompleteMessages.remove(messageId);
            fullMessages.addLast(message.buildMessage());
            notifyAll();
          }
        }
      } catch (COMM_FAILURE e) {
        if (logger.isDebugEnabled()) {
          logger.debug("Transport to " + connection_info + ": stream closed " + e.getMessage());
        }
        if (connected) {
          close();
        }
      } catch (SystemException e) {
        if (logger.isWarnEnabled()) {
          logger.warn("ServerMIOPConnection caught exception.", e);
        }
      } catch (Throwable e) {
        if (logger.isErrorEnabled()) {
          logger.error("ServerMIOPConnection caught exception.", e);
        }
      }
    }
  }
Ejemplo n.º 21
0
  private static void printPolicyComponent(TaggedComponent taggedComponent, PrintWriter out) {
    final CDRInputStream is = new CDRInputStream(taggedComponent.component_data);

    try {
      int val;
      int count = 0;

      is.openEncapsulatedArray();
      int len = is.read_long();

      while (len-- != 0) {
        val = is.read_long();
        out.print("\t\t#" + count++ + ": ");
        is.openEncapsulation();
        switch (val) {
          case PRIORITY_BANDED_CONNECTION_POLICY_TYPE.value:
            {
              long i;
              short low;
              short high;

              out.println("RTCORBA::PRIORITY_BANDED_CONNECTION");
              val = is.read_long();
              for (i = 0; i < val; i++) {
                low = is.read_short();
                high = is.read_short();
                out.println("\t\t\tBand " + i + ": " + low + "-" + high);
              }
              break;
            }
          case PRIORITY_MODEL_POLICY_TYPE.value:
            {
              out.print("RTCORBA::PRIORITY_MODEL");
              val = is.read_long();
              switch (val) {
                case PriorityModel._CLIENT_PROPAGATED:
                  {
                    out.print(" (CLIENT_PROPAGATED, ");
                    break;
                  }
                case PriorityModel._SERVER_DECLARED:
                  {
                    out.print(" (SERVER_DECLARED, ");
                    break;
                  }
                default:
                  {
                    out.print(" (Unknown, ");
                    break;
                  }
              }
              short prio = is.read_short();
              out.println(prio + ")");
              break;
            }
          default:
            {
              out.println("Unknown (" + val + ")");
              break;
            }
        }
        is.closeEncapsulation();
      }

    } finally {
      is.close();
    }
  }
Ejemplo n.º 22
0
 private void selectCodeSets(CDRInputStream stream, String charCodeSet, String wideCharCodeSet) {
   stream.setCodeSet(CodeSet.getCodeSet(charCodeSet), CodeSet.getCodeSet(wideCharCodeSet));
 }
Ejemplo n.º 23
0
  private static void printCSIMechComponent(TaggedComponent taggedComponent, PrintWriter out) {
    final CDRInputStream is = new CDRInputStream(taggedComponent.component_data);

    try {
      is.openEncapsulatedArray();
      CompoundSecMechList csmList = CompoundSecMechListHelper.read(is);

      if (csmList != null) {
        out.println("\t\tis stateful: " + csmList.stateful);
        for (int i = 0; i < csmList.mechanism_list.length; i++) {
          out.println("\t\tCompoundSecMech #" + i);
          out.println("\t\t\ttarget_requires: " + csmList.mechanism_list[i].target_requires);
          out.print("\t\t\ttransport mechanism tag: ");
          switch (csmList.mechanism_list[i].transport_mech.tag) {
            case TAG_TLS_SEC_TRANS.value:
              {
                out.println("TAG_TLS_SEC_TRANS");
                printTlsSecTrans(csmList.mechanism_list[i].transport_mech.component_data, out);
                break;
              }
            case TAG_NULL_TAG.value:
              {
                out.println("TAG_NULL_TAG");
                break;
              }
            default:
              {
                out.println("Unknown tag : " + csmList.mechanism_list[i].transport_mech.tag);
              }
          }
          out.println(
              "\t\t\tAS_ContextSec target_supports: "
                  + csmList.mechanism_list[i].as_context_mech.target_supports);
          out.println(
              "\t\t\tAS_ContextSec target_requires: "
                  + csmList.mechanism_list[i].as_context_mech.target_requires);
          out.print("\t\t\tAS_ContextSec mech: ");
          dumpHex(csmList.mechanism_list[i].as_context_mech.client_authentication_mech, out);
          out.println();
          out.print("\t\t\tAS_ContextSec target_name: ");
          printNTExportedName(csmList.mechanism_list[i].as_context_mech.target_name, out);
          out.println(
              "\t\t\tSAS_ContextSec target_supports: "
                  + csmList.mechanism_list[i].sas_context_mech.target_supports);
          out.println(
              "\t\t\tSAS_ContextSec target_requires: "
                  + csmList.mechanism_list[i].sas_context_mech.target_requires);

          for (int j = 0;
              j < csmList.mechanism_list[i].sas_context_mech.supported_naming_mechanisms.length;
              j++) {
            out.print("\t\t\tSAS_ContextSec Naming mech: ");
            dumpHex(csmList.mechanism_list[i].sas_context_mech.supported_naming_mechanisms[j], out);
            out.println();
          }
          out.println(
              "\t\t\tSAS_ContextSec Naming types: "
                  + csmList.mechanism_list[i].sas_context_mech.supported_identity_types);
          out.println();
        }
      }
    } finally {
      is.close();
    }
  }