{"size": 1394, "ext": "js", "max_stars_repo_path": "dist/com/onsoft/glasscat/security/session/managers/EjpSessionManager.js", "max_stars_repo_name": "jec-project/jec-glasscat-core", "max_stars_repo_stars_event_min_datetime": "2017-10-27T12:53:20.000Z", "max_stars_repo_stars_event_max_datetime": "2017-10-27T12:53:20.000Z", "max_issues_repo_path": "dist/com/onsoft/glasscat/security/session/managers/EjpSessionManager.js", "max_issues_repo_name": "pechemann/jec-glasscat-core", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "dist/com/onsoft/glasscat/security/session/managers/EjpSessionManager.js", "max_forks_repo_name": "pechemann/jec-glasscat-core", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 33.1904761905, "max_line_length": 98, "alphanum_fraction": 0.6606886657}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const jec_commons_1 = require("jec-commons");
const crypto = require("crypto");
const SessionIdBuilder_1 = require("../utils/SessionIdBuilder");
class EjpSessionManager {
    constructor() {
        this._guid = null;
        this.HASH_ALGORITHM = "sha256";
        this.OUTPUT_ENCODING = "hex";
        this._connector = null;
        this._sessionIdBuilder = null;
        this.init();
    }
    init() {
        this._guid = jec_commons_1.GlobalGuidGenerator.getInstance().generate();
        this._sessionIdBuilder = new SessionIdBuilder_1.SessionIdBuilder();
    }
    getSessionStorage() {
        return this._connector;
    }
    setSessionStorage(sessionStorage) {
        this._connector = sessionStorage;
    }
    initSessionId() {
        const sha = crypto.createHash(this.HASH_ALGORITHM)
            .update(Date.now() + this._guid);
        const sessionId = this._sessionIdBuilder.buildSessionId(sha.digest(this.OUTPUT_ENCODING));
        return sessionId;
    }
    addSession(session, result) {
        this._connector.add(session, result);
    }
    getSession(sessionId, success, error) {
        this._connector.get(sessionId, success, error);
    }
    removeSession(sessionId, result) {
        this._connector.remove(sessionId, result);
    }
}
exports.EjpSessionManager = EjpSessionManager;
