NodeSessionPrx InternalRegistryI::registerNode(const InternalNodeInfoPtr& info, const NodePrx& node, const LoadInfo& load, const Ice::Current& current) { const Ice::LoggerPtr logger = _database->getTraceLevels()->logger; try { NodeSessionIPtr session = new NodeSessionI(_database, node, info, _nodeSessionTimeout, load); _reaper->add(new SessionReapable<NodeSessionI>(logger, session), _nodeSessionTimeout); return session->getProxy(); } catch(const Ice::ObjectAdapterDeactivatedException&) { throw Ice::ObjectNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation); } }
void NodeEntry::setSession(const NodeSessionIPtr& session) { Lock sync(*this); if(session) { while(_session) { if(_session->isDestroyed()) { // If the current session has just been destroyed, wait for the setSession(0) call. assert(session != _session); wait(); } else { NodeSessionIPtr session = _session; sync.release(); try { session->getNode()->ice_ping(); throw NodeActiveException(); } catch(const Ice::LocalException&) { try { session->destroy(); } catch(const Ice::ObjectNotExistException&) { } } sync.acquire(); } } // // Clear the saved proxy, the node has established a session // so we won't need anymore to try to register it with this // registry. // _proxy = 0; } else { if(!_session) { return; } } _session = session; notifyAll(); if(_registering) { _registering = false; notifyAll(); } if(session) { if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0) { Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat); out << "node `" << _name << "' up"; } } else { if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0) { Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat); out << "node `" << _name << "' down"; } } }
NodeSessionPrx InternalRegistryI::registerNode(const InternalNodeInfoPtr& info, const NodePrx& node, const LoadInfo& load, const Ice::Current& current) { const TraceLevelsPtr traceLevels = _database->getTraceLevels(); const Ice::LoggerPtr logger = traceLevels->logger; if(!info || !node) { return 0; } if(_requireNodeCertCN) { try { IceSSL::ConnectionInfoPtr sslConnInfo = IceSSL::ConnectionInfoPtr::dynamicCast(current.con->getInfo()); if(sslConnInfo) { if (sslConnInfo->certs.empty() || !sslConnInfo->certs[0]->getSubjectDN().match("CN=" + info->name)) { if(traceLevels->node > 0) { Ice::Trace out(logger, traceLevels->nodeCat); out << "certificate CN doesn't match node name `" << info->name << "'"; } throw PermissionDeniedException("certificate CN doesn't match node name `" + info->name + "'"); } } else { if(traceLevels->node > 0) { Ice::Trace out(logger, traceLevels->nodeCat); out << "node certificate for `" << info->name << "' is required to connect to this registry"; } throw PermissionDeniedException("node certificate is required to connect to this registry"); } } catch(const PermissionDeniedException&) { throw; } catch(const IceUtil::Exception&) { if(traceLevels->node > 0) { Ice::Trace out(logger, traceLevels->nodeCat); out << "unexpected exception while verifying certificate for node `" << info->name << "'"; } throw PermissionDeniedException("unable to verify certificate for node `" + info->name + "'"); } } try { NodeSessionIPtr session = new NodeSessionI(_database, node, info, _nodeSessionTimeout, load); _reaper->add(new SessionReapable<NodeSessionI>(logger, session), _nodeSessionTimeout); return session->getProxy(); } catch(const Ice::ObjectAdapterDeactivatedException&) { throw Ice::ObjectNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation); } }