解析Protection.jar

  1. List item

. com.jp.protection.utils.LicenseUtils

	public static void load(License aLicense, Properties aProperties) {
		LicenseImpl license = (LicenseImpl) aLicense;
//		license.setLicenseNumber(aProperties.getProperty("num")); //dev
		System.out.println("num:"+aProperties.getProperty("num"));
		license.setLicenseNumber("dep"); 
		System.out.println("type:"+aProperties.getProperty("typ"));
//		license.setLicenseType(Integer.parseInt(aProperties.getProperty("typ"))); // 3
		license.setLicenseType(3);
		license.setLicenseOptions(Integer.parseInt(aProperties.getProperty("opt", "0"))); // 0
		String property = aProperties.getProperty("isd");
		if (property != null) {
			license.setLicenseIssueDate(new Date(Long.parseLong(property)));
		}

		property = aProperties.getProperty("exd");
		if (property != null) {
			license.setLicenseExpireDate(new Date(Long.parseLong("1619592486000")));
		}

		license.setNumberCopies(Integer.parseInt(aProperties.getProperty("nuc"))); //1
		license.setGracePeriod(Integer.parseInt(aProperties.getProperty("gp"))); // -1
		license.setProduct(aProperties.getProperty("pro")); // saca
		license.setProductEdition(aProperties.getProperty("pre"));
		license.setProductMajorVersion(Integer.parseInt(aProperties.getProperty("maj")));
		license.setProductMinorVersion(Integer.parseInt(aProperties.getProperty("min")));
		license.setLicenseText(aProperties.getProperty("txt"));
		loadProductFeatures(license, aProperties);
		loadProductProperties(license, aProperties);
	}

最内层代码set 属性值。可直接修改过期时间。

  1. List item
protected void readLicense(byte[] aLicenseBytes) {
		try {
			ByteArrayInputStream inputStream = new ByteArrayInputStream(aLicenseBytes);

			try {
				Properties properties = new Properties();
				properties.load(inputStream);
				this.fLicense = new LicenseImpl();
				LicenseUtils.load(this.fLicense, properties);
			} finally {
				inputStream.close();
			}
		} catch (Exception var8) {
			this.fLicense = null;
			this.error((Throwable) var8);
		}

	}
protected void smartReadLicense(byte[] aLicenseBytes) {
		this.readLicense(aLicenseBytes);
		if (this.fLicense == null && this.fLicenseReaderIssueResolver != null
				&& this.fLicenseReaderIssueResolver.resolveLicenseCorrupted(this)) {
			throw new LicenseOutdatedException();
		}
	}
protected byte[] smartGetLicenseBytes(InputStream aLicenseInputStream) {
		byte[] result = this.getLicenseBytes(aLicenseInputStream);
		if (result == null && this.fLicenseReaderIssueResolver != null
				&& this.fLicenseReaderIssueResolver.resolveLicenseCorrupted(this)) {
			throw new LicenseOutdatedException();
		} else {
			return result;
		}
	}
protected byte[] decodeLicense(byte[] aLicenseBytes) {
		byte[] result = aLicenseBytes;
		if (!this.isSkipEncryption()) {
			try {
				SecurityProvider securityProvider = this.getSecurityProvider();
				PublicKey publicKey = securityProvider.getPublicKey(this.fDecryptKeyBytes);
				result = securityProvider.decode(aLicenseBytes, publicKey);
			} catch (Exception var5) {
				result = null;
				this.error((Throwable) var5);
			}
		}

		return result;
	}
protected byte[] smartDecodeLicense(byte[] aLicenseBytes) {
		byte[] result = this.decodeLicense(aLicenseBytes);
		if (result == null && this.fLicenseReaderIssueResolver != null
				&& this.fLicenseReaderIssueResolver.resolveLicenseCorrupted(this)) {
			throw new LicenseOutdatedException();
		} else {
			return result;
		}
	}
public synchronized void readLicense(InputStream aLicenseInputStream, String aLicenseLocation) throws IOException {
		this.fLicenseRead = true;
		this.fLicense = null;
		Object var3 = null;

		byte[] licenseBytes;
		try {
			licenseBytes = this.smartGetLicenseBytes(aLicenseInputStream);
		} finally {
			aLicenseInputStream.close();
		}

		if (licenseBytes == null) {
			this.fireLicenseCorrupted(this, aLicenseLocation);
		} else {
			licenseBytes = this.smartDecodeLicense(licenseBytes);
			if (licenseBytes == null) {
				this.fireLicenseCorrupted(this, aLicenseLocation);
			} else {
				this.smartReadLicense(licenseBytes);
				if (this.fLicense != null) {
					((LicenseImpl) this.fLicense).setLicenseLocation(aLicenseLocation);
					this.fireLicenseAvailable(this, aLicenseLocation);
				} else {
					this.fireLicenseCorrupted(this, aLicenseLocation);
				}
			}
		}

	}

你可能感兴趣的:(解析源码(pojie),java)