Results 1 to 1 of 1
Thread: Certificate is empty
- 05-14-2012, 08:15 AM #1
Member
- Join Date
- May 2012
- Posts
- 1
- Rep Power
- 0
Certificate is empty
Good day, I'm working on Soap Web Service to call from my Web Service an other Web Service. But I have little problem, my inserted certificate is empty. I'm using latest NetBeans and Tomcat. Here is my little code, please help me with this:
Best regards,Java Code:/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package niis.janis; import java.io.*; import java.util.logging.Level; import java.util.logging.Logger; import javax.security.cert.X509Certificate; import javax.servlet.ServletException; import javax.servlet.ServletInputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import niis.wsclient.GetInfoBlock.CadastreInformationBlockRequestStructure; import niis.wsclient.GetInfoBlock.CadastreInformationBlockResponseStructure; import niis.wsclient.GetInfoBlock.GetInfoBlock; /** * * @author Owner */ public class testWS extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet { static final long serialVersionUID = 1L; @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { CadastreInformationBlockRequestStructure req = new CadastreInformationBlockRequestStructure(); req.username = "janis"; req.password = "wtfn00b"; InputStream is = null; X509Certificate cert = null; FileInputStream fos = null; int ch; StringBuilder strContent = new StringBuilder(""); try { File certificate = new File("C:/Users/Owner/Desktop/notartest.notary.lv.p12"); fos = new FileInputStream(certificate); while((ch = fos.read()) != -1){ strContent.append((char)ch); } is = new ByteArrayInputStream(strContent.toString().getBytes()); cert = X509Certificate.getInstance(is); // is 'cert' is null } catch (Exception ex) { Logger.getLogger(testWS.class.getName()).log(Level.SEVERE, null, ex); } finally { if (fos != null) {fos.close();} if (is != null) {is.close();} } CadastreInformationBlockResponseStructure response2 = null; try { GetInfoBlock proxy = new GetInfoBlock(); proxy.Add(cert); response2 = proxy.CadastreInformationBlocks(req); } catch (Exception ex){ Logger.getLogger(testWS.class.getName()).log(Level.SEVERE, null, ex); } //response.getWriter().write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><document xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:String\">"+ response2.getCadastreInformationData() +"</document>"); //response.getWriter().flush(); } protected void doPost(HttpServletRequest request, CadastreInformationBlockResponseStructure response) throws ServletException, IOException { ServletInputStream inStream = request.getInputStream(); String xml_doc="<?xml version=\"1.0\" encoding=\"UTF-8\" ?><document xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xsi:type=\"xs:base64Binary\" content-type=\"application/xls\">Jānis Pekša</document>"; } }
wtfn00b.
Similar Threads
-
Temporarily add CA certificate
By ohm in forum Advanced JavaReplies: 0Last Post: 02-15-2011, 12:07 PM -
Unwrapping a key using a certificate
By alexag in forum New To JavaReplies: 0Last Post: 12-15-2010, 12:40 PM -
CAS certificate issue
By pacificz in forum Advanced JavaReplies: 4Last Post: 07-24-2010, 07:11 PM -
SUN 310-813 certificate
By koko12 in forum Java CertificationReplies: 2Last Post: 11-24-2009, 05:33 PM -
HTTPS using certificate
By MCJP in forum Advanced JavaReplies: 1Last Post: 09-25-2008, 01:48 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks