All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alachisoft.ncache.licensing.ExpirationInfo Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.alachisoft.ncache.licensing;

import com.alachisoft.ncache.runtime.util.NCDateTime;

import java.util.Calendar;

/**
 * @author usama_tariq
 */
public class ExpirationInfo {
    private Calendar _expirationDate = LicenseHelper.getUTCDate();
    private int _gracePeriod = 0;
    private boolean _isPerpetual = false;
    private boolean _inEvaluation = false;
    private boolean _isServerOnly;
    private boolean _istrial;


    public Calendar getExpirationDate() {
        return _expirationDate;
    }

    public void setExpirationDate(Calendar value) {
        _expirationDate = value;
    }

    public int getGracePeriod() {
        return _gracePeriod;
    }

    public void setGracePeriod(int value) {
        _gracePeriod = value;
    }

    public boolean isPerpetual() {
        return _isPerpetual;
    }

    public void setIsPerpetual(boolean value) {
        _isPerpetual = value;
    }

    public boolean isInEvaluation() {
        return _inEvaluation;
    }

    public void setInEvaluation(boolean value) {
        _inEvaluation = value;
    }

    public boolean getIsTrial()
    {
        return _istrial;
    }

    public void setIsTrial(boolean value)
    {
        _istrial = value;
    }

    public boolean getIsServerOnly()
    {
        return _isServerOnly;
    }

    public void setIsServerOnly(boolean value)
    {
        _isServerOnly = value;
    }

    ExpirationStatus getExpirationStatus() {
        if (_inEvaluation)
            return ExpirationStatus.InEvaluation;

        if (_isPerpetual)
            return ExpirationStatus.Licensed;

        if (_isServerOnly)
            return ExpirationStatus.ServerOnly;

        if (NCDateTime.getUTCNow().compareTo(_expirationDate.getTime()) > 0)
        {
            NCDateTime ncDateTime = new NCDateTime(_expirationDate.getTime());
            ncDateTime.addTicks(new NCDateTime(0,0,getGracePeriod(),0,0,0,0).getTicks());
            if (NCDateTime.getUTCNow().compareTo(ncDateTime.getDate()) > 0)
            {
                return ExpirationStatus.Expired;
            }
            return ExpirationStatus.InGracePeriod;
        }
        return ExpirationStatus.Licensed;
    }

    public Calendar getHardExpirationDate() {
        Calendar calendar = LicenseHelper.getCopy(_expirationDate);
        calendar.add(Calendar.DAY_OF_MONTH, _gracePeriod);
        return calendar;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy