• aspose.slides for java去除水印


    原文: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

  • 相关阅读:
    Win7电脑无法安全删除硬件并弹出媒体的解决方法
    Linux环境变量及其设置
    Linux环境变量文件environment, profile, bashrc含义
    Linux下设置和查看环境变量
    [Android Traffic] 让android应用在传输网络数据的时候更省电
    [Android Traffic] 看无线电波如何影响网络操作]
    [Android Pro] Android的5个进程等级
    [编码解码] Base64 编码换行和+号遍空格的处理
    [Android Traffic] Android网络开启、关闭整理
    [Android Traffic] android 流量计算方法
  • 原文地址:https://www.cnblogs.com/shihaiming/p/13024600.html
Copyright © 2020-2023  润新知