莲花笔记中的飞碟

发布于 2024-11-05 22:15:44 字数 3751 浏览 6 评论 0原文

我试图将简单的 XHTML 文件转换为 PDF,并使用 Flying Saucer 和 iText 来完成此操作。它在 Java 中运行没有问题,但是,当我尝试使用相同的代码创建 Lotus Notes 代理时,我遇到了一个异常,我不确定如何处理。

代码:

import lotus.domino.*;
import java.io.*;
import com.lowagie.text.DocumentException;
import org.xhtmlrenderer.pdf.ITextRenderer; 
import org.xhtmlrenderer.util.XRLog;
import java.util.*;

public class JavaAgent extends AgentBase {

    public void NotesMain() {

      try {
        Session session = getSession();
        AgentContext agentContext = session.getAgentContext();
        String received = agentContext.getDocumentContext().
             getItemValueString("Query_String");
        String[] split;
        split = received.split("&");
        String url = split[1];
        split = url.split("/");
        String outputFile = split[split.length-1];
        String direc = session.getEnvironmentString("Directory", true);
        outputFile = direc + "\\" + outputFile + ".pdf"; 
        OutputStream os = new FileOutputStream(outputFile);
        ITextRenderer renderer = new ITextRenderer();
        renderer.setDocument(url);
        renderer.layout();
        renderer.createPDF(os);
        os.close();
        System.exit(0);

      } catch(Exception e) {
        e.printStackTrace();
      }
   }
}

这会产生以下结果:

09-05-2011 13:33:29 HTTP JVM:无法初始化 Flying Saucer 库的配置。消息是:找不到捆绑包 java.util.PropertyResourceBundle 的资源,密钥 access_properties_not_allowed

09-05-2011 13:33:29 HTTP JVM:java.util.MissingResourceException:找不到捆绑包 java.util.PropertyResourceBundle 的资源,密钥 access_properties_not_allowed

09-05-2011 13:33:29 HTTP JVM:位于 java.util.MissingResourceException。(MissingResourceException.java:50)

09-05-2011 13:33:29 HTTP JVM:位于 java.util.ResourceBundle.getObject(ResourceBundle.java:400)

09-05-2011 13:33:29 HTTP JVM:位于 java.util.ResourceBundle.getString(ResourceBundle.java:421)

09-05-2011 13:33:29 HTTP JVM:位于lotus.notes.JavaString.getString(来源未知)

09-05-2011 13:33:29 HTTP JVM:位于lotus.notes.AgentSecurityManager.checkPropertiesAccess(来源未知)

09-05-2011 13:33:30 HTTP JVM:位于 java.lang.System.getProperties(System.java:323)

09-05-2011 13:33:30 HTTP JVM:位于 org.xhtmlrenderer.util.Configuration.loadSystemProperties(Configuration.java:419)

09-05-2011 13:33:30 HTTP JVM:位于 org.xhtmlrenderer.util.Configuration.(Configuration.java:147)

09-05-2011 13:33:30 HTTP JVM:位于 org.xhtmlrenderer.util.Configuration.instance(Configuration.java:742)

09-05-2011 13:33:31 HTTP JVM:位于 org.xhtmlrenderer.util.Configuration.valueFor(Configuration.java:463)

09-05-2011 13:33:31 HTTP JVM:位于 org.xhtmlrenderer.util.Configuration.isTrue(Configuration.java:709)

09-05-2011 13:33:31 HTTP JVM:位于 org.xhtmlrenderer.util.XRLog.init(XRLog.java:250)

09-05-2011 13:33:31 HTTP JVM:位于 org.xhtmlrenderer.util.XRLog.log(XRLog.java:203)

09-05-2011 13:33:31 HTTP JVM:位于 org.xhtmlrenderer.util.XRLog.render(XRLog.java:194)

09-05-2011 13:33:31 HTTP JVM:位于 org.xhtmlrenderer.util.XRLog.render(XRLog.java:190)

09-05-2011 13:33:31 HTTP JVM:位于 org.xhtmlrenderer.layout.SharedContext.(SharedContext.java:107)

09-05-2011 13:33:31 HTTP JVM:位于 org.xhtmlrenderer.pdf.ITextRenderer.(ITextRenderer.java:111)

09-05-2011 13:33:31 HTTP JVM:位于 org.xhtmlrenderer.pdf.ITextRenderer.(ITextRenderer.java:102)

09-05-2011 13:33:31 HTTP JVM:位于 JavaAgent.NotesMain(来源未知)

09-05-2011 13:33:31 HTTP JVM:位于lotus.domino.AgentBase.runNotes(来源未知)

09-05-2011 13:33:31 HTTP JVM:位于lotus.domino.NotesThread.run(来源未知)

违规行是

ITextRenderer renderer = new ITextRenderer();

谷歌搜索“access_properties_not_allowed”字面意思没有什么。

I was trying to convert simple XHTML-files to PDF, and used Flying Saucer and iText to do so. It worked without problems in Java, however, when I tried to make a Lotus Notes agent with the same code, I got an exception I am unsure how to deal with.

The code:

import lotus.domino.*;
import java.io.*;
import com.lowagie.text.DocumentException;
import org.xhtmlrenderer.pdf.ITextRenderer; 
import org.xhtmlrenderer.util.XRLog;
import java.util.*;

public class JavaAgent extends AgentBase {

    public void NotesMain() {

      try {
        Session session = getSession();
        AgentContext agentContext = session.getAgentContext();
        String received = agentContext.getDocumentContext().
             getItemValueString("Query_String");
        String[] split;
        split = received.split("&");
        String url = split[1];
        split = url.split("/");
        String outputFile = split[split.length-1];
        String direc = session.getEnvironmentString("Directory", true);
        outputFile = direc + "\\" + outputFile + ".pdf"; 
        OutputStream os = new FileOutputStream(outputFile);
        ITextRenderer renderer = new ITextRenderer();
        renderer.setDocument(url);
        renderer.layout();
        renderer.createPDF(os);
        os.close();
        System.exit(0);

      } catch(Exception e) {
        e.printStackTrace();
      }
   }
}

This yields the following:

09-05-2011 13:33:29 HTTP JVM: Could not initialize configuration for Flying Saucer library. Message is: Can't find resource for bundle java.util.PropertyResourceBundle, key access_properties_not_allowed

09-05-2011 13:33:29 HTTP JVM: java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key access_properties_not_allowed

09-05-2011 13:33:29 HTTP JVM: at java.util.MissingResourceException.(MissingResourceException.java:50)

09-05-2011 13:33:29 HTTP JVM: at java.util.ResourceBundle.getObject(ResourceBundle.java:400)

09-05-2011 13:33:29 HTTP JVM: at java.util.ResourceBundle.getString(ResourceBundle.java:421)

09-05-2011 13:33:29 HTTP JVM: at lotus.notes.JavaString.getString(Unknown Source)

09-05-2011 13:33:29 HTTP JVM: at lotus.notes.AgentSecurityManager.checkPropertiesAccess(Unknown Source)

09-05-2011 13:33:30 HTTP JVM: at java.lang.System.getProperties(System.java:323)

09-05-2011 13:33:30 HTTP JVM: at org.xhtmlrenderer.util.Configuration.loadSystemProperties(Configuration.java:419)

09-05-2011 13:33:30 HTTP JVM: at org.xhtmlrenderer.util.Configuration.(Configuration.java:147)

09-05-2011 13:33:30 HTTP JVM: at org.xhtmlrenderer.util.Configuration.instance(Configuration.java:742)

09-05-2011 13:33:31 HTTP JVM: at org.xhtmlrenderer.util.Configuration.valueFor(Configuration.java:463)

09-05-2011 13:33:31 HTTP JVM: at org.xhtmlrenderer.util.Configuration.isTrue(Configuration.java:709)

09-05-2011 13:33:31 HTTP JVM: at org.xhtmlrenderer.util.XRLog.init(XRLog.java:250)

09-05-2011 13:33:31 HTTP JVM: at org.xhtmlrenderer.util.XRLog.log(XRLog.java:203)

09-05-2011 13:33:31 HTTP JVM: at org.xhtmlrenderer.util.XRLog.render(XRLog.java:194)

09-05-2011 13:33:31 HTTP JVM: at org.xhtmlrenderer.util.XRLog.render(XRLog.java:190)

09-05-2011 13:33:31 HTTP JVM: at org.xhtmlrenderer.layout.SharedContext.(SharedContext.java:107)

09-05-2011 13:33:31 HTTP JVM: at org.xhtmlrenderer.pdf.ITextRenderer.(ITextRenderer.java:111)

09-05-2011 13:33:31 HTTP JVM: at org.xhtmlrenderer.pdf.ITextRenderer.(ITextRenderer.java:102)

09-05-2011 13:33:31 HTTP JVM: at JavaAgent.NotesMain(Unknown Source)

09-05-2011 13:33:31 HTTP JVM: at lotus.domino.AgentBase.runNotes(Unknown Source)

09-05-2011 13:33:31 HTTP JVM: at lotus.domino.NotesThread.run(Unknown Source)

The offending line is

ITextRenderer renderer = new ITextRenderer();

Googling "access_properties_not_allowed" gives literally nothing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冧九 2024-11-12 22:15:44

1) Notes/Domino 中的代理在代理属性中具有附加的安全功能,用于设置代理的安全级别。默认情况下,此设置设置为不允许受限操作(默认设置为“不允许受限操作”)。

为了使代理运行该属性,必须将其设置为以下选项之一:

“允许受限操作”
“允许具有完全管理权限的受限操作”

该属性位于“代理属性”对话框的第二个选项卡(密钥选项卡)上。

2) 正如“road to yamburg”已经解释的那样,JVM 的安全管理器不允许访问系统的属性,因为安全策略未指定允许此操作。
您必须更改 Java 虚拟机 (JVM) 的安全策略才能允许访问系统属性。为此,您可以添加“permission java.security.AllPermission;”行到 Notes/Domino 目录中的“/jvm/lib/security/java.policy”文件。

进行更改后,java.policy 文件将与此类似:

grant { 
    permission java.security.AllPermission;
    permission java.util.PropertyPermission "java.version", "read";
    permission java.util.PropertyPermission "java.vendor", "read";
    permission java.util.PropertyPermission "java.vendor.url", "read";
    permission java.util.PropertyPermission "java.class.version", "read";
    permission java.util.PropertyPermission "os.name", "read";
        // ... and so on ...
}

重新启动客户端/服务器后,任何需要访问 System.getProperties() 的 Java 程序现在都将被授予访问权限。

1) Agents in Notes/Domino have an additional security feature in the Agent properties that sets the security level of the agent. By default, this setting is set to not allow restricted operations (the default setting is "Do not allow restricted operations").

In order for the agent to run the property it must be set to one of the following options:

"Allow restricted operations"
"Allow restricted operations with full administration rights"

The property is found on the second tab, the key tab, of the Agent Properties dialog box.

2) As "road to yamburg" already explained, the JVM's Security Manager is not allowing access to the system's properties because the security policy does not specify to allow this action.
You must change the security policy of the Java Virtual Machine (JVM) in order to allow access to the system properties. To do this, you can add the line "permission java.security.AllPermission;" to the "/jvm/lib/security/java.policy" file in the Notes/Domino directory.

The java.policy file will look similar to this after making the change:

grant { 
    permission java.security.AllPermission;
    permission java.util.PropertyPermission "java.version", "read";
    permission java.util.PropertyPermission "java.vendor", "read";
    permission java.util.PropertyPermission "java.vendor.url", "read";
    permission java.util.PropertyPermission "java.class.version", "read";
    permission java.util.PropertyPermission "os.name", "read";
        // ... and so on ...
}

Once the client/server is restarted, any Java program requiring access to System.getProperties() will now be granted access.

各自安好 2024-11-12 22:15:44

这可能是安全配置:

XhtmlRenderer 尝试从系统属性中读取其配置:

09-05-2011 13:33:30 HTTP JVM: at java.lang.System.getProperties(System.java:323)
09-05-2011 13:33:30 HTTP JVM: at org.xhtmlrenderer.util.Configuration.loadSystemProperties(Configuration.java:419)

但不允许(SecurityManager),

09-05-2011 13:33:29 HTTP JVM: at lotus.notes.AgentSecurityManager.checkPropertiesAccess(Unknown Source)

必须抛出异常,捕获异常并需要生成错误消息。该错误消息必须从资源包加载,但找不到该资源包。

09-05-2011 13:33:29 HTTP JVM: Could not initialize configuration for Flying Saucer library. Message is: Can't find resource for bundle java.util.PropertyResourceBundle, key access_properties_not_allowed

解决方案:

  • 尝试找到 Lotus Domino JVM 的安全属性(不知道它们可能在或应该在哪里),并让代码读取系统属性

或者

  • 对 org.xhtmlrenderer 包进行补丁以捕获安全异常并进行处理他们自己的。

This is likely the security configuration:

XhtmlRenderer tries to read its configuration from System properties:

09-05-2011 13:33:30 HTTP JVM: at java.lang.System.getProperties(System.java:323)
09-05-2011 13:33:30 HTTP JVM: at org.xhtmlrenderer.util.Configuration.loadSystemProperties(Configuration.java:419)

But it is not allowed (SecurityManager),

09-05-2011 13:33:29 HTTP JVM: at lotus.notes.AgentSecurityManager.checkPropertiesAccess(Unknown Source)

There must be an exception thrown, caught and an error message needs to be produced. That error message have to be loaded from a resource bundle, but the bundle is not found.

09-05-2011 13:33:29 HTTP JVM: Could not initialize configuration for Flying Saucer library. Message is: Can't find resource for bundle java.util.PropertyResourceBundle, key access_properties_not_allowed

Solution:

  • Try to find security properties for Lotus Domino JVM (don't know where they may be or should be), and let the code to read system properties

Or

  • Make a patch to org.xhtmlrenderer package to catch security exceptions and handle them on their own.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文