org.openorb.orb.csiv2
Class ASN1Utils
java.lang.Object
|
+--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 |
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.
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".
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:
| Offset | Meaning | Value |
| 0 | token id | 0x04 |
| 1 | token id | 0x01 |
| 2 | oid length | hi-byte (len/0xFF) |
| 3 | oid length | lo-byte (len%0xFF) |
| 4 | oid | oid:1.3.6.1.5.6.4 |
| n+0 | name length | len/0xFFFFFF |
| n+1 | name length | (len%0xFFFFFF)/0xFFFF |
| n+2 | name length | ((len%0xFFFFFF)%0xFFFF)/0xFF |
| n+3 | name length | ((len%0xFFFFFF)%0xFFFF)%0xFF |
| n+4 | name | foo |
- 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.
| Offset | Meaning |
| 0 | ASN1 tag |
| 1 | token length (<128) |
| 2 | mechanism oid |
| n | mechanism 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.