Changeset 647bb1f in dispositivos_moviles


Ignore:
Timestamp:
Oct 24, 2013, 10:29:58 AM (11 years ago)
Author:
Antonio Araujo Brett <aaraujo@…>
Branches:
master
Children:
e68708b
Parents:
8fcfbf1
Message:

*- Agregado soporte para descrifrar un documento cifrado al seleccionarlo desde el sistema de archivo del móvil.

Location:
TibisayMovil
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • TibisayMovil/AndroidManifest.xml

    rc874484 r647bb1f  
    189189            android:name="ve.gob.cenditel.tibisaymovil.PKCS12ToDecryptActivity"
    190190            android:label="@string/title_activity_pkcs12_to_decrypt" >
     191           
     192            <intent-filter>
     193                <action android:name="android.intent.action.VIEW" />
     194
     195                <category android:name="android.intent.category.DEFAULT" />
     196
     197                <data android:scheme="file" />
     198                <data android:mimeType="*/*" />
     199                <data android:host="*" />
     200                <data android:pathPattern=".*\\.cdoc" />
     201            </intent-filter>
     202            <intent-filter>
     203                <action android:name="android.intent.action.VIEW" />
     204
     205                <category android:name="android.intent.category.DEFAULT" />
     206
     207                <data android:scheme="file" />
     208                <data android:mimeType="*/*" />
     209                <data android:host="*" />
     210                <data android:pathPattern=".*\\..*\\.cdoc" />
     211            </intent-filter>
     212           
    191213        </activity>
    192214        <activity
  • TibisayMovil/res/values/strings.xml

    rc874484 r647bb1f  
    171171    <string name="title_activity_file_to_decrypt">FileToDecryptActivity</string>
    172172    <string name="decrypt_description">Seleccione el archivo a descifrar</string>
    173     <string name="title_activity_pkcs12_to_decrypt">PKCS12ToDecryptActivity</string>
     173    <string name="title_activity_pkcs12_to_decrypt">Tibisay Móvil</string>
    174174    <string name="pkcs12_to_decrypt_description">Seleccione el archivo .p12 que protege su clave</string>
    175175    <string name="decrypted_dir_files">DecryptedFiles</string>
     
    183183   
    184184   
     185   
    185186</resources>
  • TibisayMovil/src/ve/gob/cenditel/tibisaymovil/PKCS12ToDecryptActivity.java

    rfd4a5b9 r647bb1f  
    116116               
    117117               
    118                 //Capturando archivo original que se debe descifrar
    119                 fileToDecrypt = getIntent().getExtras().getString("fileToDecrypt");
    120 
    121 
     118                // chequear si intent tiene data
     119        final android.content.Intent intent = getIntent();
     120        final android.net.Uri data = intent.getData();
     121     
     122       
     123        if (data != null) {
     124                // verificar el tipo de scheme
     125            String scheme = data.getScheme();
     126           
     127            // descifrar un archivo que esta en el dispositivo
     128            if (scheme.equals("file")) {
     129                Log.d("PKCS12ToDecryptActivity: ", "scheme == file");
     130                Toast.makeText(getApplicationContext(), "Descifrar archivo: "+data.getPath(), Toast.LENGTH_SHORT).show();
     131         
     132                // obtener archivo a descifrar
     133                          if (data.getPath().endsWith("cdoc")){
     134                                  fileToDecrypt = data.getPath();
     135                                 
     136                                 
     137                                        }else{
     138                                                Toast.makeText(getApplicationContext(), "¡Intentando descifrar un archivo distinto de .cdoc!", Toast.LENGTH_SHORT).show();
     139                                                Log.d("PKCS12ToDecryptActivity: ", "¡Intentando descifrar un archivo distinto de .cdoc!");
     140                                                finish();
     141                                        }               
     142            }
     143        }else{
     144       
     145                final Bundle bundle = getIntent().getExtras();
     146                // verificacion de archivo desde la Activity principal
     147                if (bundle != null) {
     148                        Log.d("PKCS12ToDecryptActivity: ", "bundle != null");
     149                        // Capturando archivo original que se debe descifrar
     150                        fileToDecrypt = getIntent().getExtras().getString("fileToDecrypt");
     151                }
     152       
     153        }
     154            //Capturando archivo original que se debe descifrar
     155        //fileToDecrypt = getIntent().getExtras().getString("fileToDecrypt");
     156           
    122157        }
    123158
     
    691726                        Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_SHORT).show();
    692727                       
    693                         showDialog("Error:", ex.getMessage());
     728                        showDialog("Error:", ex.getMessage(), false);
    694729                        return;
    695730                }
     
    730765                        // el pasword del PKCS12 no es correcto
    731766                        showDialog(getResources().getString(R.string.msg_encryption_error),
    732                                         "password incorrecto");
     767                                        "password incorrecto", false);
    733768                        return;
    734769                }
    735                 showDialog(getResources().getString(R.string.msg_encryption_error), ex.getMessage());
     770                showDialog(getResources().getString(R.string.msg_encryption_error), ex.getMessage(), false);
    736771                        return;
    737772               
    738773                } catch(ArrayIndexOutOfBoundsException ex) {
    739774                        showDialog(getResources().getString(R.string.msg_encryption_error),
    740                                         getResources().getString(R.string.error_decrypting_file_index_out_of_bounds));
     775                                        getResources().getString(R.string.error_decrypting_file_index_out_of_bounds), false);
    741776                        return;
    742777                }
     
    798833                System.err.println("DataFile has no data!");
    799834                showDialog(getResources().getString(R.string.msg_encryption_error),
    800                                 "DataFile has no data!");
     835                                "DataFile has no data!", false);
    801836                return;
    802837            }
     
    817852            Toast.makeText(getApplicationContext(), "Descifrado correctamente: " + decryptedFile, Toast.LENGTH_SHORT).show();
    818853               
    819             showDialog("Información:", "Archivo descifrado exitosamente.");
     854            showDialog("Información:", "Archivo descifrado exitosamente.", true);
    820855           
    821856            // TODO lanzar la actividad para mostrar el resultado del cifrado
     
    827862                       
    828863                        showDialog(getResources().getString(R.string.msg_encryption_error),
    829                                         e.getMessage());
     864                                        e.getMessage(), false);
    830865                        return;
    831866                }
     
    833868                catch (FileNotFoundException e) {
    834869                        showDialog(getResources().getString(R.string.msg_encryption_error),
    835                                         e.getMessage());
     870                                        e.getMessage(), false);
    836871                        return;
    837872                } catch (IOException e) {
    838873                        showDialog(getResources().getString(R.string.msg_encryption_error),
    839                                         e.getMessage());
     874                                        e.getMessage(), false);
    840875                        return;
    841876                }
     
    852887     * @return void
    853888     */
    854     public void showDialog(String title, String msg) {
     889    public void showDialog(String title, String msg, final boolean success) {
    855890       
    856891        // 1. Instantiate an AlertDialog.Builder with its constructor
     
    868903               
    869904                // TODO lanzar la actividad para mostrar el resultado del cifrado
    870                 showDecryptionResults(fileToDecrypt, decryptedFile);
     905                if (success){
     906                        showDecryptionResults(fileToDecrypt, decryptedFile);
     907                }
    871908            }
    872909                });
Note: See TracChangeset for help on using the changeset viewer.