javacommons/security/javasrc/com/nokia/mj/impl/security/utils/SecurityErrorMessage.java
branchRCL_3
changeset 83 26b2b12093af
parent 60 6c158198356e
equal deleted inserted replaced
77:7cee158cb8cd 83:26b2b12093af
    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
    26  */
    29  */
    27 public final class SecurityErrorMessage extends ErrorMessageBase
    30 public final class SecurityErrorMessage extends ErrorMessageBase
    28 {
    31 {
    29     // Security error codes.
    32     // Security error codes.
    30     public static final int JAR_TAMPERED = 1 + ErrorMessageBase.SECURITY_RANGE_START;
    33     public static final int JAR_TAMPERED = 1;
    31     public static final int CERT_NOT_AVAILABLE = 2 + ErrorMessageBase.SECURITY_RANGE_START;
    34     public static final int CERT_NOT_AVAILABLE = 2;
    32     public static final int UNEXPECTED_ERR = 3 + ErrorMessageBase.SECURITY_RANGE_START;
    35     public static final int UNEXPECTED_ERR = 3;
    33     public static final int NETWORK_RESTRICTION_VIOLATION = 4 + ErrorMessageBase.SECURITY_RANGE_START;
    36     public static final int NETWORK_RESTRICTION_VIOLATION = 4;
    34     public static final int OCSP_GENERAL_ERR = 5 + ErrorMessageBase.SECURITY_RANGE_START;
    37     public static final int OCSP_GENERAL_ERR = 5;
    35     public static final int JAR_NOT_FOUND = 6 + ErrorMessageBase.SECURITY_RANGE_START;
       
    36 
    38 
    37     /*** ----------------------------- PUBLIC ------------------------------ */
    39     /*** ----------------------------- PUBLIC ------------------------------ */
    38     /*** ---------------------------- PROTECTED --------------------------- */
    40     /*** ---------------------------- PROTECTED --------------------------- */
    39 
    41 
    40     /**
    42     /**
    47         if (iMessageTable != null)
    49         if (iMessageTable != null)
    48         {
    50         {
    49             return iMessageTable;
    51             return iMessageTable;
    50         }
    52         }
    51         Hashtable messageTable = new Hashtable();
    53         Hashtable messageTable = new Hashtable();
    52         if (getLocaleIdQt() == null)
    54         messageTable.put(new Integer(JAR_TAMPERED), "jar_tampered");
    53         {
    55         messageTable.put(new Integer(CERT_NOT_AVAILABLE), "cert_not_available");
    54             messageTable.put(new Integer(JAR_TAMPERED), "jar_tampered");
    56         messageTable.put(new Integer(UNEXPECTED_ERR), "unexpected_err");
    55             messageTable.put(new Integer(CERT_NOT_AVAILABLE), "cert_not_available");
    57         messageTable.put(new Integer(NETWORK_RESTRICTION_VIOLATION), "net_restr_violation");
    56             messageTable.put(new Integer(UNEXPECTED_ERR), "unexpected_err");
    58         messageTable.put(new Integer(OCSP_GENERAL_ERR), "ocsp_general");
    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         }
       
    70         iMessageTable = messageTable;
    59         iMessageTable = messageTable;
    71         return iMessageTable;
    60         return iMessageTable;
    72     }
    61     }
    73 
    62 
    74     /**
    63     /**
    78     private static ResourceLoader iRes = null;
    67     private static ResourceLoader iRes = null;
    79     protected ResourceLoader getResourceLoader()
    68     protected ResourceLoader getResourceLoader()
    80     {
    69     {
    81         if (iRes == null)
    70         if (iRes == null)
    82         {
    71         {
    83             // This method returns ResourceLoader only when Qt
    72             iRes = ResourceLoader.getInstance("javausermessages", "qtn_java_secur_error_");
    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             }
       
    92         }
    73         }
    93         return iRes;
    74         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);
       
   114     }
    75     }
   115 
    76 
   116     /*** ----------------------------- PACKAGE ---------------------------- */
    77     /*** ----------------------------- PACKAGE ---------------------------- */
   117     /*** ----------------------------- PRIVATE ---------------------------- */
    78     /*** ----------------------------- PRIVATE ---------------------------- */
   118     /*** ----------------------------- NATIVE ----------------------------- */
    79     /*** ----------------------------- NATIVE ----------------------------- */