莲花笔记中的飞碟 [英] Flying Saucer in Lotus Notes

查看:171
本文介绍了莲花笔记中的飞碟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将简单的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。*;

公共类JavaAgent扩展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(例外e){
e.printStackTrace();
}
}
}

这会产生以下结果:


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



09-05-2011 13:33:29 HTTP JVM:java.util。 MissingResourceException:找不到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:在java.lang.System.getProper中tie(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:在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(未知来源)



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



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


违规行是

  ITextRenderer renderer = new ITextRenderer(); 

Google搜索access_properties_not_allowed几乎没有任何内容。

解决方案

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



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



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



该属性位于代理属性对话框的第二个选项卡(关键选项卡)上。



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



java.policy文件在生成之后看起来与此类似更改:

 授予{
权限java.security.AllPermission;
权限java.util.PropertyPermissionjava.version,read;
权限java.util.PropertyPermissionjava.vendor,read;
permission java.util.PropertyPermissionjava.vendor.url,read;
权限java.util.PropertyPermissionjava.class.version,read;
permission java.util.PropertyPermissionos.name,read;
// ......依此类推...
}

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


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.

解决方案

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.

这篇关于莲花笔记中的飞碟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆