Changeset 962f860 in murachi
- Timestamp:
- May 8, 2015, 12:27:39 PM (9 years ago)
- Branches:
- master
- Children:
- 4ac0cf4
- Parents:
- 7c45d87
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
murachi/src/main/java/ve/gob/cenditel/murachi/MurachiRESTWS.java
r7c45d87 r962f860 528 528 * @throws GeneralSecurityException falla en 529 529 * @throws IOException cuando ca 530 */ 531 public HashMap<String, String> verifySignature(AcroFields fields, String name) throws GeneralSecurityException, IOException { 530 * @throws MurachiException 531 */ 532 public HashMap<String, String> verifySignature(AcroFields fields, String name) throws GeneralSecurityException, IOException, MurachiException { 532 533 533 534 HashMap<String, String> integrityMap = new HashMap<String, String>(); … … 660 661 * de firmas 661 662 * @return KeyStore con certificados confiables 662 */ 663 private KeyStore setupKeyStore() { 663 * @throws MurachiException 664 */ 665 private KeyStore setupKeyStore() throws MurachiException { 664 666 665 667 KeyStore ks = null; … … 674 676 675 677 676 } catch (KeyStoreException e) { 677 // TODO Auto-generated catch block678 e.printStackTrace();678 } catch (KeyStoreException e) { 679 e.printStackTrace(); 680 throw new MurachiException(e.getMessage()); 679 681 } catch (NoSuchAlgorithmException e) { 680 // TODO Auto-generated catch block681 e.printStackTrace();682 e.printStackTrace(); 683 throw new MurachiException(e.getMessage()); 682 684 } catch (CertificateException e) { 683 // TODO Auto-generated catch block684 e.printStackTrace();685 e.printStackTrace(); 686 throw new MurachiException(e.getMessage()); 685 687 } catch (IOException e) { 686 // TODO Auto-generated catch block687 e.printStackTrace();688 e.printStackTrace(); 689 throw new MurachiException(e.getMessage()); 688 690 } 689 691 return ks; … … 760 762 * @param req objeto request para crear una sesion y mantener elementos del 761 763 * pdf en la misma. 764 * @throws MurachiException 762 765 * 763 766 */ … … 767 770 @Produces(MediaType.APPLICATION_JSON) 768 771 //public PresignHash presignPdf(PresignParameters presignPar, @Context HttpServletRequest req) { 769 public Response presignPdf(PresignParameters presignPar, @Context HttpServletRequest req) { 770 771 String result = null; 772 public Response presignPdf(PresignParameters presignPar, @Context HttpServletRequest req) throws MurachiException { 772 773 773 774 PresignHash presignHash = new PresignHash(); … … 919 920 920 921 } catch (CertificateException e1) { 921 // TODO Auto-generated catch block922 922 e1.printStackTrace(); 923 throw new MurachiException(e1.getMessage()); 923 924 } catch (InvalidPdfException e) { 924 // TODO Auto-generated catch block925 925 e.printStackTrace(); 926 926 presignHash.setError("No se pudo leer el archivo PDF en el servidor"); 927 throw new MurachiException(e.getMessage()); 927 928 } catch (IOException e) { 928 // TODO Auto-generated catch block 929 e.printStackTrace(); 930 931 929 e.printStackTrace(); 930 throw new MurachiException(e.getMessage()); 932 931 } catch (DocumentException e) { 933 // TODO Auto-generated catch block934 e.printStackTrace();932 e.printStackTrace(); 933 throw new MurachiException(e.getMessage()); 935 934 } catch (InvalidKeyException e) { 936 // TODO Auto-generated catch block937 e.printStackTrace();935 e.printStackTrace(); 936 throw new MurachiException(e.getMessage()); 938 937 } catch (NoSuchProviderException e) { 939 // TODO Auto-generated catch block940 e.printStackTrace();938 e.printStackTrace(); 939 throw new MurachiException(e.getMessage()); 941 940 } catch (NoSuchAlgorithmException e) { 942 // TODO Auto-generated catch block943 e.printStackTrace();941 e.printStackTrace(); 942 throw new MurachiException(e.getMessage()); 944 943 } catch (GeneralSecurityException e) { 945 // TODO Auto-generated catch block946 e.printStackTrace();944 e.printStackTrace(); 945 throw new MurachiException(e.getMessage()); 947 946 } 948 947 … … 992 991 * pdf en la misma. 993 992 * @throws IOException 993 * @throws MurachiException 994 994 */ 995 995 @POST … … 997 997 @Consumes(MediaType.APPLICATION_JSON) 998 998 @Produces(MediaType.APPLICATION_JSON) 999 public Response postsignPdf(PostsignParameters postsignPar, @Context HttpServletRequest req) throws IOException { 1000 1001 1002 // cadena resultado de la funcion 1003 String result = ""; 999 public Response postsignPdf(PostsignParameters postsignPar, @Context HttpServletRequest req) throws IOException, MurachiException { 1000 1004 1001 1005 1002 // cadena con la firma … … 1026 1023 if (sgn == null) { 1027 1024 System.out.println("sgn == null"); 1025 throw new MurachiException("Error en completacion de firma: estructura PdfPKCS7 nula"); 1028 1026 } 1029 1027 if (hash == null) { 1030 1028 System.out.println("hash == null"); 1029 throw new MurachiException("Error en completacion de firma: hash nulo"); 1031 1030 } 1032 1031 if (cal == null) { 1033 1032 System.out.println("cal == null"); 1033 throw new MurachiException("Error en completacion de firma: estructura de fecha nula"); 1034 1034 } 1035 1035 if (sap == null) { 1036 1036 System.out.println("sap == null"); 1037 throw new MurachiException("Error en completacion de firma: estructura de apariencia de firma pdf nula"); 1037 1038 } 1038 1039 if (os == null) { 1039 1040 System.out.println("os == null"); 1040 }1041 1042 1043 1041 throw new MurachiException("Error en completacion de firma: bytes de archivo nulos"); 1042 } 1043 1044 System.out.println("antes de hexStringToByteArray(signature)"); 1044 1045 // convertir signature en bytes 1045 1046 byte[] signatureInBytes = hexStringToByteArray(signature); … … 1052 1053 PdfDictionary dic2 = new PdfDictionary(); 1053 1054 dic2.put(PdfName.CONTENTS, new PdfString(paddedSig).setHexWriting(true)); 1055 1054 1056 try { 1055 sap.close(dic2); 1056 1057 sap.close(dic2); 1057 1058 stamper.close(); 1058 1059 System.out.println("stamper.close"); 1059 1060 1060 1061 }catch(DocumentException e) { 1061 1062 1062 System.out.println("throw new IOException"); 1063 throw new IOException(e);1063 throw new MurachiException(e.getMessage()); 1064 1064 1065 1065 } catch (IOException e) { 1066 // TODO Auto-generated catch block1067 1066 System.out.println("IOException e"); 1068 1067 e.printStackTrace(); 1068 throw new MurachiException(e.getMessage()); 1069 1069 1070 1070 } … … 1076 1076 os.writeTo(signedFile); 1077 1077 os.flush(); 1078 1079 1080 1078 1081 1079 // en este punto el archivo pdf debe estar disponible en la ruta 1082 // SERVER_UPLOAD_LOCATION_FOLDER + fileId; 1083 1084 // llamar a una funcion que permita descargar el archivo 1085 1086 result = "Archivo firmado correctamente"; 1080 // SERVER_UPLOAD_LOCATION_FOLDER + fileId; 1087 1081 System.out.println("Archivo firmado correctamente"); 1088 1089 1082 1090 1083 PostsignMessage message = new PostsignMessage(); 1091 1084 //message.setMessage(SERVER_UPLOAD_LOCATION_FOLDER + fileId + "-signed.pdf"); 1092 message.setMessage(fileId + "-signed.pdf"); 1093 return Response.status(200).entity(message).build(); 1085 message.setMessage("{\"signedFile\":"+fileId + "-signed.pdf}"); 1086 //return Response.status(200).entity(message).build(); 1087 1088 JSONObject jsonFinalResult = new JSONObject(); 1089 jsonFinalResult.put("signedFileId",fileId + "-signed.pdf"); 1090 return Response.status(200).entity(jsonFinalResult.toString()).build(); 1094 1091 } 1095 1092 … … 1195 1192 } 1196 1193 1197 jsonSignatures.put("signatures", jsonSignaturesArray); 1198 1194 jsonSignatures.put("signatures", jsonSignaturesArray); 1199 1195 System.out.println(jsonSignatures.toString()); 1200 } 1201 1202 1196 } 1203 1197 } 1204 1198 //verifyBdocContainer(container);
Note: See TracChangeset
for help on using the changeset viewer.