diffusion
Version:
Diffusion JavaScript client
66 lines (65 loc) • 2.88 kB
JavaScript
;
/**
* @module Services.Authentication
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SystemPrincipalSerialiser = exports.SystemPrincipalSerialiserClass = void 0;
var system_principal_1 = require("./../../features/security/system-principal");
var Codec = require("./../../io/codec");
var serialiser_1 = require("./../../serialisers/serialiser");
/**
* Serialiser for {@link SystemPrincipal}
*/
var SystemPrincipalSerialiserClass = /** @class */ (function (_super) {
__extends(SystemPrincipalSerialiserClass, _super);
function SystemPrincipalSerialiserClass() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Read a {@link SystemPrincipal} from the stream
*
* @param bis the input stream
* @return the {@link SystemPrincipal} that was read
*/
SystemPrincipalSerialiserClass.prototype.read = function (bis) {
var name = Codec.readString(bis);
var roles = Codec.readCollection(bis, Codec.readString);
var lockingPrincipal = Codec.readBoolean(bis) ? Codec.readString(bis) : undefined;
return new system_principal_1.SystemPrincipalImpl(name, roles, lockingPrincipal);
};
/**
* Write a {@link SystemPrincipal} to the stream
*
* @param bis the input stream
* @param value the {@link SystemPrincipal} to be written
*/
SystemPrincipalSerialiserClass.prototype.write = function (bos, value) {
Codec.writeString(bos, value.name);
Codec.writeCollection(bos, value.roles, Codec.writeString);
Codec.writeBoolean(bos, !!value.lockingPrincipal);
if (value.lockingPrincipal) {
Codec.writeString(bos, value.lockingPrincipal);
}
};
return SystemPrincipalSerialiserClass;
}(serialiser_1.AbstractSerialiser));
exports.SystemPrincipalSerialiserClass = SystemPrincipalSerialiserClass;
/**
* The {@link SystemPrincipalSerialiser} singleton
*/ // eslint-disable-next-line @typescript-eslint/naming-convention
exports.SystemPrincipalSerialiser = new SystemPrincipalSerialiserClass();