71 static Provider getSunJceProvider() { 72 Provider p = sunJce; 73 if (p == null) { 74 synchronized (LOCK) { 75 p = getProvider 76 (sunJce, "SunJCE", "com.sun.crypto.provider.SunJCE"); 77 sunJce = p; 78 } 79 } 80 return p; 81 } 82 83 private static Provider getProvider(Provider p, String providerName, 84 String className) { 85 if (p != null) { 86 return p; 87 } 88 p = Security.getProvider(providerName); 89 if (p == null) { 90 try { 91 Class<?> clazz = Class.forName(className); 92 p = (Provider)clazz.newInstance(); 93 } catch (Exception e) { 94 throw new ProviderException 95 ("Could not find provider " + providerName, e); 96 } 97 } 98 return p; 99 } 100 101 static byte[] convert(byte[] input, int offset, int len) { 102 if ((offset == 0) && (len == input.length)) { 103 return input; 104 } else { 105 byte[] t = new byte[len]; 106 System.arraycopy(input, offset, t, 0, len); 107 return t; 108 } 109 } 110 111 static byte[] subarray(byte[] b, int ofs, int len) { 112 byte[] out = new byte[len]; | 71 static Provider getSunJceProvider() { 72 Provider p = sunJce; 73 if (p == null) { 74 synchronized (LOCK) { 75 p = getProvider 76 (sunJce, "SunJCE", "com.sun.crypto.provider.SunJCE"); 77 sunJce = p; 78 } 79 } 80 return p; 81 } 82 83 private static Provider getProvider(Provider p, String providerName, 84 String className) { 85 if (p != null) { 86 return p; 87 } 88 p = Security.getProvider(providerName); 89 if (p == null) { 90 try { 91 @SuppressWarnings("deprecation") 92 Object o = Class.forName(className).newInstance(); 93 p = (Provider)o; 94 } catch (Exception e) { 95 throw new ProviderException 96 ("Could not find provider " + providerName, e); 97 } 98 } 99 return p; 100 } 101 102 static byte[] convert(byte[] input, int offset, int len) { 103 if ((offset == 0) && (len == input.length)) { 104 return input; 105 } else { 106 byte[] t = new byte[len]; 107 System.arraycopy(input, offset, t, 0, len); 108 return t; 109 } 110 } 111 112 static byte[] subarray(byte[] b, int ofs, int len) { 113 byte[] out = new byte[len]; |