diff options
author | Matthew Newhook <matthew@zeroc.com> | 2005-08-09 06:57:43 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2005-08-09 06:57:43 +0000 |
commit | 3e347721b5881a3bc792eceba86346905c759db4 (patch) | |
tree | c8e7ecd5ab13581d8d68ef4c7bd304f5f5ad1946 /cppe/src | |
parent | cleanup. CE demos now use config.txt (diff) | |
download | ice-3e347721b5881a3bc792eceba86346905c759db4.tar.bz2 ice-3e347721b5881a3bc792eceba86346905c759db4.tar.xz ice-3e347721b5881a3bc792eceba86346905c759db4.zip |
- IceE now supports datagram, batch datagram and secure modes.
- The modes are preserved by the proxy.
- stringified proxies can be both read/written which contain these modes.
- any attempt to call on a proxy which supports contains this an
unsupported mode will result in a NoEndpointException.
Diffstat (limited to 'cppe/src')
-rw-r--r-- | cppe/src/IceE/ObjectAdapter.cpp | 8 | ||||
-rw-r--r-- | cppe/src/IceE/Reference.cpp | 104 | ||||
-rw-r--r-- | cppe/src/IceE/Reference.h | 14 | ||||
-rw-r--r-- | cppe/src/IceE/ReferenceFactory.cpp | 68 | ||||
-rw-r--r-- | cppe/src/IceE/ReferenceFactory.h | 4 |
5 files changed, 146 insertions, 52 deletions
diff --git a/cppe/src/IceE/ObjectAdapter.cpp b/cppe/src/IceE/ObjectAdapter.cpp index f40f58b9be5..c9844c09c0e 100644 --- a/cppe/src/IceE/ObjectAdapter.cpp +++ b/cppe/src/IceE/ObjectAdapter.cpp @@ -704,11 +704,11 @@ Ice::ObjectAdapter::newProxy(const Identity& ident, const string& facet) const // Create a reference with the adapter id. // #ifdef ICEE_HAS_ROUTER - ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), facet,Reference::ModeTwoway, + ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), facet,Reference::ModeTwoway, false, _id, 0, _locatorInfo); #else - ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), facet, Reference::ModeTwoway, + ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), facet, Reference::ModeTwoway, false, _id, _locatorInfo); #endif @@ -752,10 +752,10 @@ Ice::ObjectAdapter::newDirectProxy(const Identity& ident, const string& facet) c // Create a reference and return a proxy for this reference. // #ifdef ICEE_HAS_ROUTER - ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), facet, Reference::ModeTwoway, + ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), facet, Reference::ModeTwoway, false, endpoints, 0); #else - ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), facet, Reference::ModeTwoway, + ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), facet, Reference::ModeTwoway, false, endpoints); #endif return _instance->proxyFactory()->referenceToProxy(ref); diff --git a/cppe/src/IceE/Reference.cpp b/cppe/src/IceE/Reference.cpp index 9c96ad01bae..72935b41b8f 100644 --- a/cppe/src/IceE/Reference.cpp +++ b/cppe/src/IceE/Reference.cpp @@ -169,6 +169,8 @@ Reference::hash() const h = 5 * h + *p; } + h = 5 * h + static_cast<Int>(getSecure()); + _hashValue = h; _hashInitialized = true; @@ -199,7 +201,7 @@ IceInternal::Reference::streamWrite(BasicStream* s) const s->write(static_cast<Byte>(_mode)); - s->write(false); // Secure + s->write(getSecure()); // Derived class writes the remainder of the reference. } @@ -269,16 +271,26 @@ IceInternal::Reference::toString() const } case ModeDatagram: + { + s += " -d"; + break; + } + case ModeBatchDatagram: { - // - // TODO: Should this assert? - // + s += " -D"; break; } } + if(getSecure()) + { + s += " -s"; + } + return s; + + // Derived class writes the remainder of the string. } bool @@ -417,6 +429,12 @@ IceInternal::FixedReference::getFixedConnections() const return _fixedConnections; } +bool +IceInternal::FixedReference::getSecure() const +{ + return false; +} + vector<EndpointPtr> IceInternal::FixedReference::getEndpoints() const { @@ -467,7 +485,11 @@ IceInternal::FixedReference::getConnection() const // // Randomize the order of connections. // - if(_fixedConnections.empty()) + // If a reference is secure or the mode is datagram or batch + // datagram then we throw a NoEndpointException since IceE lacks + // this support. + // + if(getSecure() || getMode() == ModeDatagram || getMode() == ModeBatchDatagram || _fixedConnections.empty()) { NoEndpointException ex(__FILE__, __LINE__); ex.proxy = toString(); @@ -557,10 +579,17 @@ IceInternal::RoutableReference::getRoutedEndpoints() const return vector<EndpointPtr>(); } +bool +IceInternal::RoutableReference::getSecure() const +{ + return _secure; +} + ReferencePtr IceInternal::RoutableReference::changeDefault() const { RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(Reference::changeDefault()); + r->_secure = false; r->_routerInfo = getInstance()->routerManager()->get(getInstance()->referenceFactory()->getDefaultRouter()); return r; } @@ -591,6 +620,10 @@ IceInternal::RoutableReference::operator==(const Reference& r) const { return false; } + if(_secure != rhs->_secure) + { + return false; + } return _routerInfo == rhs->_routerInfo; } @@ -616,6 +649,14 @@ IceInternal::RoutableReference::operator<(const Reference& r) const const RoutableReference* rhs = dynamic_cast<const RoutableReference*>(&r); if(rhs) { + if(!_secure && rhs->_secure) + { + return true; + } + else if(rhs->_secure < _secure) + { + return false; + } return _routerInfo < rhs->_routerInfo; } } @@ -624,13 +665,13 @@ IceInternal::RoutableReference::operator<(const Reference& r) const IceInternal::RoutableReference::RoutableReference(const InstancePtr& inst, const Identity& ident, const Context& ctx, const string& fs, Mode md, - const RouterInfoPtr& rtrInfo) - : Reference(inst, ident, ctx, fs, md), _routerInfo(rtrInfo) + bool sec, const RouterInfoPtr& rtrInfo) + : Reference(inst, ident, ctx, fs, md), _secure(sec), _routerInfo(rtrInfo) { } IceInternal::RoutableReference::RoutableReference(const RoutableReference& r) - : Reference(r), _routerInfo(r._routerInfo) + : Reference(r), _secure(r._secure), _routerInfo(r._routerInfo) { } #endif @@ -641,16 +682,16 @@ void IceInternal::decRef(IceInternal::DirectReference* p) { p->__decRef(); } #ifdef ICEE_HAS_ROUTER IceInternal::DirectReference::DirectReference(const InstancePtr& inst, const Identity& ident, - const Context& ctx, const string& fs, Mode md, + const Context& ctx, const string& fs, Mode md, bool sec, const vector<EndpointPtr>& endpts, const RouterInfoPtr& rtrInfo) : - RoutableReference(inst, ident, ctx, fs, md, rtrInfo), + RoutableReference(inst, ident, ctx, fs, md, sec, rtrInfo), _endpoints(endpts) { } #else IceInternal::DirectReference::DirectReference(const InstancePtr& inst, const Identity& ident, - const Context& ctx, const string& fs, Mode md, + const Context& ctx, const string& fs, Mode md, bool, const vector<EndpointPtr>& endpts) : Reference(inst, ident, ctx, fs, md), _endpoints(endpts) @@ -688,10 +729,10 @@ IceInternal::DirectReference::changeDefault() const { LocatorInfoPtr newLocatorInfo = getInstance()->locatorManager()->get(loc); #ifdef ICEE_HAS_ROUTER - return getInstance()->referenceFactory()->create(getIdentity(), Context(), "", ModeTwoway, + return getInstance()->referenceFactory()->create(getIdentity(), Context(), "", ModeTwoway, false, "", 0, newLocatorInfo); #else - return getInstance()->referenceFactory()->create(getIdentity(), Context(), "", ModeTwoway, + return getInstance()->referenceFactory()->create(getIdentity(), Context(), "", ModeTwoway, false, "", newLocatorInfo); #endif } @@ -712,10 +753,10 @@ IceInternal::DirectReference::changeLocator(const LocatorPrx& newLocator) const LocatorInfoPtr newLocatorInfo = getInstance()->locatorManager()->get(newLocator); #ifdef ICEE_HAS_ROUTER return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(), - "", 0, newLocatorInfo); + getSecure(), "", 0, newLocatorInfo); #else return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(), - "", newLocatorInfo); + getSecure(), "", newLocatorInfo); #endif } else @@ -790,7 +831,7 @@ IceInternal::DirectReference::getConnection() const #else vector<EndpointPtr> endpts = _endpoints; #endif - vector<EndpointPtr> filteredEndpoints = filterEndpoints(endpts); + vector<EndpointPtr> filteredEndpoints = filterEndpoints(endpts, getMode(), getSecure()); if(filteredEndpoints.empty()) { NoEndpointException ex(__FILE__, __LINE__); @@ -879,17 +920,17 @@ void IceInternal::decRef(IceInternal::IndirectReference* p) { p->__decRef(); } #ifdef ICEE_HAS_ROUTER IceInternal::IndirectReference::IndirectReference(const InstancePtr& inst, const Identity& ident, - const Context& ctx, const string& fs, Mode md, + const Context& ctx, const string& fs, Mode md, bool sec, const string& adptid, const RouterInfoPtr& rtrInfo, const LocatorInfoPtr& locInfo) - : RoutableReference(inst, ident, ctx, fs, md, rtrInfo), + : RoutableReference(inst, ident, ctx, fs, md, sec, rtrInfo), _adapterId(adptid), _locatorInfo(locInfo) { } #else IceInternal::IndirectReference::IndirectReference(const InstancePtr& inst, const Identity& ident, - const Context& ctx, const string& fs, Mode md, + const Context& ctx, const string& fs, Mode md, bool, const string& adptid, const LocatorInfoPtr& locInfo) : Reference(inst, ident, ctx, fs, md), _adapterId(adptid), @@ -914,10 +955,10 @@ IceInternal::IndirectReference::changeDefault() const if(!loc) { #ifdef ICEE_HAS_ROUTER - return getInstance()->referenceFactory()->create(getIdentity(), Context(), "", ModeTwoway, + return getInstance()->referenceFactory()->create(getIdentity(), Context(), "", ModeTwoway, false, vector<EndpointPtr>(), getRouterInfo()); #else - return getInstance()->referenceFactory()->create(getIdentity(), Context(), "", ModeTwoway, + return getInstance()->referenceFactory()->create(getIdentity(), Context(), "", ModeTwoway, false, vector<EndpointPtr>()); #endif } @@ -939,10 +980,10 @@ IceInternal::IndirectReference::changeLocator(const LocatorPrx& newLocator) cons { #ifdef ICEE_HAS_ROUTER return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(), - vector<EndpointPtr>(), getRouterInfo()); + getSecure(), vector<EndpointPtr>(), getRouterInfo()); #else return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(), - vector<EndpointPtr>()); + getSecure(), vector<EndpointPtr>()); #endif } else @@ -1027,7 +1068,7 @@ IceInternal::IndirectReference::getConnection() const const IndirectReferencePtr self = const_cast<IndirectReference*>(this); endpts = _locatorInfo->getEndpoints(self, cached); } - vector<EndpointPtr> filteredEndpoints = filterEndpoints(endpts); + vector<EndpointPtr> filteredEndpoints = filterEndpoints(endpts, getMode(), getSecure()); if(filteredEndpoints.empty()) { NoEndpointException ex(__FILE__, __LINE__); @@ -1152,9 +1193,20 @@ IceInternal::IndirectReference::IndirectReference(const IndirectReference& r) #endif // ICEE_HAS_LOCATOR vector<EndpointPtr> -IceInternal::filterEndpoints(const vector<EndpointPtr>& allEndpoints) +IceInternal::filterEndpoints(const vector<EndpointPtr>& allEndpoints, Reference::Mode m, bool sec) { - vector<EndpointPtr> endpoints = allEndpoints; + vector<EndpointPtr> endpoints; + + // + // If a secure endpoint, datagram or batch datagram endpoint is + // requested since IceE lacks this support we return no endpoints. + // + if(sec || m == Reference::ModeDatagram || m == Reference::ModeBatchDatagram) + { + return endpoints; + } + + endpoints = allEndpoints; // // Filter out unknown endpoints. diff --git a/cppe/src/IceE/Reference.h b/cppe/src/IceE/Reference.h index e41588fedcf..91ad8f46dc3 100644 --- a/cppe/src/IceE/Reference.h +++ b/cppe/src/IceE/Reference.h @@ -56,6 +56,7 @@ public: Ice::CommunicatorPtr getCommunicator() const; + virtual bool getSecure() const = 0; virtual std::vector<EndpointPtr> getEndpoints() const = 0; // @@ -134,6 +135,7 @@ public: const std::vector<Ice::ConnectionPtr>& getFixedConnections() const; + virtual bool getSecure() const; virtual std::vector<EndpointPtr> getEndpoints() const; #ifdef ICEE_HAS_ROUTER @@ -172,6 +174,7 @@ public: const RouterInfoPtr& getRouterInfo() const { return _routerInfo; } std::vector<EndpointPtr> getRoutedEndpoints() const; + virtual bool getSecure() const; virtual ReferencePtr changeDefault() const; virtual ReferencePtr changeRouter(const Ice::RouterPrx&) const; @@ -186,13 +189,14 @@ public: protected: - RoutableReference(const InstancePtr&, const Ice::Identity&, const Ice::Context&, const std::string&, Mode, - const RouterInfoPtr&); + RoutableReference(const InstancePtr&, const Ice::Identity&, const Ice::Context&, const std::string&, + Mode, bool, const RouterInfoPtr&); RoutableReference(const RoutableReference&); private: + bool _secure; RouterInfoPtr _routerInfo; // Null if no router is used. }; #endif @@ -207,7 +211,7 @@ class DirectReference : public: DirectReference(const InstancePtr&, const Ice::Identity&, const Ice::Context&, const std::string&, Mode, - const std::vector<EndpointPtr>& + bool, const std::vector<EndpointPtr>& #ifdef ICEE_HAS_ROUTER , const RouterInfoPtr& #endif @@ -261,7 +265,7 @@ class IndirectReference : public: IndirectReference(const InstancePtr&, const Ice::Identity&, const Ice::Context&, const std::string&, - Mode, const std::string& + Mode, bool, const std::string& #ifdef ICEE_HAS_ROUTER , const RouterInfoPtr& #endif @@ -304,7 +308,7 @@ private: #endif // ICEE_HAS_LOCATOR -std::vector<EndpointPtr> filterEndpoints(const std::vector<EndpointPtr>&); +std::vector<EndpointPtr> filterEndpoints(const std::vector<EndpointPtr>&, Reference::Mode, bool); } diff --git a/cppe/src/IceE/ReferenceFactory.cpp b/cppe/src/IceE/ReferenceFactory.cpp index f2eac7cae08..e958257edeb 100644 --- a/cppe/src/IceE/ReferenceFactory.cpp +++ b/cppe/src/IceE/ReferenceFactory.cpp @@ -54,6 +54,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, const Context& context, const string& facet, Reference::Mode mode, + bool secure, const vector<EndpointPtr>& endpoints #ifdef ICEE_HAS_ROUTER , const RouterInfoPtr& routerInfo @@ -76,9 +77,9 @@ IceInternal::ReferenceFactory::create(const Identity& ident, // Create new reference // #ifdef ICEE_HAS_ROUTER - return new DirectReference(_instance, ident, context, facet, mode, endpoints, routerInfo); + return new DirectReference(_instance, ident, context, facet, mode, secure, endpoints, routerInfo); #else - return new DirectReference(_instance, ident, context, facet, mode, endpoints); + return new DirectReference(_instance, ident, context, facet, mode, secure, endpoints); #endif } @@ -89,6 +90,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, const Context& context, const string& facet, Reference::Mode mode, + bool secure, const string& adapterId #ifdef ICEE_HAS_ROUTER , const RouterInfoPtr& routerInfo @@ -111,9 +113,9 @@ IceInternal::ReferenceFactory::create(const Identity& ident, // Create new reference // #ifdef ICEE_HAS_ROUTER - return new IndirectReference(_instance, ident, context, facet, mode, adapterId, routerInfo, locatorInfo); + return new IndirectReference(_instance, ident, context, facet, mode, secure, adapterId, routerInfo, locatorInfo); #else - return new IndirectReference(_instance, ident, context, facet, mode, adapterId, locatorInfo); + return new IndirectReference(_instance, ident, context, facet, mode, secure, adapterId, locatorInfo); #endif } @@ -238,6 +240,7 @@ IceInternal::ReferenceFactory::create(const string& str) string facet; Reference::Mode mode = Reference::ModeTwoway; + bool secure = false; string adapter; while(true) @@ -370,6 +373,42 @@ IceInternal::ReferenceFactory::create(const string& str) break; } + case 'd': + { + if(!argument.empty()) + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } + mode = Reference::ModeDatagram; + break; + } + + case 'D': + { + if(!argument.empty()) + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } + mode = Reference::ModeBatchDatagram; + break; + } + + case 's': + { + if(!argument.empty()) + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } + secure = true; + break; + } + default: { ProxyParseException ex(__FILE__, __LINE__); @@ -390,9 +429,9 @@ IceInternal::ReferenceFactory::create(const string& str) { #ifdef ICEE_HAS_LOCATOR # ifdef ICEE_HAS_ROUTER - return create(ident, Context(), facet, mode, "", routerInfo, locatorInfo); + return create(ident, Context(), facet, mode, secure, "", routerInfo, locatorInfo); # else - return create(ident, Context(), facet, mode, "", locatorInfo); + return create(ident, Context(), facet, mode, secure, "", locatorInfo); # endif #else ProxyParseException ex(__FILE__, __LINE__); @@ -449,9 +488,9 @@ IceInternal::ReferenceFactory::create(const string& str) } #ifdef ICEE_HAS_ROUTER - return create(ident, Context(), facet, mode, endpoints , routerInfo); + return create(ident, Context(), facet, mode, secure, endpoints , routerInfo); #else - return create(ident, Context(), facet, mode, endpoints); + return create(ident, Context(), facet, mode, secure, endpoints); #endif break; } @@ -495,9 +534,9 @@ IceInternal::ReferenceFactory::create(const string& str) } #ifdef ICEE_HAS_ROUTER - return create(ident, Context(), facet, mode, adapter, routerInfo, locatorInfo); + return create(ident, Context(), facet, mode, secure, adapter, routerInfo, locatorInfo); #else - return create(ident, Context(), facet, mode, adapter, locatorInfo); + return create(ident, Context(), facet, mode, secure, adapter, locatorInfo); #endif break; } @@ -569,9 +608,9 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) endpoints.push_back(endpoint); } #ifdef ICEE_HAS_ROUTER - return create(ident, Context(), facet, mode, endpoints, routerInfo); + return create(ident, Context(), facet, mode, secure, endpoints, routerInfo); #else - return create(ident, Context(), facet, mode, endpoints); + return create(ident, Context(), facet, mode, secure, endpoints); #endif } else @@ -580,10 +619,9 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) LocatorInfoPtr locatorInfo = _instance->locatorManager()->get(getDefaultLocator()); s->read(adapterId); # ifdef ICEE_HAS_ROUTER - return create(ident, Context(), facet, mode, adapterId, routerInfo, locatorInfo); - + return create(ident, Context(), facet, mode, secure, adapterId, routerInfo, locatorInfo); # else - return create(ident, Context(), facet, mode, adapterId, locatorInfo); + return create(ident, Context(), facet, mode, secure, adapterId, locatorInfo); # endif #else throw ProxyUnmarshalException(__FILE__, __LINE__); diff --git a/cppe/src/IceE/ReferenceFactory.h b/cppe/src/IceE/ReferenceFactory.h index a9c802db1bb..d2c4c4482ae 100644 --- a/cppe/src/IceE/ReferenceFactory.h +++ b/cppe/src/IceE/ReferenceFactory.h @@ -32,7 +32,7 @@ public: // Create a direct reference. // ReferencePtr create(const ::Ice::Identity&, const ::Ice::Context&, const ::std::string&, - Reference::Mode, const ::std::vector<EndpointPtr>& + Reference::Mode, bool, const ::std::vector<EndpointPtr>& #ifdef ICEE_HAS_ROUTER , const RouterInfoPtr& #endif @@ -42,7 +42,7 @@ public: // #ifdef ICEE_HAS_LOCATOR ReferencePtr create(const ::Ice::Identity&, const ::Ice::Context&, const ::std::string&, - Reference::Mode, const ::std::string& + Reference::Mode, bool, const ::std::string& #ifdef ICEE_HAS_ROUTER , const RouterInfoPtr& #endif |