iiop-openjdk/src/main/java/org/wildfly/iiop/openjdk/csiv2/CSIv2Util.java
public static byte[] createGSSExportedName(byte[] oid, byte[] name) {
        int olen = oid.length;
        int nlen = name.length;

        // size according to spec.
        int size = 2 + 2 + olen + 4 + nlen;

        // allocate space for the exported name.
        byte[] buf = new byte[size];
        // index.
        int i = 0;

        // standard header.
        buf[i++] = 0x04;
        buf[i++] = 0x01;

        // encode oid length.
        buf[i++] = (byte) (olen & 0xFF00);
        buf[i++] = (byte) (olen & 0x00FF);

        // copy the oid in the exported name buffer.
        System.arraycopy(oid, 0, buf, i, olen);
        i += olen;

        // encode the name length in the exported buffer.
        buf[i++] = (byte) (nlen & 0xFF000000);
        buf[i++] = (byte) (nlen & 0x00FF0000);
        buf[i++] = (byte) (nlen & 0x0000FF00);
        buf[i++] = (byte) (nlen & 0x000000FF);

        // finally, copy the name bytes.
        System.arraycopy(name, 0, buf, i, nlen);

        return buf;
    }
public static byte[] createGSSExportedName(byte[] oid, byte[] name) {
        int olen = oid.length;
        int nlen = name.length;

        // size according to spec.
        int size = 2 + 2 + olen + 4 + nlen;

        // allocate space for the exported name.
        byte[] buf = new byte[size];
        // index.
        int i = 0;

        // standard header.
        buf[i++] = 0x04;
        buf[i++] = 0x01;

        // encode oid length.
        buf[i++] = (byte) (olen & 0xFF00);
        buf[i++] = (byte) (olen & 0x00FF);

        // copy the oid in the exported name buffer.
        System.arraycopy(oid, 0, buf, i, olen);
        i += olen;

        // encode the name length in the exported buffer.
        buf[i++] = (byte) (nlen & 0xFF000000);
        buf[i++] = (byte) (nlen & 0x00FF0000);
        buf[i++] = (byte) (nlen & 0x0000FF00);
        buf[i++] = (byte) (nlen & 0x000000FF);

        // finally, copy the name bytes.
        System.arraycopy(name, 0, buf, i, nlen);

        return buf;
    }
public static byte [ ] createGSSExportedName ( byte [ ] oid , byte [ ] name ) { int olen = oid . length ; int nlen = name . length ; // size according to spec. int size = 2 + 2 + olen + 4 + nlen ; // allocate space for the exported name. byte [ ] buf = new byte [ size ] ; // index. int i = 0 ; // standard header. buf [ i ++ ] = 0x04 ; buf [ i ++ ] = 0x01 ; // encode oid length. buf [ i ++ ] = ( byte ) ( olen & 0xFF00 ) ; buf [ i ++ ] = ( byte ) ( olen & 0x00FF ) ; // copy the oid in the exported name buffer. System . arraycopy ( oid , 0 , buf , i , olen ) ; i += olen ; // encode the name length in the exported buffer. buf [ i ++ ] = ( byte ) ( nlen & 0xFF000000 ) ; buf [ i ++ ] = ( byte ) ( nlen & 0x00FF0000 ) ; buf [ i ++ ] = ( byte ) ( nlen & 0x0000FF00 ) ; buf [ i ++ ] = ( byte ) ( nlen & 0x000000FF ) ; // finally, copy the name bytes. System . arraycopy ( name , 0 , buf , i , nlen ) ; return buf ; }
<p/>
Generate an exported name as specified in [RFC 2743], section 3.2 copied below:
<p/>
3.2: Mechanism-Independent Exported Name Object Format
<p/>
This section specifies a mechanism-independent level of encapsulating representation for names exported via the
GSS_Export_name() call, including an object identifier representing the exporting mechanism. The format of names
encapsulated via this representation shall be defined within individual mechanism drafts.  The Object Identifier
value to indicate names of this type is defined in Section 4.7 of this document.
<p/>
No name type OID is included in this mechanism-independent level of format definition, since (depending on
individual mechanism specifications) the enclosed name may be implicitly typed or may be explicitly typed using
a means other than OID encoding.
<p/>
The bytes within MECH_OID_LEN and NAME_LEN elements are represented most significant byte first (equivalently,
in IP network byte order).
<p/>
Length          Name            Description
<p/>
2               TOK_ID          Token Identifier
For exported name objects, this must be hex 04 01.
2               MECH_OID_LEN    Length of the Mechanism OID
MECH_OID_LEN    MECH_OID        Mechanism OID, in DER
4               NAME_LEN        Length of name
NAME_LEN        NAME            Exported name; format defined in applicable mechanism draft.
<p/>
A concrete example of the contents of an exported name object, derived from the Kerberos Version 5 mechanism, is
as follows:
<p/>
04 01 00 0B 06 09 2A 86 48 86 F7 12 01 02 02 hx xx xx xl pp qq ... zz
<p/>
...

@param oid  the DER encoded OID.
@param name the name to be converted to {@code GSSExportedName}.
@return a {@code byte[]} representing the exported name.
<p / > Generate an exported name as specified in [ RFC 2743 ] section 3 . 2 copied below : <p / > 3 . 2 : Mechanism - Independent Exported Name Object Format <p / > This section specifies a mechanism - independent level of encapsulating representation for names exported via the GSS_Export_name () call including an object identifier representing the exporting mechanism . The format of names encapsulated via this representation shall be defined within individual mechanism drafts . The Object Identifier value to indicate names of this type is defined in Section 4 . 7 of this document . <p / > No name type OID is included in this mechanism - independent level of format definition since ( depending on individual mechanism specifications ) the enclosed name may be implicitly typed or may be explicitly typed using a means other than OID encoding . <p / > The bytes within MECH_OID_LEN and NAME_LEN elements are represented most significant byte first ( equivalently in IP network byte order ) . <p / > Length Name Description <p / > 2 TOK_ID Token Identifier For exported name objects this must be hex 04 01 . 2 MECH_OID_LEN Length of the Mechanism OID MECH_OID_LEN MECH_OID Mechanism OID in DER 4 NAME_LEN Length of name NAME_LEN NAME Exported name ; format defined in applicable mechanism draft . <p / > A concrete example of the contents of an exported name object derived from the Kerberos Version 5 mechanism is as follows : <p / > 04 01 00 0B 06 09 2A 86 48 86 F7 12 01 02 02 hx xx xx xl pp qq ... zz <p / > ...