< prev index next >

test/jdk/sun/security/jca/PreferredProviderNegativeTest.java

Print this page
rev 59107 : imported patch security


  90     public static void invalidAlg(String value) throws NoSuchPaddingException {
  91         String[] arrays = value.split(":");
  92 
  93         try {
  94             Security.setProperty(SEC_PREF_PROP, value);
  95             Cipher.getInstance(arrays[0]);
  96         } catch (NoSuchAlgorithmException e) {
  97             System.out.println(
  98                     "Test Pass:Got NoSuchAlgorithmException as expired");
  99             return;
 100         }
 101         throw new RuntimeException(
 102                 "Test Failed:Expected NoSuchAlgorithmException was not thrown");
 103     }
 104 
 105     public static void main(String[] args)
 106             throws NoSuchAlgorithmException, NoSuchPaddingException {
 107 
 108         String expected;
 109         String value = args[1];
 110         // If OS is solaris, expect OracleUcrypto, otherwise SunJCE
 111         if (System.getProperty("os.name").toLowerCase().contains("sun")) {
 112             expected = "OracleUcrypto";
 113         } else {
 114             expected = "SunJCE";
 115         }
 116 
 117         if (args.length >= 2) {
 118             switch (args[0]) {
 119                 case "preSet":
 120                     boolean negativeProvider = Boolean.valueOf(args[2]);
 121                     if (!args[1].contains(":")) {
 122                         value += ":" + expected;
 123                     }
 124                     PreferredProviderNegativeTest.preJCESet(
 125                             value, negativeProvider);
 126                     break;
 127                 case "afterSet":
 128                     PreferredProviderNegativeTest.afterJCESet(args[1],
 129                             expected);
 130                     break;
 131                 case "invalidAlg":
 132                     PreferredProviderNegativeTest.invalidAlg(args[1]);
 133                     break;
 134             }
 135         } else {


  90     public static void invalidAlg(String value) throws NoSuchPaddingException {
  91         String[] arrays = value.split(":");
  92 
  93         try {
  94             Security.setProperty(SEC_PREF_PROP, value);
  95             Cipher.getInstance(arrays[0]);
  96         } catch (NoSuchAlgorithmException e) {
  97             System.out.println(
  98                     "Test Pass:Got NoSuchAlgorithmException as expired");
  99             return;
 100         }
 101         throw new RuntimeException(
 102                 "Test Failed:Expected NoSuchAlgorithmException was not thrown");
 103     }
 104 
 105     public static void main(String[] args)
 106             throws NoSuchAlgorithmException, NoSuchPaddingException {
 107 
 108         String expected;
 109         String value = args[1];




 110         expected = "SunJCE";

 111 
 112         if (args.length >= 2) {
 113             switch (args[0]) {
 114                 case "preSet":
 115                     boolean negativeProvider = Boolean.valueOf(args[2]);
 116                     if (!args[1].contains(":")) {
 117                         value += ":" + expected;
 118                     }
 119                     PreferredProviderNegativeTest.preJCESet(
 120                             value, negativeProvider);
 121                     break;
 122                 case "afterSet":
 123                     PreferredProviderNegativeTest.afterJCESet(args[1],
 124                             expected);
 125                     break;
 126                 case "invalidAlg":
 127                     PreferredProviderNegativeTest.invalidAlg(args[1]);
 128                     break;
 129             }
 130         } else {
< prev index next >