0

我必须使用 s/mime 加密 json 数据。

我浏览了这些链接: http ://docs.jboss.org/resteasy/docs/2.3.0.GA/userguide/html/ch38.html

虽然我按照上面提到的链接做,但我无法加密这是我的代码:

 @Path("encrypted")
     @GET
      @Produces("text/plain")

      @GZIP
      public EnvelopedOutput getAllOpenMeetings(@QueryParam("batchsize")
      int batchSize, @QueryParam("offset")
      int offset, @Context
      HttpServletRequest req) {

        String ipAddress = req.getRemoteAddr();


        EnvelopedOutput output=null;
        CustomerBean bean=null;
        try {
           bean=new CustomerBean();
          bean.setDesc("abc");
          bean.setName("xyz");

          //certificate generation
          FileInputStream stream = new FileInputStream("e:/arruun/keystore.jks"); 
//        Security.addProvider(new BouncyCastleProvider());
                KeyStore store = KeyStore.getInstance("JKS");
//        KeyStore store = KeyStore.getInstance("pkcs12", "SunJSSE");
                store.load(stream, "password".toCharArray());

                PrivateKey      key = (PrivateKey)store.getKey(
                                                 "selfsigned", "password".toCharArray());

                Certificate[]   chain = store.getCertificateChain(
                        "selfsigned");
X509Certificate cert = (X509Certificate)chain[0];


          X509V3Generator generator=new X509V3Generator();

           output = new EnvelopedOutput(bean, MediaType.APPLICATION_XML_TYPE);

          output.setCertificate(cert);
          return output;

        }  
        catch (Exception ex) {

            String result = "Error 500 - Internal Server Error";
            System.out.println("exception=="+ex.getMessage());
            return null;
//       
        }


      }

所以请任何人都可以提供一个resteasy加密的小例子(即使用s / mime的json body加密)

4

0 回答 0