9 #ifndef TECGRAF_SDK_OPENBUS_OPENBUS_CONNECTION_HPP
10 #define TECGRAF_SDK_OPENBUS_OPENBUS_CONNECTION_HPP
13 #include "openbus/idl.hpp"
14 #include "openbus/detail/decl.hpp"
15 #include "openbus/detail/interceptors/orb_initializer.hpp"
16 #ifndef TECGRAF_SDK_OPENBUS_OPENBUS_DETAIL_LRUCACHE_HPP
17 #define TECGRAF_SDK_OPENBUS_OPENBUS_DETAIL_LRUCACHE_HPP
18 #include "openbus/detail/lru_cache.hpp"
20 #include "openbus/orb_initializer.hpp"
21 #include "openbus/detail/openssl/private_key.hpp"
23 #include <boost/array.hpp>
24 #include <boost/function.hpp>
25 #include <boost/scoped_ptr.hpp>
26 #include <boost/thread.hpp>
27 #include <boost/shared_ptr.hpp>
44 namespace interceptors
47 struct ServerInterceptor;
48 struct ClientInterceptor;
54 struct OPENBUS_SDK_DECL WrongBus :
public std::exception
56 const char *what()
const throw()
58 return "openbus::WrongBus";
62 struct OPENBUS_SDK_DECL BusChanged :
public std::exception
64 const char *what()
const throw()
66 return "openbus::BusChanged";
70 struct OPENBUS_SDK_DECL AlreadyLoggedIn :
public std::exception
72 const char *what()
const throw()
74 return "openbus::AlreadyLoggedIn";
78 struct OPENBUS_SDK_DECL InvalidLoginProcess :
public std::exception
80 const char *what()
const throw()
82 return "openbus::InvalidLoginProcess";
86 struct OPENBUS_SDK_DECL InvalidPropertyValue :
public std::exception
88 InvalidPropertyValue(
const std::string &p,
const std::string &v)
throw()
89 : property(p), value(v)
93 ~InvalidPropertyValue() throw()
97 const char *what()
const throw()
99 return "openbus::InvalidPropertyValue";
102 const std::string property;
103 const std::string value;
106 struct OPENBUS_SDK_DECL InvalidBusAddress :
public std::exception
108 const char *what()
const throw()
110 return "openbus::InvalidBusAddress";
149 const std::string &bus_id,
150 idl::access::LoginProcess_var,
151 idl::legacy::access::LoginProcess_var,
152 const idl::core::OctetSeq &secret,
153 interceptors::ORBInitializer *);
156 idl::access::LoginProcess_var login_process_;
157 idl::legacy::access::LoginProcess_var legacy_login_process_;
158 idl::core::OctetSeq secret_;
159 interceptors::ORBInitializer *orb_initializer_;
160 friend class OpenBusContext;
192 typedef std::vector<std::pair<std::string, std::string> >
193 ConnectionProperties;
209 typedef boost::function<void (Connection & conn, idl::access::LoginInfo login)>
235 void loginByPassword(
236 const std::string &entity,
237 const std::string &password,
238 const std::string &domain =
"");
264 void loginByCertificate(
const std::string &entity, EVP_PKEY *key);
360 const idl::access::LoginInfo *login()
const;
365 const std::string busid()
const;
373 interceptors::ORBInitializer *,
375 EVP_PKEY *access_key,
376 bool legacy_support);
382 const unsigned short port,
384 interceptors::ORBInitializer *,
386 EVP_PKEY *access_key,
387 bool legacy_support);
392 static void renewLogin(
Connection &conn, idl::access::AccessControl_ptr acs,
393 OpenBusContext &ctx, idl::access::ValidityTime t);
395 void login(idl::access::LoginInfo &loginInfo,
396 idl::access::ValidityTime validityTime);
398 void checkBusid()
const;
399 bool _logout(
bool local =
true);
400 CORBA::ORB_ptr orb()
const
405 idl::access::LoginRegistry_var login_registry()
const
407 return _login_registry;
410 idl::access::AccessControl_var access_control()
const
412 return _access_control;
415 const idl::access::LoginInfo *_login()
const
417 boost::lock_guard<boost::mutex> lock(_mutex);;
418 return _loginInfo.get();
421 idl::offers::OfferRegistry_var getOfferRegistry()
const
423 return _offer_registry;
426 idl::access::LoginRegistry_var getLoginRegistry()
const
428 return _login_registry;
433 idl::access::LoginInfo get_login();
435 scs::core::IComponent_var _iComponent;
436 const std::string _host;
437 const unsigned short _port;
438 interceptors::ORBInitializer * _orb_init;
440 boost::thread _renewLogin;
441 mutable boost::mutex _mutex;
442 boost::scoped_ptr<idl::access::LoginInfo> _loginInfo, _invalid_login;
443 InvalidLoginCallback_t _onInvalidLogin;
453 OpenBusContext &_openbusContext;
455 idl::access::AccessControl_var _access_control;
456 idl::access::LoginRegistry_var _login_registry;
457 idl::offers::OfferRegistry_var _offer_registry;
458 boost::scoped_ptr<LoginCache> _loginCache;
460 boost::scoped_ptr<PublicKey> _buskey;
461 bool _legacy_support;
462 idl::legacy::access::AccessControl_var _legacy_access_control;
463 idl::legacy_support::LegacyConverter_var _legacy_converter;
466 CORBA::Object_var _component_ref;
478 std::string remote_id, entity;
479 boost::array<unsigned char, secret_size> secret;
482 friend bool operator==(
const SecretSession &lhs,
const SecretSession &rhs);
483 friend bool operator!=(
const SecretSession &lhs,
const SecretSession &rhs);
485 typedef LRUCache<hash_value, std::string> profile2login_LRUCache;
486 profile2login_LRUCache _profile2login;
487 LRUCache<std::string, SecretSession> _login2session;
489 friend struct openbus::interceptors::ServerInterceptor;
490 friend struct openbus::interceptors::ClientInterceptor;
491 friend class openbus::OpenBusContext;
492 friend bool operator==(
const SecretSession &lhs,
const SecretSession &rhs);
493 friend bool operator!=(
const SecretSession &lhs,
const SecretSession &rhs);
496 inline bool operator==(
const Connection::SecretSession &lhs,
497 const Connection::SecretSession &rhs)
499 return lhs.id == rhs.id
500 && lhs.remote_id == rhs.remote_id
501 && lhs.secret == rhs.secret
502 && lhs.ticket == rhs.ticket;
505 inline bool operator!=(
const Connection::SecretSession &lhs,
506 const Connection::SecretSession &rhs)
508 return !(lhs == rhs);
openbus
Definition: Connection.hpp:37
Segredo para compartilhamento de autenticação.
Definition: Connection.hpp:128
std::string busid() const
Retorna o identificador do barramento em que o segredo pode ser utilizado.
Definition: Connection.hpp:142
boost::function< void(Connection &conn, idl::access::LoginInfo login)> InvalidLoginCallback_t
Callback de login inválido.
Definition: Connection.hpp:210
Conexão para acesso identificado a um barramento.
Definition: Connection.hpp:189