PDFGProductInfo.java 4.73 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.pdfg.exception.ConfigException
 *  org.slf4j.Logger
 *  org.slf4j.LoggerFactory
 */
package com.adobe.pdfg.common;

import com.adobe.pdfg.exception.ConfigException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PDFGProductInfo
implements Serializable {
    private static final Logger logger = LoggerFactory.getLogger(PDFGProductInfo.class);
    static final long serialVersionUID = 765312;
    static final String LICENSE_EVAL = "Eval";
    static final String LICENSE_FULL = "Full";
    private String licenseType;
    private String version;
    private String patchVersion;
    private String expirationDate;
    private String seriallNumber;
    private boolean windows = false;
    private boolean aix = false;
    static PDFGProductInfo instance = null;
    static PDFGProductInfo emptyInstance = null;

    private PDFGProductInfo(String licenseType, String version, String patchVersion, String dateString, String serialNumber) {
        this.licenseType = licenseType;
        this.version = version;
        this.patchVersion = patchVersion;
        this.expirationDate = dateString;
        this.seriallNumber = serialNumber;
        String osName = System.getProperty("os.name").toLowerCase();
        this.windows = osName.indexOf("windows") >= 0;
        this.aix = osName.indexOf("aix") >= 0;
    }

    private PDFGProductInfo() {
        String osName = System.getProperty("os.name").toLowerCase();
        this.windows = osName.indexOf("windows") >= 0;
        this.aix = osName.indexOf("aix") >= 0;
    }

    public static long getSerialVersionUID() {
        return 765312;
    }

    public String getExpirationDate() {
        return this.expirationDate;
    }

    public String getLicenseType() {
        return this.licenseType;
    }

    public String getVersion() {
        return this.version;
    }

    public String getPatchVersion() {
        return this.patchVersion;
    }

    public String getSerialNumber() {
        return this.seriallNumber;
    }

    public static PDFGProductInfo getEmptyInstance() {
        if (emptyInstance == null) {
            emptyInstance = new PDFGProductInfo();
        }
        return emptyInstance;
    }

    public static PDFGProductInfo getInstance() throws ConfigException {
        if (instance == null) {
            PDFGProductInfo.init();
        }
        return instance;
    }

    private static void init() throws ConfigException {
        PDFGProductInfo localInstance = new PDFGProductInfo("Full", "10.0.0", "0", "", "");
        boolean ok = true;
        String temp = localInstance.getLicenseType();
        if (!localInstance.isEvaluation() && !localInstance.isFull()) {
            logger.debug("Bad license type '" + temp + "'");
            ok = false;
        }
        if ((temp = localInstance.getVersion()) == null) {
            logger.debug("Bad version '" + temp + "'");
        }
        if ((temp = localInstance.getPatchVersion()) == null) {
            logger.debug("Bad patch version '" + temp + "'");
        }
        if ((temp = localInstance.getExpirationDate()) == null) {
            logger.debug("Bad expiration date'" + temp + "'");
            ok = false;
        }
        if (!ok) {
            throw new ConfigException(Integer.toString(80018));
        }
        instance = localInstance;
    }

    public Map getInfoMap() {
        HashMap<String, String> infoMap = new HashMap<String, String>();
        infoMap.put("PDFG_LICENSE_TYPE", this.licenseType);
        infoMap.put("PDFG_VERSION", this.version);
        infoMap.put("PDFG_PATCH_VERSION", this.patchVersion);
        infoMap.put("PDFG_EXPIRATION_DATE", this.expirationDate);
        infoMap.put("PDFG_SERIAL_NUMBER", this.seriallNumber);
        return infoMap;
    }

    public void setFromMap(Map infoMap) {
        this.licenseType = (String)infoMap.get("PDFG_LICENSE_TYPE");
        this.version = (String)infoMap.get("PDFG_VERSION");
        this.patchVersion = (String)infoMap.get("PDFG_PATCH_VERSION");
        this.expirationDate = (String)infoMap.get("PDFG_EXPIRATION_DATE");
        this.seriallNumber = (String)infoMap.get("PDFG_SERIAL_NUMBER");
    }

    public boolean isEvaluation() {
        return this.licenseType.equalsIgnoreCase("Eval");
    }

    public boolean isFull() {
        return this.licenseType.equalsIgnoreCase("Full");
    }

    public boolean isApplyWatermark() {
        return this.licenseType.equalsIgnoreCase("Eval");
    }

    public boolean isWindows() {
        return this.windows;
    }

    public boolean isUnix() {
        return !this.windows;
    }

    public boolean isAix() {
        return this.aix;
    }
}