2011-12-08 22:54:40 +00:00
|
|
|
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
|
|
|
|
2020-10-31 21:07:32 +00:00
|
|
|
const assert = require('assert')
|
|
|
|
const Ber = require('asn1').Ber
|
2011-12-08 19:22:35 +00:00
|
|
|
|
2020-10-31 21:07:32 +00:00
|
|
|
const Control = require('./control')
|
|
|
|
const EntryChangeNotificationControl =
|
2019-08-27 21:11:49 +00:00
|
|
|
require('./entry_change_notification_control')
|
2020-10-31 21:07:32 +00:00
|
|
|
const PersistentSearchControl = require('./persistent_search_control')
|
|
|
|
const PagedResultsControl = require('./paged_results_control')
|
|
|
|
const ServerSideSortingRequestControl =
|
2019-08-27 21:11:49 +00:00
|
|
|
require('./server_side_sorting_request_control.js')
|
2020-10-31 21:07:32 +00:00
|
|
|
const ServerSideSortingResponseControl =
|
2019-08-27 21:11:49 +00:00
|
|
|
require('./server_side_sorting_response_control.js')
|
2020-10-31 21:07:32 +00:00
|
|
|
const VirtualListViewRequestControl =
|
2019-09-03 20:25:14 +00:00
|
|
|
require('./virtual_list_view_request_control.js')
|
2020-10-31 21:07:32 +00:00
|
|
|
const VirtualListViewResponseControl =
|
2019-09-03 20:25:14 +00:00
|
|
|
require('./virtual_list_view_response_control.js')
|
2011-12-08 19:22:35 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
/// --- API
|
2011-12-08 19:22:35 +00:00
|
|
|
|
|
|
|
module.exports = {
|
2011-12-08 22:54:40 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
getControl: function getControl (ber) {
|
|
|
|
assert.ok(ber)
|
2011-12-08 19:22:35 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
if (ber.readSequence() === null) { return null }
|
2011-12-08 22:54:40 +00:00
|
|
|
|
2020-10-31 21:07:32 +00:00
|
|
|
let type
|
|
|
|
const opts = {
|
2015-11-12 04:36:21 +00:00
|
|
|
criticality: false,
|
|
|
|
value: null
|
2019-08-27 21:11:49 +00:00
|
|
|
}
|
2011-12-08 19:22:35 +00:00
|
|
|
|
|
|
|
if (ber.length) {
|
2020-10-31 21:07:32 +00:00
|
|
|
const end = ber.offset + ber.length
|
2011-12-08 22:54:40 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
type = ber.readString()
|
2011-12-08 19:22:35 +00:00
|
|
|
if (ber.offset < end) {
|
2019-08-27 21:11:49 +00:00
|
|
|
if (ber.peek() === Ber.Boolean) { opts.criticality = ber.readBoolean() }
|
2011-12-08 19:22:35 +00:00
|
|
|
}
|
2011-12-08 22:54:40 +00:00
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
if (ber.offset < end) { opts.value = ber.readString(Ber.OctetString, true) }
|
2011-12-08 19:22:35 +00:00
|
|
|
}
|
2011-12-08 22:54:40 +00:00
|
|
|
|
2020-10-31 21:07:32 +00:00
|
|
|
let control
|
2011-12-08 22:54:40 +00:00
|
|
|
switch (type) {
|
2019-08-27 21:11:49 +00:00
|
|
|
case PersistentSearchControl.OID:
|
|
|
|
control = new PersistentSearchControl(opts)
|
|
|
|
break
|
|
|
|
case EntryChangeNotificationControl.OID:
|
|
|
|
control = new EntryChangeNotificationControl(opts)
|
|
|
|
break
|
|
|
|
case PagedResultsControl.OID:
|
|
|
|
control = new PagedResultsControl(opts)
|
|
|
|
break
|
|
|
|
case ServerSideSortingRequestControl.OID:
|
|
|
|
control = new ServerSideSortingRequestControl(opts)
|
|
|
|
break
|
|
|
|
case ServerSideSortingResponseControl.OID:
|
|
|
|
control = new ServerSideSortingResponseControl(opts)
|
|
|
|
break
|
2019-09-03 20:25:14 +00:00
|
|
|
case VirtualListViewRequestControl.OID:
|
|
|
|
control = new VirtualListViewRequestControl(opts)
|
|
|
|
break
|
|
|
|
case VirtualListViewResponseControl.OID:
|
|
|
|
control = new VirtualListViewResponseControl(opts)
|
|
|
|
break
|
2019-08-27 21:11:49 +00:00
|
|
|
default:
|
|
|
|
opts.type = type
|
|
|
|
control = new Control(opts)
|
|
|
|
break
|
2011-12-08 22:54:40 +00:00
|
|
|
}
|
|
|
|
|
2019-08-27 21:11:49 +00:00
|
|
|
return control
|
2011-12-08 19:22:35 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
Control: Control,
|
2011-12-20 00:52:48 +00:00
|
|
|
EntryChangeNotificationControl: EntryChangeNotificationControl,
|
2012-03-26 18:53:30 +00:00
|
|
|
PagedResultsControl: PagedResultsControl,
|
2014-05-16 15:10:24 +00:00
|
|
|
PersistentSearchControl: PersistentSearchControl,
|
2014-06-09 22:58:01 +00:00
|
|
|
ServerSideSortingRequestControl: ServerSideSortingRequestControl,
|
2019-09-03 20:25:14 +00:00
|
|
|
ServerSideSortingResponseControl: ServerSideSortingResponseControl,
|
|
|
|
VirtualListViewRequestControl: VirtualListViewRequestControl,
|
|
|
|
VirtualListViewResponseControl: VirtualListViewResponseControl
|
2019-08-27 21:11:49 +00:00
|
|
|
}
|