mode_t mode) throw (DmException)
{
if (!(flags & IODriver::kInsecure)) {
- if (!extras.hasField("token"))
- throw DmException(EACCES, "Missing token");
+ if (!extras.hasField("token"))
+ vfsThrow(EACCES, "Missing token");
+
+ std::string userId;
+ if (this->useIp_)
+ userId = this->secCtx_->credentials.remoteAddress;
+ else
+ userId = this->secCtx_->credentials.clientName;
+
+ if (dmlite::validateToken(extras.getString("token"),
+ userId,
+ pfn, this->passwd_,
+ flags != O_RDONLY) != kTokenOK)
+ vfsThrow(EACCES, "Token does not validate for '%s' (using %s)", userId.c_str(), this->useIp_?"IP":"DN");
}
-
- std::string userId;
- if (this->useIp_)
- userId = this->secCtx_->credentials.remoteAddress;
- else
- userId = this->secCtx_->credentials.clientName;
-
- if (dmlite::validateToken(extras.getString("token"),
- userId,
- pfn, this->passwd_,
- flags != O_RDONLY) != kTokenOK)
- throw DmException(EACCES, "Token does not validate (using %s)",
- this->useIp_?"IP":"DN");
-
+
// Create
return new VfsIOHandler(pfn, flags, mode);
}