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

com.alachisoft.ncache.ncactivate.license.EvaluationData Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
/*
 * EvaluationData.java
 *
 * Created on October 13, 2006, 9:26 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.alachisoft.ncache.ncactivate.license;

import com.alachisoft.ncache.runtime.exceptions.LicensingException;
import com.alachisoft.ncache.runtime.exceptions.LocalVerificationFailedException;

import java.io.IOException;
import java.util.ArrayList;

/**
 * @author Administrator
 */
public class EvaluationData {

    public short Year;
    public short Month;
    public short Days;
    public short ExtensionVal;
    public short Extensions;
    public short Period;
    public short ActivationStatus;
    public short Res3;

    /**
     * Creates a new instance of EvaluationData
     */
    public EvaluationData() {
    }

    /// 
    /// Returns the number of processors on the system.
    /// 
    public static int GetNumProcessors() throws LicensingException, LocalVerificationFailedException {
        return NCCpuInfo.GetNumProcessors();
    }

    /// 
    /// Returns a list of mac addresses found on the system.
    /// 

    public static ArrayList GetAdaptersAddressList() throws IOException {
        return NetworkInfo.getMacAddress();
    }


    //   public static void ReadActivationCode(StringRef code)
    //  {
    //        NCMisc.ReadActivationCode(code);
    //           return;
    //   }


    public static int ReadEvaluationData(int version, EvaluationData time) throws LicensingException, LocalVerificationFailedException {
        String systemFolder[] = null;
        try{
            systemFolder = NCMisc.getStubPath();
            return ReadEvaluationData(NCMisc.ReadEvaluationData(systemFolder).data,version,time);
        }catch (Exception ex){

        }
        return -1;
    }

    public static int ReadEvaluationData(byte[] evalData, int version, EvaluationData time) throws LicensingException {
        SystemTime pTime = new SystemTime();
        //decrypt the eval data
//        ByteRef refBytes = new ByteRef();
//        refBytes.data = evalData;
//        NCCrypto.EncryptDecryptBytes(refBytes,evalData.length - NCMisc.g_DataOffset,NCMisc.g_DataOffset);

        int nResult = NCMisc.ReadEvaluationData(evalData, version, pTime);
        convertToEvalData(pTime, time);
        return nResult;
    }

    private static void convertToEvalData(SystemTime pTime, EvaluationData time) {
        time.Year = pTime.wYear;
        time.Month = pTime.wMonth;
        time.Days = pTime.wDayOfWeek;
        time.ExtensionVal = pTime.wDay;
        time.Extensions = pTime.wHour;
        time.Period = pTime.wMinute;
        time.ActivationStatus = pTime.wSecond;
        time.Res3 = pTime.wMilliseconds;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy