我正在尝试为服务提供者生成SAML元数据,我创建了简单的servlet并尝试在方法中生成元数据doGet()
这是我在下面尝试的代码
import java.io.IOException;
import java.io.PrintWriter;
import java.net.HttpRetryException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.namespace.QName;
import org.opensaml.Configuration;
import org.opensaml.saml2.metadata.EntityDescriptor;
import org.opensaml.xml.XMLObjectBuilderFactory;
public class MetadataProviderServlet extends HttpServlet{
protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
PrintWriter writer = response.getWriter();
response.setContentType("text/html");
writer.println("Hello world");
String entityId = "www.sampleEntityId.com";
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
EntityDescriptor descriptor = (EntityDescriptor)(builderFactory.getBuilder(EntityDescriptor.DEFAULT_ELEMENT_NAME).buildObject(EntityDescriptor.DEFAULT_ELEMENT_NAME));
descriptor.setEntityID(entityId);
}
}

但是当我使用一个应用程序服务器运行Web应用程序时,我特别创建了NUllpointer异常对象实体描述符。任何人都可以找出出了什么问题?
答案 0 :(得分:0)