javacommons/security/javasrc/com/nokia/mj/impl/security/utils/SecurityErrorMessage.java
branchRCL_3
changeset 60 6c158198356e
parent 19 04becd199f91
child 83 26b2b12093af
equal deleted inserted replaced
59:e5618cc85d74 60:6c158198356e
    21 import com.nokia.mj.impl.utils.ResourceLoader;
    21 import com.nokia.mj.impl.utils.ResourceLoader;
    22 import java.util.Hashtable;
    22 import java.util.Hashtable;
    23 
    23 
    24 /**
    24 /**
    25  * Class defining Security short error messages.
    25  * Class defining Security short error messages.
    26  *
       
    27  * @author Nokia Corporation
       
    28  * @version 1.0
       
    29  */
    26  */
    30 public final class SecurityErrorMessage extends ErrorMessageBase
    27 public final class SecurityErrorMessage extends ErrorMessageBase
    31 {
    28 {
    32     // Security error codes.
    29     // Security error codes.
    33     public static final int JAR_TAMPERED = 1;
    30     public static final int JAR_TAMPERED = 1 + ErrorMessageBase.SECURITY_RANGE_START;
    34     public static final int CERT_NOT_AVAILABLE = 2;
    31     public static final int CERT_NOT_AVAILABLE = 2 + ErrorMessageBase.SECURITY_RANGE_START;
    35     public static final int UNEXPECTED_ERR = 3;
    32     public static final int UNEXPECTED_ERR = 3 + ErrorMessageBase.SECURITY_RANGE_START;
    36     public static final int NETWORK_RESTRICTION_VIOLATION = 4;
    33     public static final int NETWORK_RESTRICTION_VIOLATION = 4 + ErrorMessageBase.SECURITY_RANGE_START;
    37     public static final int OCSP_GENERAL_ERR = 5;
    34     public static final int OCSP_GENERAL_ERR = 5 + ErrorMessageBase.SECURITY_RANGE_START;
       
    35     public static final int JAR_NOT_FOUND = 6 + ErrorMessageBase.SECURITY_RANGE_START;
    38 
    36 
    39     /*** ----------------------------- PUBLIC ------------------------------ */
    37     /*** ----------------------------- PUBLIC ------------------------------ */
    40     /*** ---------------------------- PROTECTED --------------------------- */
    38     /*** ---------------------------- PROTECTED --------------------------- */
    41 
    39 
    42     /**
    40     /**
    49         if (iMessageTable != null)
    47         if (iMessageTable != null)
    50         {
    48         {
    51             return iMessageTable;
    49             return iMessageTable;
    52         }
    50         }
    53         Hashtable messageTable = new Hashtable();
    51         Hashtable messageTable = new Hashtable();
    54         messageTable.put(new Integer(JAR_TAMPERED), "jar_tampered");
    52         if (getLocaleIdQt() == null)
    55         messageTable.put(new Integer(CERT_NOT_AVAILABLE), "cert_not_available");
    53         {
    56         messageTable.put(new Integer(UNEXPECTED_ERR), "unexpected_err");
    54             messageTable.put(new Integer(JAR_TAMPERED), "jar_tampered");
    57         messageTable.put(new Integer(NETWORK_RESTRICTION_VIOLATION), "net_restr_violation");
    55             messageTable.put(new Integer(CERT_NOT_AVAILABLE), "cert_not_available");
    58         messageTable.put(new Integer(OCSP_GENERAL_ERR), "ocsp_general");
    56             messageTable.put(new Integer(UNEXPECTED_ERR), "unexpected_err");
       
    57             messageTable.put(new Integer(NETWORK_RESTRICTION_VIOLATION), "net_restr_violation");
       
    58             messageTable.put(new Integer(OCSP_GENERAL_ERR), "ocsp_general");
       
    59             messageTable.put(new Integer(JAR_NOT_FOUND), "jar_not_found");
       
    60         }
       
    61         else
       
    62         {
       
    63             messageTable.put(new Integer(JAR_TAMPERED), "jar_tampered");
       
    64             messageTable.put(new Integer(CERT_NOT_AVAILABLE), "cert_not_available");
       
    65             messageTable.put(new Integer(UNEXPECTED_ERR), "unexpected_error");
       
    66             messageTable.put(new Integer(NETWORK_RESTRICTION_VIOLATION), "net_restr_violation");
       
    67             messageTable.put(new Integer(OCSP_GENERAL_ERR), "there_is_a_security_issue_with_this");
       
    68             messageTable.put(new Integer(JAR_NOT_FOUND), "error_jar_not_found");
       
    69         }
    59         iMessageTable = messageTable;
    70         iMessageTable = messageTable;
    60         return iMessageTable;
    71         return iMessageTable;
    61     }
    72     }
    62 
    73 
    63     /**
    74     /**
    67     private static ResourceLoader iRes = null;
    78     private static ResourceLoader iRes = null;
    68     protected ResourceLoader getResourceLoader()
    79     protected ResourceLoader getResourceLoader()
    69     {
    80     {
    70         if (iRes == null)
    81         if (iRes == null)
    71         {
    82         {
    72             iRes = ResourceLoader.getInstance("javausermessages", "qtn_java_secur_error_");
    83             // This method returns ResourceLoader only when Qt
       
    84             // localisation is not in use. When Qt localisation
       
    85             // is in use this method returns null and
       
    86             // ResourceLoader is obtained with getResourceLoader(int)
       
    87             // method variant.
       
    88             if (getLocaleIdQt() == null)
       
    89             {
       
    90                 iRes = ResourceLoader.getInstance("javausermessages", "qtn_java_secur_error_");
       
    91             }
    73         }
    92         }
    74         return iRes;
    93         return iRes;
       
    94     }
       
    95 
       
    96     /**
       
    97      * Method for retrieving the ResourceLoader instance that is used
       
    98      * to localise error message for specified error code.
       
    99      *
       
   100      * @param errorCode error code for which ResourceLoader is returned
       
   101      */
       
   102     protected ResourceLoader getResourceLoader(int errorCode)
       
   103     {
       
   104         String resFilename = "javaapplicationsecuritymessages";
       
   105         String resPrefix = "txt_java_secur_info_";
       
   106         switch (errorCode)
       
   107         {
       
   108         case OCSP_GENERAL_ERR:
       
   109             resFilename = "common_errors";
       
   110             resPrefix = "txt_error_info_";
       
   111             break;
       
   112         }
       
   113         return getResourceLoader(resFilename, resPrefix);
    75     }
   114     }
    76 
   115 
    77     /*** ----------------------------- PACKAGE ---------------------------- */
   116     /*** ----------------------------- PACKAGE ---------------------------- */
    78     /*** ----------------------------- PRIVATE ---------------------------- */
   117     /*** ----------------------------- PRIVATE ---------------------------- */
    79     /*** ----------------------------- NATIVE ----------------------------- */
   118     /*** ----------------------------- NATIVE ----------------------------- */