|
@@ -37,11 +37,14 @@ public:
|
|
|
void inc(const AuthCounters::CounterType type);
|
|
|
bool submitStatistics() const;
|
|
|
void setStatisticsSession(isc::cc::AbstractSession* statistics_session);
|
|
|
+ void registerStatisticsValidator
|
|
|
+ (AuthCounters::validator_type validator);
|
|
|
// Currently for testing purpose only
|
|
|
uint64_t getCounter(const AuthCounters::CounterType type) const;
|
|
|
private:
|
|
|
std::vector<uint64_t> counters_;
|
|
|
isc::cc::AbstractSession* statistics_session_;
|
|
|
+ AuthCounters::validator_type validator_;
|
|
|
};
|
|
|
|
|
|
AuthCountersImpl::AuthCountersImpl() :
|
|
@@ -78,6 +81,14 @@ AuthCountersImpl::submitStatistics() const {
|
|
|
<< "]}";
|
|
|
isc::data::ConstElementPtr statistics_element =
|
|
|
isc::data::Element::fromJSON(statistics_string);
|
|
|
+ // validate the statistics data before send
|
|
|
+ if (validator_) {
|
|
|
+ if (!validator_(
|
|
|
+ statistics_element->get("command")->get(1)->get("data"))) {
|
|
|
+ LOG_ERROR(auth_logger, AUTH_INVALID_STATISTICS_DATA);
|
|
|
+ return (false);
|
|
|
+ }
|
|
|
+ }
|
|
|
try {
|
|
|
// group_{send,recv}msg() can throw an exception when encountering
|
|
|
// an error, and group_recvmsg() will throw an exception on timeout.
|
|
@@ -106,6 +117,13 @@ AuthCountersImpl::setStatisticsSession
|
|
|
statistics_session_ = statistics_session;
|
|
|
}
|
|
|
|
|
|
+void
|
|
|
+AuthCountersImpl::registerStatisticsValidator
|
|
|
+ (AuthCounters::validator_type validator)
|
|
|
+{
|
|
|
+ validator_ = validator;
|
|
|
+}
|
|
|
+
|
|
|
// Currently for testing purpose only
|
|
|
uint64_t
|
|
|
AuthCountersImpl::getCounter(const AuthCounters::CounterType type) const {
|
|
@@ -140,3 +158,10 @@ uint64_t
|
|
|
AuthCounters::getCounter(const AuthCounters::CounterType type) const {
|
|
|
return (impl_->getCounter(type));
|
|
|
}
|
|
|
+
|
|
|
+void
|
|
|
+AuthCounters::registerStatisticsValidator
|
|
|
+ (AuthCounters::validator_type validator) const
|
|
|
+{
|
|
|
+ return (impl_->registerStatisticsValidator(validator));
|
|
|
+}
|