Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright 2011 Mark Cavage, Inc. All rights reserved.
  2. var assert = require('assert');
  3. var Ber = require('asn1').Ber;
  4. var Control = require('./control');
  5. var EntryChangeNotificationControl =
  6. require('./entry_change_notification_control');
  7. var PersistentSearchControl = require('./persistent_search_control');
  8. var PagedResultsControl = require('./paged_results_control');
  9. var ServerSideSortingRequestControl =
  10. require('./server_side_sorting_request_control.js');
  11. var ServerSideSortingResponseControl =
  12. require('./server_side_sorting_response_control.js');
  13. ///--- API
  14. module.exports = {
  15. getControl: function getControl(ber) {
  16. assert.ok(ber);
  17. if (ber.readSequence() === null)
  18. return null;
  19. var type;
  20. var opts = {
  21. criticality: false,
  22. value: null
  23. };
  24. if (ber.length) {
  25. var end = ber.offset + ber.length;
  26. type = ber.readString();
  27. if (ber.offset < end) {
  28. if (ber.peek() === Ber.Boolean)
  29. opts.criticality = ber.readBoolean();
  30. }
  31. if (ber.offset < end)
  32. opts.value = ber.readString(Ber.OctetString, true);
  33. }
  34. var control;
  35. switch (type) {
  36. case PersistentSearchControl.OID:
  37. control = new PersistentSearchControl(opts);
  38. break;
  39. case EntryChangeNotificationControl.OID:
  40. control = new EntryChangeNotificationControl(opts);
  41. break;
  42. case PagedResultsControl.OID:
  43. control = new PagedResultsControl(opts);
  44. break;
  45. case ServerSideSortingRequestControl.OID:
  46. control = new ServerSideSortingRequestControl(opts);
  47. break;
  48. case ServerSideSortingResponseControl.OID:
  49. control = new ServerSideSortingResponseControl(opts);
  50. break;
  51. default:
  52. opts.type = type;
  53. control = new Control(opts);
  54. break;
  55. }
  56. return control;
  57. },
  58. Control: Control,
  59. EntryChangeNotificationControl: EntryChangeNotificationControl,
  60. PagedResultsControl: PagedResultsControl,
  61. PersistentSearchControl: PersistentSearchControl,
  62. ServerSideSortingRequestControl: ServerSideSortingRequestControl,
  63. ServerSideSortingResponseControl: ServerSideSortingResponseControl
  64. };