org.apache.geronimo.corba.util
Class Util

java.lang.Object
  extended by org.apache.geronimo.corba.util.Util

public final class Util
extends Object

Various utility functions.

Note: #getORB() and #getCodec() rely on UtilInitializer to initialze the ORB and codec.

See Also:
UtilInitializer

Constructor Summary
Util()
           
 
Method Summary
static String buildScopedUserName(String user, String domain)
           
static String byteToString(byte[] data)
           
static String[] createCorbaIds(Class type)
           
static String decodeGeneralName(byte[] name)
           
static String decodeGSSExportName(byte[] name_tok)
          This function reads a name from a byte array which was created by the gssExportName() method.
static boolean decodeGSSUPToken(Codec codec, byte[] token_arr, org.omg.GSSUP.InitialContextToken gssup_tok)
          Decode an GSSUP InitialContextToken from a GSSToken.
static String decodeOID(byte[] oid)
           
static DERObjectIdentifier decodeOIDDERObjectIdentifier(byte[] oid)
           
static byte[] encodeGeneralName(GeneralName generalName)
           
static byte[] encodeGeneralName(String name)
           
static byte[] encodeGeneralName(X509Name x509Name)
           
static byte[] encodeGSSExportName(String oid, 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 byte[] encodeGSSUPToken(ORB orb, Codec codec, String user, String pwd, String target)
          Encode a mechanism independent initial context token (GSSToken).
static byte[] encodeOID(DERObjectIdentifier oid)
           
static byte[] encodeOID(String oid)
           
static String extractUserNameFromScopedName(byte[] scopedNameBytes)
          See csiv2 spec 16.2.5 par. 63-64.
static String extractUserNameFromScopedName(String scopedUserName)
           
static Codec getCodec()
           
static Object getEJBProxy(org.apache.openejb.ProxyInfo info)
           
static HandleDelegate getHandleDelegate()
           
static ORB getORB()
           
static ORBConfiguration getRegisteredORB(String id)
           
static Map mapMethodToOperation(Class intfClass)
           
static Map mapOperationToMethod(Class intfClass)
           
static Object readObject(Class type, InputStream in)
           
static void registerORB(String id, ORBConfiguration orb)
           
static void setORB(ORB orb)
           
static void throwException(Method method, InputStream in)
           
static void unregisterORB(String id)
           
static void writeObject(Class type, Object object, OutputStream out)
           
static OutputStream writeUserException(Method method, ResponseHandler reply, Exception exception)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

getORB

public static ORB getORB()

registerORB

public static void registerORB(String id,
                               ORBConfiguration orb)

getRegisteredORB

public static ORBConfiguration getRegisteredORB(String id)

unregisterORB

public static void unregisterORB(String id)

setORB

public static void setORB(ORB orb)
                   throws UserException
Throws:
UserException

getCodec

public static Codec getCodec()

getHandleDelegate

public static HandleDelegate getHandleDelegate()
                                        throws NamingException
Throws:
NamingException

getEJBProxy

public static Object getEJBProxy(org.apache.openejb.ProxyInfo info)

encodeOID

public static byte[] encodeOID(String oid)
                        throws IOException
Throws:
IOException

encodeOID

public static byte[] encodeOID(DERObjectIdentifier oid)
                        throws IOException
Throws:
IOException

decodeOID

public static String decodeOID(byte[] oid)
                        throws IOException
Throws:
IOException

decodeOIDDERObjectIdentifier

public static DERObjectIdentifier decodeOIDDERObjectIdentifier(byte[] oid)
                                                        throws IOException
Throws:
IOException

encodeGeneralName

public static byte[] encodeGeneralName(String name)
                                throws IOException
Throws:
IOException

encodeGeneralName

public static byte[] encodeGeneralName(X509Name x509Name)
                                throws IOException
Throws:
IOException

encodeGeneralName

public static byte[] encodeGeneralName(GeneralName generalName)
                                throws IOException
Throws:
IOException

decodeGeneralName

public static String decodeGeneralName(byte[] name)
                                throws IOException
Throws:
IOException

encodeGSSExportName

public static byte[] encodeGSSExportName(String oid,
                                         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.

decodeGSSExportName

public static String decodeGSSExportName(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.

extractUserNameFromScopedName

public static String extractUserNameFromScopedName(byte[] scopedNameBytes)
                                            throws UnsupportedEncodingException
See csiv2 spec 16.2.5 par. 63-64. We extract the username if any and un-escape any escaped \ and @ characters.

Parameters:
scopedNameBytes -
Returns:
Throws:
UnsupportedEncodingException

extractUserNameFromScopedName

public static String extractUserNameFromScopedName(String scopedUserName)

buildScopedUserName

public static String buildScopedUserName(String user,
                                         String domain)

encodeGSSUPToken

public static byte[] encodeGSSUPToken(ORB orb,
                                      Codec codec,
                                      String user,
                                      String pwd,
                                      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(Codec codec,
                                       byte[] token_arr,
                                       org.omg.GSSUP.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.

byteToString

public static String byteToString(byte[] data)

writeObject

public static void writeObject(Class type,
                               Object object,
                               OutputStream out)

readObject

public static Object readObject(Class type,
                                InputStream in)

throwException

public static void throwException(Method method,
                                  InputStream in)
                           throws Throwable
Throws:
Throwable

writeUserException

public static OutputStream writeUserException(Method method,
                                              ResponseHandler reply,
                                              Exception exception)
                                       throws Exception
Throws:
Exception

createCorbaIds

public static String[] createCorbaIds(Class type)

mapMethodToOperation

public static Map mapMethodToOperation(Class intfClass)

mapOperationToMethod

public static Map mapOperationToMethod(Class intfClass)


Copyright © 2003-2007 Apache Software Foundation. All Rights Reserved.