org.openorb.orb.csiv2
Class ASN1Utils

java.lang.Object
  extended by org.openorb.orb.csiv2.ASN1Utils

public final class ASN1Utils
extends java.lang.Object

Helper methods to encode and decode various ASN1 constructs.

Author:
Michael Rumpf

Method Summary
static boolean decodeGSSUPToken(org.omg.IOP.Codec codec, byte[] token_arr, InitialContextToken gssup_tok)
          Decode an GSSUP InitialContextToken from a GSSToken.
static java.lang.String decodeObjectIdentifier(byte[] arr)
          Decode an oid from the ASN representation (byte array) into a human readable string format.
static byte[] encodeGSSUPToken(org.omg.CORBA.ORB orb, org.omg.IOP.Codec codec, java.lang.String user, char[] pwd, java.lang.String target)
          Encode a mechanism independent initial context token (GSSToken).
static byte[] encodeObjectIdentifier(java.lang.String oid)
          Encode an oid from a stringified representation into ASN format (byte array).
static byte[] gssExportName(java.lang.String oid, java.lang.String name)
          This method encodes a name as if it was encoded using the GSS-API gss_export_name() function call (see RFC 2743, page 84).
static java.lang.String gssImportName(byte[] name_tok)
          This function reads a name from a byte array which was created by the gssExportName() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encodeObjectIdentifier

public static byte[] encodeObjectIdentifier(java.lang.String oid)
                                     throws java.io.IOException
Encode an oid from a stringified representation into ASN format (byte array).

Parameters:
oid - The stringified object identifier.
Returns:
The OID in ASN1 format.
Throws:
java.io.IOException

decodeObjectIdentifier

public static java.lang.String decodeObjectIdentifier(byte[] arr)
                                               throws java.io.IOException
Decode an oid from the ASN representation (byte array) into a human readable string format.

Parameters:
arr - The byte array containing the oid in ASN1 format.
Returns:
The OID in format "oid:x.y.z".
Throws:
java.io.IOException

gssExportName

public static byte[] gssExportName(java.lang.String oid,
                                   java.lang.String name)
This method encodes a name as if it was encoded using the GSS-API gss_export_name() function call (see RFC 2743, page 84). The oid to indicate names of this format is:
{1(iso), 3(org), 6(dod), 1(internet), 5(security), 6(nametypes), 4(gss-api-exported-name)}
The token has the following format:
OffsetMeaningValue
0token id0x04
1token id0x01
2oid lengthhi-byte (len/0xFF)
3oid lengthlo-byte (len%0xFF)
4oidoid:1.3.6.1.5.6.4
n+0name lengthlen/0xFFFFFF
n+1name length(len%0xFFFFFF)/0xFFFF
n+2name length((len%0xFFFFFF)%0xFFFF)/0xFF
n+3name length((len%0xFFFFFF)%0xFFFF)%0xFF
n+4namefoo

Parameters:
oid - The oid of the mechanism this name is exported from.
name - The name to be exported.
Returns:
The byte array representing the exported name object.

gssImportName

public static java.lang.String gssImportName(byte[] name_tok)
This function reads a name from a byte array which was created by the gssExportName() method.

Parameters:
name_tok - The GSS name token.
Returns:
The name from the GSS name token.

encodeGSSUPToken

public static byte[] encodeGSSUPToken(org.omg.CORBA.ORB orb,
                                      org.omg.IOP.Codec codec,
                                      java.lang.String user,
                                      char[] pwd,
                                      java.lang.String target)
Encode a mechanism independent initial context token (GSSToken). Defined in [IETF RFC 2743] Section 3.1, "Mechanism-Independent token Format" pp. 81-82.
OffsetMeaning
0ASN1 tag
1token length (<128)
2mechanism oid
nmechanism specific token (e.g. GSSUP::InitialContextToken)
Currently only one mechanism specific token is supported: GSS username password (GSSUP::InitialContextToken).

Parameters:
orb - The orb to get an Any from.
codec - The codec to do the encoding of the Any.
user - The username.
pwd - The password of the user.
target - The target name.
Returns:
The byte array of the ASN1 encoded GSSToken.

decodeGSSUPToken

public static boolean decodeGSSUPToken(org.omg.IOP.Codec codec,
                                       byte[] token_arr,
                                       InitialContextToken gssup_tok)
Decode an GSSUP InitialContextToken from a GSSToken.

Parameters:
codec - The codec to do the encoding of the Any.
gssup_tok - The InitialContextToken struct to fill in the decoded values.
Returns:
Return true when decoding was successful, false otherwise.