Source: security/v2/certificate-fetcher-offline.js

  1. /**
  2. * Copyright (C) 2018 Regents of the University of California.
  3. * @author: Jeff Thompson <jefft0@remap.ucla.edu>
  4. * @author: From ndn-cxx security https://github.com/named-data/ndn-cxx/blob/master/src/security/v2/certificate-fetcher-offline.hpp
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. * A copy of the GNU Lesser General Public License is in the file COPYING.
  19. */
  20. /** @ignore */
  21. var ValidationError = require('./validation-error.js').ValidationError; /** @ignore */
  22. var CertificateFetcher = require('./certificate-fetcher.js').CertificateFetcher;
  23. /**
  24. * CertificateFetcherOffline extends CertificateFetcher to implement a fetcher
  25. * that does not fetch certificates (always offline).
  26. * @constructor
  27. */
  28. var CertificateFetcherOffline = function CertificateFetcherOffline()
  29. {
  30. // Call the base constructor.
  31. CertificateFetcher.call(this);
  32. };
  33. CertificateFetcherOffline.prototype = new CertificateFetcher();
  34. CertificateFetcherOffline.prototype.name = "CertificateFetcherOffline";
  35. exports.CertificateFetcherOffline = CertificateFetcherOffline;
  36. CertificateFetcherOffline.prototype.doFetch_ = function
  37. (certificateRequest, state, continueValidation)
  38. {
  39. state.fail(new ValidationError
  40. (ValidationError.CANNOT_RETRIEVE_CERTIFICATE,
  41. "Cannot fetch certificate " +
  42. certificateRequest.interest_.getName().toUri() + " in offline mode"));
  43. };