[omniORB] Authentication; Garbage Collection
Bill Noon
noon at snow.nrcc.cornell.edu
Thu Jul 22 08:00:26 BST 2004
Alex -- I ran into the same problem with authentication a few years ago
and also used Interceptors to insert my authentication key into the
CORBA request. This worked fine until I moved some computers to MacOS
10.3 where I had a problem getting OmniORB's c++ objects to call the
initializing code. This killed my python interface to the
omniInterceptors.
Since Duncan had exposed the omniInterceptors to python, I tried that
route. Below is some simple code to add and get a token from the CORBA
stream.
#!/usr/bin/env python
import thread
from omniORB import CORBA, PortableServer, interceptors, cdrUnmarshal,
cdrMarshal
_UCAN_SECURE = 0x52434301
_tokens = {}
def registerToken(t):
global _tokens
_tokens[thread.get_ident()] = t
def _insertToken(op, srvctx):
u = _tokens.get(thread.get_ident(), None)
if u :
cargo = cdrMarshal(CORBA._tc_string, u)
srvctx.append((_UCAN_SECURE, cargo))
def _retrieveToken(op, contexts):
for k, v in contexts:
if k == _UCAN_SECURE:
u = cdrUnmarshal(CORBA._tc_string, v)
registerToken(u)
break
interceptors.addServerReceiveRequest(_retrieveToken)
interceptors.addClientSendRequest(_insertToken)
def getToken() :
return _tokens.get(thread.get_ident(), ' ')
def setToken(t) :
registerToken(t)
Just import this module before initializing the ORB.
In my case, I also needed the remote address of the client. The
address is not exposed to the pyInterceptors interface. I had to hack
in something into pyInterceptors.cc to add that the contexts returned.
I am not sure how Duncan would want this exposed.
--Bill Noon
Northeast Regional Climate Center
Cornell University
More information about the omniORB-list
mailing list