예제 #1
0
파일: SeatingBL.cs 프로젝트: heran/DekiWiki
 //--- Constructors ---
 public SeatingBL(IUserBL userBL, ILicenseBL licenseBL, ICurrentUserContext userContext, IDekiDataSession dataSession, ILog log) {
     _userBL = userBL;
     _licenseBL = licenseBL;
     _log = log;
     _userContext = userContext;
     _dataSession = dataSession;
 }
예제 #2
0
 //--- Constructors ---
 public SeatingBL(IUserBL userBL, ILicenseBL licenseBL, ICurrentUserContext userContext, IDekiDataSession dataSession, ILog log)
 {
     _userBL      = userBL;
     _licenseBL   = licenseBL;
     _log         = log;
     _userContext = userContext;
     _dataSession = dataSession;
 }
예제 #3
0
 //--- Constructors ---
 public LicenseManager(ILicenseController licenseController, IUserBL userBL, LicenseData licenseData, ILicenseBL licenseBL, IInstanceSettings settings, ISeatingBL seatingBL, LicenseStateTransitionCallback licenseStateTransitionCallback)
 {
     _licenseController = licenseController;
     _userBL            = userBL;
     _licenseData       = licenseData;
     _licenseBL         = licenseBL;
     _settings          = settings;
     _seatingBL         = seatingBL;
     _licenseStateTransitionCallback = licenseStateTransitionCallback;
 }
예제 #4
0
        public override LicenseData VerifyLicenseData(LicenseData licenseData, ILicenseBL licenseBL, ISeatingBL seatingBL) {
            _log.Debug("verifying license: " + licenseData.LicenseState);

            // load authoritative license from remote
            var license = LicenseDoc;
            var verified = licenseBL.DetermineLicenseState(new LicenseData().WithLicenseDocument(license), true, seatingBL.IsSeatLicensingEnabled(licenseData));
            if(!(new[] { LicenseStateType.COMMERCIAL, LicenseStateType.TRIAL, LicenseStateType.INACTIVE, LicenseStateType.EXPIRED }).Contains(verified.LicenseState)) {
                _log.DebugFormat("license state '{0}' is not allowed for remotely managed instances", verified.LicenseState);
                throw new MindTouchRemoteLicenseFailedException();
            }
            _log.Debug("verified license: " + verified.LicenseState);
            return verified;
        }
예제 #5
0
        public override LicenseData VerifyLicenseData(LicenseData licenseData, ILicenseBL licenseBL, ISeatingBL seatingBL)
        {
            _log.Debug("verifying license: " + licenseData.LicenseState);

            // load authoritative license from remote
            var license  = LicenseDoc;
            var verified = licenseBL.DetermineLicenseState(new LicenseData().WithLicenseDocument(license), true, seatingBL.IsSeatLicensingEnabled(licenseData));

            if (!(new[] { LicenseStateType.COMMERCIAL, LicenseStateType.TRIAL, LicenseStateType.INACTIVE, LicenseStateType.EXPIRED }).Contains(verified.LicenseState))
            {
                _log.DebugFormat("license state '{0}' is not allowed for remotely managed instances", verified.LicenseState);
                throw new MindTouchRemoteLicenseFailedException();
            }
            _log.Debug("verified license: " + verified.LicenseState);
            return(verified);
        }
예제 #6
0
        //--- Methods ---
        public virtual LicenseData UpdateLicense(XDoc license, LicenseData currentLicense, ILicenseBL licenseBL, ISeatingBL seatingBL) {
            licenseBL.Validate(license);

            // Only site owner of a license can upload a license that has seat licensing enabled.
            seatingBL.ValidateLicenseUpdateUser(license);
            var newLicense = HandleLicenseTransition(license, currentLicense, seatingBL, licenseBL);
            _licenseStoragePlug.At(_wikiId, LICENSE_FILE).Put(license);
            return newLicense;
        }
예제 #7
0
        protected LicenseData HandleLicenseTransition(XDoc licenseDoc, LicenseData currentLicense, ISeatingBL seatingBL, ILicenseBL licenseBL) {
            var seatingEnabledInNewLicense = seatingBL.IsSeatLicensingEnabled(licenseDoc);
            var tempLicense = licenseBL.BuildLicenseData(licenseDoc, true, seatingEnabledInNewLicense);
            var newLicense = licenseBL.ValidateNewLicenseTransition(tempLicense, currentLicense);
            _log.DebugFormat("new license with state '{0}' has passed validation and will be accepted", newLicense.LicenseState);

            // Ensure that all seats are cleared if seat licensing is disabled. 
            // This will allow a known clean seat state if it becomes enabled.
            if(!seatingBL.IsSeatLicensingEnabled(currentLicense)) {

                _log.Debug("old license did not have seat licensing");
                seatingBL.RevokeSeats(currentLicense);
            }

            // Seat licensing
            if(seatingEnabledInNewLicense) {
                var seats = seatingBL.HandleSeatTransition(licenseDoc);
                if(seats.Assigned > seats.Allowed) {
                    HandleExcessSeats(currentLicense, seatingBL, seats);
                }

                // set a seat for the owner
                seatingBL.SetOwnerUserSeat(newLicense);
            } else {
                _log.Debug("new license does not contain seat licensing");

                // Clear the seat state when going to non-seat license
                seatingBL.RevokeSeats(newLicense);
            }
            _log.DebugFormat("transitioned license from '{0}' to '{1}'", currentLicense.LicenseState, newLicense.LicenseState);
            return newLicense;
        }
예제 #8
0
 public virtual LicenseData VerifyLicenseData(LicenseData licenseData, ILicenseBL licenseBL, ISeatingBL seatingBL) {
     if(licenseData.LicenseDoc.IsEmpty) {
         licenseData = licenseData.WithLicenseDocument(LicenseDoc);
     }
     return licenseBL.DetermineLicenseState(licenseData, true, seatingBL.IsSeatLicensingEnabled(licenseData));
 }
예제 #9
0
 public LicenseService(ILicenseBL licenseBL)
 {
     _licenseBL = licenseBL;
 }
예제 #10
0
 //--- Methods ---
 public override LicenseData UpdateLicense(XDoc license, LicenseData currentLicense, ILicenseBL licenseBL, ISeatingBL seatingBL) {
     _log.DebugFormat("updating license from '{1}' to '{0}'", license["@type"].Contents, currentLicense.LicenseState);
     licenseBL.Validate(license);
     return HandleLicenseTransition(license, currentLicense, seatingBL, licenseBL);
 }
예제 #11
0
 //--- Methods ---
 public override LicenseData UpdateLicense(XDoc license, LicenseData currentLicense, ILicenseBL licenseBL, ISeatingBL seatingBL)
 {
     _log.DebugFormat("updating license from '{1}' to '{0}'", license["@type"].Contents, currentLicense.LicenseState);
     licenseBL.Validate(license);
     return(HandleLicenseTransition(license, currentLicense, seatingBL, licenseBL));
 }
예제 #12
0
 //--- Constructors ---
 public LicenseManager(ILicenseController licenseController, IUserBL userBL, LicenseData licenseData, ILicenseBL licenseBL, IInstanceSettings settings, ISeatingBL seatingBL, LicenseStateTransitionCallback licenseStateTransitionCallback) {
     _licenseController = licenseController;
     _userBL = userBL;
     _licenseData = licenseData;
     _licenseBL = licenseBL;
     _settings = settings;
     _seatingBL = seatingBL;
     _licenseStateTransitionCallback = licenseStateTransitionCallback;
 }
예제 #13
0
        //--- Methods ---
        public virtual LicenseData UpdateLicense(XDoc license, LicenseData currentLicense, ILicenseBL licenseBL, ISeatingBL seatingBL) {
            licenseBL.Validate(license);

            // Only site owner of a license can upload a license that has seat licensing enabled.
            seatingBL.ValidateLicenseUpdateUser(license);
            var newLicense = HandleLicenseTransition(license, currentLicense, seatingBL, licenseBL);
            _licenseStoragePlug.At(_wikiId, LICENSE_FILE).Put(license);
            return newLicense;
        }
예제 #14
0
        protected LicenseData HandleLicenseTransition(XDoc licenseDoc, LicenseData currentLicense, ISeatingBL seatingBL, ILicenseBL licenseBL) {
            var seatingEnabledInNewLicense = seatingBL.IsSeatLicensingEnabled(licenseDoc);
            var tempLicense = licenseBL.BuildLicenseData(licenseDoc, true, seatingEnabledInNewLicense);
            var newLicense = licenseBL.ValidateNewLicenseTransition(tempLicense, currentLicense);
            _log.DebugFormat("new license with state '{0}' has passed validation and will be accepted", newLicense.LicenseState);

            // Ensure that all seats are cleared if seat licensing is disabled. 
            // This will allow a known clean seat state if it becomes enabled.
            if(!seatingBL.IsSeatLicensingEnabled(currentLicense)) {

                _log.Debug("old license did not have seat licensing");
                seatingBL.RevokeSeats(currentLicense);
            }

            // Seat licensing
            if(seatingEnabledInNewLicense) {
                var seats = seatingBL.HandleSeatTransition(licenseDoc);
                if(seats.Assigned > seats.Allowed) {
                    HandleExcessSeats(currentLicense, seatingBL, seats);
                }

                // set a seat for the owner
                seatingBL.SetOwnerUserSeat(newLicense);
            } else {
                _log.Debug("new license does not contain seat licensing");

                // Clear the seat state when going to non-seat license
                seatingBL.RevokeSeats(newLicense);
            }
            _log.DebugFormat("transitioned license from '{0}' to '{1}'", currentLicense.LicenseState, newLicense.LicenseState);
            return newLicense;
        }
예제 #15
0
 public virtual LicenseData VerifyLicenseData(LicenseData licenseData, ILicenseBL licenseBL, ISeatingBL seatingBL) {
     if(licenseData.LicenseDoc.IsEmpty) {
         licenseData = licenseData.WithLicenseDocument(LicenseDoc);
     }
     return licenseBL.DetermineLicenseState(licenseData, true, seatingBL.IsSeatLicensingEnabled(licenseData));
 }