9 #ifndef TECGRAF_SDK_OPENBUS_CONNECTION_H_
10 #define TECGRAF_SDK_OPENBUS_CONNECTION_H_
12 #include "openbus/decl.hpp"
15 #include "access_controlC.h"
16 #include "offer_registryC.h"
17 #include "openbus/interceptors/ORBInitializer_impl.hpp"
18 #include "openbus/crypto/PrivateKey.hpp"
19 #include "openbus/crypto/PublicKey.hpp"
20 #ifndef TECGRAF_SDK_OPENBUS_LRUCACHE_H_
21 #define TECGRAF_SDK_OPENBUS_LRUCACHE_H_
22 #include "openbus/LRUCache_impl.hpp"
25 #include <boost/array.hpp>
26 #include <boost/function.hpp>
27 #include <boost/scoped_ptr.hpp>
28 #ifdef OPENBUS_SDK_MULTITHREAD
29 #include <boost/thread.hpp>
31 #include <boost/shared_ptr.hpp>
45 namespace idl_or = tecgraf::openbus::core::v2_0::services::offer_registry;
49 #ifndef OPENBUS_SDK_MULTITHREAD
53 namespace interceptors
56 struct ServerInterceptor;
57 struct ClientInterceptor;
63 struct OPENBUS_SDK_DECL BusChanged :
public std::exception
65 const char *what()
const throw()
67 return "openbus::BusChanged";
71 struct OPENBUS_SDK_DECL AlreadyLoggedIn :
public std::exception
73 const char *what()
const throw()
75 return "openbus::AlreadyLoggedIn";
79 struct OPENBUS_SDK_DECL InvalidLoginProcess :
public std::exception
81 const char *what()
const throw()
83 return "openbus::InvalidLoginProcess";
87 struct OPENBUS_SDK_DECL InvalidPropertyValue :
public std::exception
89 InvalidPropertyValue(
const std::string &p,
const std::string &v)
throw()
90 : property(p), value(v)
94 ~InvalidPropertyValue() throw()
98 const char *what()
const throw()
100 return "openbus::InvalidPropertyValue";
103 const std::string property;
104 const std::string value;
142 const idl::OctetSeq &secret,
143 interceptors::ORBInitializer *);
145 idl_ac::LoginProcess_var login_process_;
146 idl::OctetSeq secret_;
147 interceptors::ORBInitializer *orb_initializer_;
180 typedef std::vector<std::pair<std::string, std::string> >
181 ConnectionProperties;
197 typedef boost::function<void (Connection & conn, idl_ac::LoginInfo login)>
218 void loginByPassword(
const std::string &entity,
const std::string &password);
241 void loginByCertificate(
const std::string &entity,
const PrivateKey &privKey);
334 const idl_ac::LoginInfo *login()
const;
339 const std::string busid()
const;
345 Connection(
const std::string host,
const unsigned short port, CORBA::ORB_ptr,
347 const ConnectionProperties &props);
352 #ifdef OPENBUS_SDK_MULTITHREAD
353 static void renewLogin(
Connection &conn, idl_ac::AccessControl_ptr acs,
356 void login(idl_ac::LoginInfo &loginInfo,
357 idl_ac::ValidityTime validityTime);
359 void checkBusid()
const;
360 bool _logout(
bool local =
true);
361 CORBA::ORB_ptr orb()
const
366 idl_ac::LoginRegistry_var login_registry()
const
368 return _login_registry;
371 idl_ac::AccessControl_var access_control()
const
373 return _access_control;
376 const idl_ac::LoginInfo *_login()
const
378 #ifdef OPENBUS_SDK_MULTITHREAD
379 boost::lock_guard<boost::mutex> lock(_mutex);;
381 return _loginInfo.get();
384 idl_or::OfferRegistry_var getOfferRegistry()
const
386 return _offer_registry;
389 idl_ac::LoginRegistry_var getLoginRegistry()
const
391 return _login_registry;
394 idl_ac::LoginInfo get_login();
396 const std::string _host;
397 const unsigned short _port;
398 interceptors::ORBInitializer * _orb_init;
400 #ifdef OPENBUS_SDK_MULTITHREAD
401 boost::thread _renewLogin;
402 mutable boost::mutex _mutex;
404 boost::scoped_ptr<RenewLogin> _renewLogin;
406 boost::scoped_ptr<idl_ac::LoginInfo> _loginInfo, _invalid_login;
407 InvalidLoginCallback_t _onInvalidLogin;
423 OpenBusContext &_openbusContext;
425 scs::core::IComponent_var _iComponent;
426 idl_ac::AccessControl_var _access_control;
427 idl_ac::LoginRegistry_var _login_registry;
428 idl_or::OfferRegistry_var _offer_registry;
429 boost::scoped_ptr<LoginCache> _loginCache;
431 boost::scoped_ptr<PublicKey> _buskey;
432 LegacyDelegate _legacyDelegate;
444 std::string remote_id;
445 boost::array<unsigned char, secret_size> secret;
447 friend bool operator==(
const SecretSession &lhs,
const SecretSession &rhs);
448 friend bool operator!=(
const SecretSession &lhs,
const SecretSession &rhs);
450 typedef LRUCache<hash_value, std::string> profile2login_LRUCache;
451 profile2login_LRUCache _profile2login;
452 LRUCache<std::string, SecretSession> _login2session;
454 friend struct openbus::interceptors::ServerInterceptor;
455 friend struct openbus::interceptors::ClientInterceptor;
457 friend bool operator==(
const SecretSession &lhs,
const SecretSession &rhs);
458 friend bool operator!=(
const SecretSession &lhs,
const SecretSession &rhs);
461 inline bool operator==(
const Connection::SecretSession &lhs,
462 const Connection::SecretSession &rhs)
464 return lhs.id == rhs.id
465 && lhs.remote_id == rhs.remote_id
466 && lhs.secret == rhs.secret
467 && lhs.ticket == rhs.ticket;
470 inline bool operator!=(
const Connection::SecretSession &lhs,
471 const Connection::SecretSession &rhs)
473 return !(lhs == rhs);
openbus
Definition: Connection.hpp:41
Segredo para compartilhamento de autenticação.
Definition: Connection.hpp:121
Definition: OpenBusContext.hpp:47
std::string busid() const
Retorna o identificador do barramento em que o segredo pode ser utilizado.
Definition: Connection.hpp:135
Definition: OpenBusContext.hpp:51
Conexão para acesso identificado a um barramento.
Definition: Connection.hpp:177
boost::function< void(Connection &conn, idl_ac::LoginInfo login)> InvalidLoginCallback_t
Callback de login inválido.
Definition: Connection.hpp:198
Permite controlar o contexto das chamadas de um ORB para acessar informações que identificam essas ch...
Definition: OpenBusContext.hpp:262