原文:https://www.cnblogs.com/baby123/p/11046704.html
前一段时间使用aspose.slides for java,处理了下才去除的水印,但是时间一久就忘记了,重新整理了下
下载aspose-slides-19.3-jdk16.jar,重命名为aspose.slides-19.3.jar(为了在maven应用才改名的)
(1)使用jd-gui查看jar包
注册文件的加载类License
package com.aspose.slides; import com.aspose.slides.exceptions.InvalidOperationException; import com.aspose.slides.internal.k5.return; import com.aspose.slides.ms.System.IDisposable; import com.aspose.slides.ms.System.p; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; public class License implements ILicense { public void setLicense(InputStream stream) throws AsposeLicenseException { try { ByteArrayInputStream localByteArrayInputStream = null; if (stream != null) { localObject = new ByteArrayOutputStream(); byte[] arrayOfByte = new byte[1024]; int i; while ((i = stream.read(arrayOfByte)) > 0) ((ByteArrayOutputStream)localObject).write(arrayOfByte, 0, i); ((ByteArrayOutputStream)localObject).flush(); localByteArrayInputStream = new ByteArrayInputStream(((ByteArrayOutputStream)localObject).toByteArray()); } Object localObject = new return(); ((return)localObject).jdMethod_do(localByteArrayInputStream); } catch (IOException localIOException1) { throw new InvalidOperationException("License stream is not available for reading"); } } public void setLicense(String namePath) throws AsposeLicenseException { try { FileInputStream localFileInputStream = null; if ((null != namePath) && (!"".equals(namePath))) localFileInputStream = new FileInputStream(namePath); setLicense(localFileInputStream); } catch (FileNotFoundException localFileNotFoundException1) { throw new InvalidOperationException("License stream is not available for reading"); } } public static String getVersion() { return return.jdMethod_new(); } public void resetLicense() { return.jdMethod_for(); } public boolean isLicensed() { int i = 0; Presentation localPresentation = new Presentation(); try { ISlide localISlide = localPresentation.getSlides().addEmptySlide(localPresentation.getLayoutSlides().getByType(11)); IAutoShape localIAutoShape = localISlide.getShapes().addAutoShape(5, 10.0F, 10.0F, 200.0F, 100.0F); localIAutoShape.getTextFrame().setText(p.jdMethod_if("", 500, 'a')); i = localIAutoShape.getTextFrame().getText().length() == 500 ? 1 : 0; } finally { if (localPresentation != null) localPresentation.dispose(); } return i; } }
主要的处理类为return
说明:具体是是哪一个类,要看具体情况,不同的版本是有差异的
关键代码
private static void jdField_do(Node paramNode1, Node paramNode2, String[] paramArrayOfString) { PublicKey localPublicKey = null; Object localObject; try { KeyFactory localKeyFactory = KeyFactory.getInstance("RSA"); localObject = void.jdField_do(jdField_if(paramArrayOfString)); localPublicKey = localKeyFactory.generatePublic((KeySpec)localObject); } catch (Exception localException1) { new float() { } .jdField_do(new throws() { } .jdField_if, localException1); } try { String str1 = paramNode1 != null ? jdField_do(paramNode1) : ""; localObject = str1.getBytes("UTF-16LE"); String str2 = paramNode2 != null ? paramNode2.getFirstChild().getNodeValue() : ""; byte[] arrayOfByte = try.jdField_do(str2); Signature localSignature = Signature.getInstance("SHA1withRSA"); localSignature.initVerify(localPublicKey); localSignature.update(localObject); if (!localSignature.verify(arrayOfByte)) new float() { } .jdField_do(new throws() { } .jdField_for); } catch (Exception localException2) { new float() { } .jdField_do(new throws() { } .jdField_int, localException2); } }
(2)使用javassist
使用rsa加密验证许可证的合法性,屏蔽验证过程许可证即有效
用进行代码修改
import javassist.ClassPool; import javassist.CtClass; import javassist.CtMethod; public class Main { public static void main(String[] args) { try { ClassPool.getDefault().insertClassPath( "lib/aspose.slides-19.3.jar"); CtClass c2 = ClassPool.getDefault() .getCtClass("com.aspose.slides.internal.k5.return"); CtMethod[] ms = c2.getDeclaredMethods(); for (CtMethod c : ms) { System.out.println(c.getName()); CtClass[] ps = c.getParameterTypes(); for (CtClass cx : ps) { System.out.println(" " + cx.getName()); } if (ps.length == 3 && ps[0].getName().equals("org.w3c.dom.Node") && ps[1].getName().equals("org.w3c.dom.Node")) { System.out.println("find it!"); c.setBody("{return;}"); } } c2.writeFile(); } catch (Exception e) { e.printStackTrace(); } } }
说明:
javassist下载使用参考https://www.cnblogs.com/baby123/p/10871154.html
重新生成jar包:
a. 将以前的 aspose.slides-19.3.jar 修改aspose.slides-19.3.zip
b. 解压 aspose.slides-19.3.zip 为 aspose.slides-19.3
c. 将刚才生成的 comasposeslidesinternalmx eturn.class 替换掉 aspose.slides-19.3 里的 return.class
d. 将 META-INF 下除了 MANIFEST.MF 其他文件都删掉
e. 压缩 aspose.slides-19.3 为 aspose.slides-19.3.zip
f. 修改文件名为 aspose.slides-19.3.jar
(3)许可文件 license.xml
<License> <Data> <Products> <Product>Aspose.Total for Java</Product> </Products> <EditionType>Enterprise</EditionType> <SubscriptionExpiry>20991231</SubscriptionExpiry> <LicenseExpiry>20991231</LicenseExpiry> <SerialNumber>------</SerialNumber> </Data> <Signature>------</Signature> </License>
aspose.slides使用https://www.cnblogs.com/baby123/p/10863759.html
注意:此教程及下载文件只允许学习使用,不得用于商业用途,请购买授权正版 apose