2011-08-04 20:32:01 +00:00
|
|
|
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
|
|
|
|
|
2015-10-31 17:28:25 +00:00
|
|
|
var assert = require('assert-plus');
|
2011-08-04 20:32:01 +00:00
|
|
|
var util = require('util');
|
|
|
|
|
|
|
|
var LDAPResult = require('./result');
|
|
|
|
var Protocol = require('../protocol');
|
|
|
|
|
|
|
|
|
|
|
|
///--- API
|
|
|
|
|
|
|
|
function ExtendedResponse(options) {
|
2015-10-31 17:28:25 +00:00
|
|
|
options = options || {};
|
|
|
|
assert.object(options);
|
|
|
|
assert.optionalString(options.responseName);
|
|
|
|
assert.optionalString(options.responsevalue);
|
2011-08-04 20:32:01 +00:00
|
|
|
|
|
|
|
this.responseName = options.responseName || undefined;
|
|
|
|
this.responseValue = options.responseValue || undefined;
|
|
|
|
|
|
|
|
options.protocolOp = Protocol.LDAP_REP_EXTENSION;
|
|
|
|
LDAPResult.call(this, options);
|
|
|
|
}
|
|
|
|
util.inherits(ExtendedResponse, LDAPResult);
|
2015-10-31 17:28:25 +00:00
|
|
|
Object.defineProperties(ExtendedResponse.prototype, {
|
|
|
|
type: {
|
|
|
|
get: function getType() { return 'ExtendedResponse'; },
|
|
|
|
configurable: false
|
|
|
|
},
|
|
|
|
_dn: {
|
|
|
|
get: function getDN() { return this.responseName; },
|
|
|
|
configurable: false
|
|
|
|
},
|
|
|
|
name: {
|
|
|
|
get: function getName() { return this.responseName; },
|
|
|
|
set: function setName(val) {
|
|
|
|
assert.string(val);
|
|
|
|
this.responseName = val;
|
|
|
|
},
|
|
|
|
configurable: false
|
|
|
|
},
|
|
|
|
value: {
|
|
|
|
get: function getValue() { return this.responseValue; },
|
|
|
|
set: function (val) {
|
|
|
|
assert.string(val);
|
|
|
|
this.responseValue = val;
|
|
|
|
},
|
|
|
|
configurable: false
|
|
|
|
}
|
|
|
|
});
|
2011-08-04 20:32:01 +00:00
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
ExtendedResponse.prototype._parse = function (ber) {
|
2011-08-04 20:32:01 +00:00
|
|
|
assert.ok(ber);
|
|
|
|
|
|
|
|
if (!LDAPResult.prototype._parse.call(this, ber))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (ber.peek() === 0x8a)
|
|
|
|
this.responseName = ber.readString(0x8a);
|
|
|
|
if (ber.peek() === 0x8b)
|
|
|
|
this.responseValue = ber.readString(0x8b);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
ExtendedResponse.prototype._toBer = function (ber) {
|
2011-08-04 20:32:01 +00:00
|
|
|
assert.ok(ber);
|
|
|
|
|
|
|
|
if (!LDAPResult.prototype._toBer.call(this, ber))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (this.responseName)
|
|
|
|
ber.writeString(this.responseName, 0x8a);
|
|
|
|
if (this.responseValue)
|
|
|
|
ber.writeString(this.responseValue, 0x8b);
|
|
|
|
|
|
|
|
return ber;
|
|
|
|
};
|
|
|
|
|
2012-02-18 08:15:52 +00:00
|
|
|
ExtendedResponse.prototype._json = function (j) {
|
2011-08-04 20:32:01 +00:00
|
|
|
assert.ok(j);
|
|
|
|
|
|
|
|
j = LDAPResult.prototype._json.call(this, j);
|
|
|
|
|
|
|
|
j.responseName = this.responseName;
|
|
|
|
j.responseValue = this.responseValue;
|
|
|
|
|
|
|
|
return j;
|
|
|
|
};
|
2015-10-31 17:28:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
///--- Exports
|
|
|
|
|
|
|
|
module.exports = ExtendedResponse;
|