1 | package ve.gob.cenditel.tibisaymovil; |
---|
2 | |
---|
3 | import java.io.File; |
---|
4 | import java.io.FileInputStream; |
---|
5 | import java.io.FileNotFoundException; |
---|
6 | import java.io.FileOutputStream; |
---|
7 | import java.io.IOException; |
---|
8 | import java.io.InputStream; |
---|
9 | import java.io.OutputStream; |
---|
10 | import java.nio.channels.FileChannel; |
---|
11 | import java.util.ArrayList; |
---|
12 | import java.util.Collection; |
---|
13 | |
---|
14 | import ee.sk.digidoc.DigiDocException; |
---|
15 | |
---|
16 | import android.content.Context; |
---|
17 | import android.net.Uri; |
---|
18 | import android.os.Environment; |
---|
19 | import android.os.StatFs; |
---|
20 | import android.text.format.DateFormat; |
---|
21 | import android.util.Log; |
---|
22 | |
---|
23 | /** |
---|
24 | * Clase para utilidades sobre contenedores BDOC |
---|
25 | * |
---|
26 | * |
---|
27 | */ |
---|
28 | |
---|
29 | public class BDOCUtils { |
---|
30 | |
---|
31 | |
---|
32 | public BDOCUtils() {} |
---|
33 | |
---|
34 | |
---|
35 | public static String translateErrors(ArrayList list) { |
---|
36 | |
---|
37 | String errorList = ""; |
---|
38 | |
---|
39 | for (int i = 0; i < list.size(); i++) { |
---|
40 | if ( ((DigiDocException) list.get(i)).getCode() == 82) { |
---|
41 | errorList = errorList.concat("El certificado firmante expiró"); |
---|
42 | } |
---|
43 | } |
---|
44 | return errorList; |
---|
45 | } |
---|
46 | |
---|
47 | // funcion para traducir el codigo de error al verificar una firma electronica |
---|
48 | public static String translateError(int codeError) { |
---|
49 | |
---|
50 | String stringError = ""; |
---|
51 | |
---|
52 | if ( codeError == 38) |
---|
53 | stringError = stringError.concat("Error interno: No se encontró el valor de la firma."); |
---|
54 | if ( codeError == 39) |
---|
55 | stringError = stringError.concat("El certificado del firmante no existe."); |
---|
56 | if ( codeError == 53) |
---|
57 | stringError = stringError.concat("No se encontró el certificado del servidor OCSP."); |
---|
58 | if ( codeError == 70) |
---|
59 | stringError = stringError.concat("Error interno: sólo se soporta un servidor OCSP. Servidor OCSP inválido."); |
---|
60 | if ( codeError == 78) |
---|
61 | stringError = stringError.concat("Error interno: no hay elemento de referencia para uno de los archivos firmados."); |
---|
62 | if ( codeError == 79) |
---|
63 | stringError = stringError.concat("Error interno: el valor de la reseña (hash) es incorrecto."); |
---|
64 | if ( codeError == 80) |
---|
65 | stringError = stringError.concat("Error interno: no hay elemento de referencia para bloque SignedProperties de la firma."); |
---|
66 | if ( codeError == 81) |
---|
67 | stringError = stringError.concat("El certificado del firmante es inválido o no existe."); |
---|
68 | if ( codeError == 82) |
---|
69 | stringError = stringError.concat("El certificado del firmante expiró."); |
---|
70 | if ( codeError == 83) |
---|
71 | stringError = stringError.concat("Error interno: el valor del OCSP está vacío"); |
---|
72 | if ( codeError == 90) |
---|
73 | stringError = stringError.concat("La firma no tiene confirmación OCSP."); |
---|
74 | if ( codeError == 94) |
---|
75 | stringError = stringError.concat("El certificado firmante no ha sido firmado por una AC raíz conocida."); |
---|
76 | if ( codeError == 129) |
---|
77 | stringError = stringError.concat("Se está usando un algoritmo de reseña (hash) considerado débil."); |
---|
78 | if ( codeError ==162) |
---|
79 | stringError = stringError.concat("El certificado del firmante no posee el bit de no repudio."); |
---|
80 | |
---|
81 | return stringError; |
---|
82 | } |
---|
83 | |
---|
84 | } |
---|
85 | |
---|
86 | |
---|
87 | |
---|