bool GssContext::supported() { return false; }
GssContext::GssContext() { d_error = GSS_CONTEXT_UNSUPPORTED; d_type = GSS_CONTEXT_NONE; }
-GssContext::GssContext(const std::string& label) { d_error = GSS_CONTEXT_UNSUPPORTED; d_type = GSS_CONTEXT_NONE; }
+GssContext::GssContext(const DNSName& label) { d_error = GSS_CONTEXT_UNSUPPORTED; d_type = GSS_CONTEXT_NONE; }
void GssContext::setLocalPrincipal(const std::string& name) {}
bool GssContext::getLocalPrincipal(std::string& name) { return false; }
void GssContext::setPeerPrincipal(const std::string& name) {}
bool GssContext::getPeerPrincipal(std::string& name) { return false; }
void GssContext::generateLabel(const std::string& suffix) {}
-void GssContext::setLabel(const std::string& label) {}
+void GssContext::setLabel(const DNSName& label) {}
bool GssContext::init(const std::string &input, std::string& output) { return false; }
bool GssContext::accept(const std::string &input, std::string& output) { return false; }
bool GssContext::destroy() { return false; }
class GssSecContext : boost::noncopyable {
public:
- GssSecContext(const std::string& label, boost::shared_ptr<GssCredential> cred) {
+ GssSecContext(boost::shared_ptr<GssCredential> cred) {
if (cred->valid() == false) throw PDNSException("Invalid credential " + cred->d_nameS);
d_cred = cred;
d_state = GssStateInitial;
};
-std::map<std::string, boost::shared_ptr<GssSecContext> > s_gss_sec_context;
+std::map<DNSName, boost::shared_ptr<GssSecContext> > s_gss_sec_context;
bool GssContext::supported() { return true; }
void GssContext::initialize() {
- d_label = "";
d_peerPrincipal = "";
d_localPrincipal = "";
d_error = GSS_CONTEXT_NO_ERROR;
generateLabel("pdns.tsig");
}
-GssContext::GssContext(const std::string& label) {
+GssContext::GssContext(const DNSName& label) {
initialize();
- setLabel(toLowerCanonic(label));
+ setLabel(label);
}
void GssContext::generateLabel(const std::string& suffix) {
setLabel(oss.str());
}
-void GssContext::setLabel(const std::string& label) {
+void GssContext::setLabel(const DNSName& label) {
d_label = label;
if (s_gss_sec_context.find(d_label) != s_gss_sec_context.end()) {
d_ctx = s_gss_sec_context[d_label];
}
} else {
// make context
- s_gss_sec_context[d_label] = boost::make_shared<GssSecContext>(d_label, cred);
+ s_gss_sec_context[d_label] = boost::make_shared<GssSecContext>(cred);
s_gss_sec_context[d_label]->d_type = d_type;
d_ctx = s_gss_sec_context[d_label];
d_ctx->d_state = GssSecContext::GssStateNegotiate;
}
} else {
// make context
- s_gss_sec_context[d_label] = boost::make_shared<GssSecContext>(d_label, cred);
+ s_gss_sec_context[d_label] = boost::make_shared<GssSecContext>(cred);
s_gss_sec_context[d_label]->d_type = d_type;
d_ctx = s_gss_sec_context[d_label];
d_ctx->d_state = GssSecContext::GssStateNegotiate;
bool gss_add_signature(const DNSName& context, const std::string& message, std::string& mac) {
string tmp_mac;
- GssContext gssctx(context.toStringNoDot());
+ GssContext gssctx(context);
if (!gssctx.valid()) {
L<<Logger::Error<<"GSS context '"<<context<<"' is not valid"<<endl;
BOOST_FOREACH(const string& error, gssctx.getErrorStrings()) {
}
bool gss_verify_signature(const DNSName& context, const std::string& message, const std::string& mac) {
- GssContext gssctx(context.toStringNoDot());
+ GssContext gssctx(context);
if (!gssctx.valid()) {
L<<Logger::Error<<"GSS context '"<<context<<"' is not valid"<<endl;
BOOST_FOREACH(const string& error, gssctx.getErrorStrings()) {
public:
static bool supported(); //<! Returns true if GSS is supported in the first place
GssContext(); //<! Construct new GSS context with random name
- GssContext(const std::string& label); //<! Create or open existing named context
+ GssContext(const DNSName& label); //<! Create or open existing named context
void setLocalPrincipal(const std::string& name); //<! Set our gss name
bool getLocalPrincipal(std::string& name); //<! Get our name
bool getPeerPrincipal(std::string &name); //<! Return remote name, returns actual name after negotatioan
void generateLabel(const std::string& suffix); //<! Generate random context name using suffix (such as mydomain.com)
- void setLabel(const std::string& label); //<! Set context name to this label
- const std::string& getLabel() { return d_label; } //<! Return context name
+ void setLabel(const DNSName& label); //<! Set context name to this label
+ const DNSName& getLabel() { return d_label; } //<! Return context name
bool init(const std::string &input, std::string& output); //<! Perform GSS Initiate Security Context handshake
bool accept(const std::string &input, std::string& output); //<! Perform GSS Acccept Security Context handshake
#ifdef ENABLE_GSS_TSIG
void processError(const string& method, OM_uint32 maj, OM_uint32 min); //<! Process and fill error text vector
#endif
- std::string d_label; //<! Context name
+ DNSName d_label; //<! Context name
std::string d_peerPrincipal; //<! Remote name
std::string d_localPrincipal; //<! Our name
GssContextError d_error; //<! Context error