2014-01-04 19:45:04 +08:00
|
|
|
/**
|
|
|
|
|
* The login information to access a server
|
|
|
|
|
*
|
|
|
|
|
* This class combines login, password and vhost
|
|
|
|
|
*
|
|
|
|
|
* @copyright 2014 Copernica BV
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set up namespace
|
|
|
|
|
*/
|
|
|
|
|
namespace AMQP {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class definition
|
|
|
|
|
*/
|
|
|
|
|
class Login
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
/**
|
|
|
|
|
* The username
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
std::string _user;
|
2014-01-04 21:11:06 +08:00
|
|
|
|
2014-01-04 19:45:04 +08:00
|
|
|
/**
|
|
|
|
|
* The password
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
std::string _password;
|
2014-01-04 21:11:06 +08:00
|
|
|
|
|
|
|
|
|
2014-01-04 19:45:04 +08:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* Constructor
|
|
|
|
|
* @param user
|
|
|
|
|
* @param password
|
|
|
|
|
*/
|
|
|
|
|
Login(const std::string &user, const std::string &password) :
|
2014-01-04 21:11:06 +08:00
|
|
|
_user(user), _password(password) {}
|
|
|
|
|
|
2014-01-04 19:45:04 +08:00
|
|
|
/**
|
|
|
|
|
* Constructor
|
|
|
|
|
*/
|
|
|
|
|
Login() :
|
2014-01-04 21:11:06 +08:00
|
|
|
_user("guest"), _password("guest") {}
|
2014-01-04 19:45:04 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Destructor
|
|
|
|
|
*/
|
|
|
|
|
virtual ~Login() {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* String representation in SASL PLAIN mode
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
std::string saslPlain()
|
|
|
|
|
{
|
|
|
|
|
// we need an initial string
|
|
|
|
|
std::string result("\0", 1);
|
|
|
|
|
|
|
|
|
|
// append other elements
|
|
|
|
|
return result.append(_user).append("\0",1).append(_password);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* End of namespace
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|