从 servlet 访问 FileNet Content Engine
Access FileNet Content Engine from servlet
我正在尝试从 servlet 访问 IBM FileNet P8 V5 数据存储,需要帮助才能正确配置 WebSphere。
我在带有 IBM WebSphere 的 RedHat 7 服务器上全新安装了 FN P8。
我尝试了 https://www.ibm.com/support/knowledgecenter/en/SSNW2F_5.0.0/com.ibm.p8.ce.dev.ce.doc/ss_ecl_cews.htm
上给出的示例代码
从普通的 Java class 可以正常工作;连接到服务器并检索数据存储名称。
我将代码复制到 servlet,但出现错误:
" com.filenet.api.exception.EngineRuntimeException: FNRCS0005E: SECURITY_INVALID_CREDENTIALS: 不允许访问内容引擎,因为内容引擎 API 库或 Web 服务接口 (WSI) 侦听器找不到所需的安全上下文信息. 在安全上下文中找不到预期的凭据"
根据教程,我需要设置运行环境。那就是我被困的地方。我尝试在 JVM 设置中通过 WebSphere 控制台添加 jaas.conf.WebSphere,但显然没有正确地添加。
package server;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.collection.ObjectStoreSet;
import com.filenet.api.core.Connection;
import com.filenet.api.core.Domain;
import com.filenet.api.core.Factory;
import com.filenet.api.core.ObjectStore;
import com.filenet.api.util.UserContext;
/**
* Servlet implementation class FNTest
* Ref: https://www.ibm.com/support/knowledgecenter/en/SSNW2F_5.0.0/com.ibm.p8.ce.dev.ce.doc/ss_ecl_cews.htm
*/
//@WebServlet(description = "Test for connection to Filenet", urlPatterns = { "/FNTest" })
@WebServlet("/FNTest")
public class FNTest extends HttpServlet {
private static final long serialVersionUID = 2L;
/**
* @see HttpServlet#HttpServlet()
*/
public FNTest() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Filenet Function Test</title></head>");
out.println("<body>");
out.println("<h1>Filenet Function Test</h1>");
out.println("<p>Request server at " + request.getServletPath() + ".</p><hr>");
out.println("<p>Connecting to Filenet...</p>");
// Connect to Filenet
// Set connection parameters; substitute for the placeholders.
String uri = "http://filenet.myserver.com:9080/wsi/FNCEWS40MTOM/";
String username = "P8Admin";
String password = "P8Password";
// Make connection.
Connection conn = Factory.Connection.getConnection(uri);
Subject subject = UserContext.createSubject(conn, username, password, null);
UserContext.get().pushSubject(subject);
try
{
// Get default domain.
Domain domain = Factory.Domain.fetchInstance(conn, null, null);
System.out.println("Domain: " + domain.get_Name());
// Get object stores for domain.
ObjectStoreSet osSet = domain.get_ObjectStores();
ObjectStore store;
Iterator osIter = osSet.iterator();
while (osIter.hasNext())
{
store = (ObjectStore) osIter.next();
System.out.println("Object store: " + store.get_Name());
}
System.out.println("Connection to Content Engine successful");
}
finally
{
UserContext.get().popSubject();
}
out.println("<p>Completed</p>");
out.println("</body></html>");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
应用程序与 servlet 安装在同一台服务器上。
我看到您的 jaas 节为空,这意味着它将采用 FileNetP8 作为默认节。尝试使用 FileNetP8WSI 而不是 null,因为您正在使用 WSI 端点进行连接。
Subject subject = UserContext.createSubject(conn, username, password, "FileNetP8WSI");
如果您提供 null 它将使用 "FileNetP8" 这是用于 IIOP 连接的 jaas 节
我正在尝试从 servlet 访问 IBM FileNet P8 V5 数据存储,需要帮助才能正确配置 WebSphere。
我在带有 IBM WebSphere 的 RedHat 7 服务器上全新安装了 FN P8。
我尝试了 https://www.ibm.com/support/knowledgecenter/en/SSNW2F_5.0.0/com.ibm.p8.ce.dev.ce.doc/ss_ecl_cews.htm
上给出的示例代码从普通的 Java class 可以正常工作;连接到服务器并检索数据存储名称。
我将代码复制到 servlet,但出现错误: " com.filenet.api.exception.EngineRuntimeException: FNRCS0005E: SECURITY_INVALID_CREDENTIALS: 不允许访问内容引擎,因为内容引擎 API 库或 Web 服务接口 (WSI) 侦听器找不到所需的安全上下文信息. 在安全上下文中找不到预期的凭据"
根据教程,我需要设置运行环境。那就是我被困的地方。我尝试在 JVM 设置中通过 WebSphere 控制台添加 jaas.conf.WebSphere,但显然没有正确地添加。
package server;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.collection.ObjectStoreSet;
import com.filenet.api.core.Connection;
import com.filenet.api.core.Domain;
import com.filenet.api.core.Factory;
import com.filenet.api.core.ObjectStore;
import com.filenet.api.util.UserContext;
/**
* Servlet implementation class FNTest
* Ref: https://www.ibm.com/support/knowledgecenter/en/SSNW2F_5.0.0/com.ibm.p8.ce.dev.ce.doc/ss_ecl_cews.htm
*/
//@WebServlet(description = "Test for connection to Filenet", urlPatterns = { "/FNTest" })
@WebServlet("/FNTest")
public class FNTest extends HttpServlet {
private static final long serialVersionUID = 2L;
/**
* @see HttpServlet#HttpServlet()
*/
public FNTest() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Filenet Function Test</title></head>");
out.println("<body>");
out.println("<h1>Filenet Function Test</h1>");
out.println("<p>Request server at " + request.getServletPath() + ".</p><hr>");
out.println("<p>Connecting to Filenet...</p>");
// Connect to Filenet
// Set connection parameters; substitute for the placeholders.
String uri = "http://filenet.myserver.com:9080/wsi/FNCEWS40MTOM/";
String username = "P8Admin";
String password = "P8Password";
// Make connection.
Connection conn = Factory.Connection.getConnection(uri);
Subject subject = UserContext.createSubject(conn, username, password, null);
UserContext.get().pushSubject(subject);
try
{
// Get default domain.
Domain domain = Factory.Domain.fetchInstance(conn, null, null);
System.out.println("Domain: " + domain.get_Name());
// Get object stores for domain.
ObjectStoreSet osSet = domain.get_ObjectStores();
ObjectStore store;
Iterator osIter = osSet.iterator();
while (osIter.hasNext())
{
store = (ObjectStore) osIter.next();
System.out.println("Object store: " + store.get_Name());
}
System.out.println("Connection to Content Engine successful");
}
finally
{
UserContext.get().popSubject();
}
out.println("<p>Completed</p>");
out.println("</body></html>");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
应用程序与 servlet 安装在同一台服务器上。
我看到您的 jaas 节为空,这意味着它将采用 FileNetP8 作为默认节。尝试使用 FileNetP8WSI 而不是 null,因为您正在使用 WSI 端点进行连接。
Subject subject = UserContext.createSubject(conn, username, password, "FileNetP8WSI");
如果您提供 null 它将使用 "FileNetP8" 这是用于 IIOP 连接的 jaas 节