ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(containerClassLoader);
try
{
SkeletonStrategy op = (SkeletonStrategy) methodInvokerMap.get(opName);
if (op == null)
{
logger.debug("Unable to find opname '" + opName + "' valid operations:" + methodInvokerMap.keySet());
throw new BAD_OPERATION(opName);
}
Object id;
try
{
id = ReferenceData.extractObjectId(poaCurrent.get_object_id());
if (traceEnabled && id != null)
logger.trace(" id class is "
+ id.getClass().getName());
}
catch (Exception e)
{
logger.error("Error getting EJBObject id", e);
throw new UnknownException(e);
}
// make java:comp work
ENCFactory.pushContextId(containerName);
org.omg.CORBA_2_3.portable.OutputStream out;
try
{
Object retVal;
if (opName.equals("_get_handle"))
{
javax.ejb.EJBObject obj =
(javax.ejb.EJBObject)javax.rmi.PortableRemoteObject.narrow(_this_object(), javax.ejb.EJBObject.class);
retVal = new HandleImplIIOP(obj);
}
else
{
Transaction tx = null;
if (inboundTxCurrent != null)
tx = inboundTxCurrent.getCurrentTransaction();
SimplePrincipal principal = null;
char[] password = null;
if (sasCurrent != null)
{
byte[] username = sasCurrent.get_incoming_username();
byte[] credential = sasCurrent.get_incoming_password();
String name = new String(username, "UTF-8");
int domainIndex = name.indexOf('@');
if (domainIndex > 0)
name = name.substring(0, domainIndex);
if (name.length() == 0)
{
byte[] incomingName =
sasCurrent.get_incoming_principal_name();
if (incomingName.length > 0)
{
name = new String(incomingName, "UTF-8");
domainIndex = name.indexOf('@');
if (domainIndex > 0)
name = name.substring(0, domainIndex);
principal = new SimplePrincipal(name);
// username==password is a hack until
// we have a real way to establish trust
password = name.toCharArray();
}
}
else
{
principal = new SimplePrincipal(name);
password = new String(credential, "UTF-8").toCharArray();
}
}
Object[] params =
op.readParams((org.omg.CORBA_2_3.portable.InputStream) in);
Invocation inv = new Invocation(id,
op.getMethod(),
params,
tx,
principal, /* identity */
password /* credential */);
inv.setValue(InvocationKey.INVOKER_PROXY_BINDING,
"iiop",
PayloadKey.AS_IS);
inv.setType(InvocationType.REMOTE);
SecurityContext sc = SecurityContextFactory.createSecurityContext("CORBA_REMOTE");
sc.getUtil().createSubjectInfo(principal, password, null);
inv.setSecurityContext(sc);
retVal = mbeanServer.invoke(containerName,
"invoke",
new Object[]{inv},
Invocation.INVOKE_SIGNATURE);
}
out = (org.omg.CORBA_2_3.portable.OutputStream)
handler.createReply();
if (op.isNonVoid())
{
op.writeRetval(out, retVal);
}
}
catch (Exception e)
{
if (traceEnabled)
{
logger.trace("Exception in EJBObject invocation", e);
}
if (e instanceof MBeanException)
{
e = ((MBeanException) e).getTargetException();
}
RmiIdlUtil.rethrowIfCorbaSystemException(e);
out = (org.omg.CORBA_2_3.portable.OutputStream)
handler.createExceptionReply();
op.writeException(out, e);
}
return out;
}
finally
{