.. | .. |
---|
13 | 13 | |
---|
14 | 14 | import javax.sound.sampled.*; |
---|
15 | 15 | |
---|
| 16 | +import javax.net.ssl.HostnameVerifier; |
---|
| 17 | +import javax.net.ssl.HttpsURLConnection; |
---|
| 18 | +import javax.net.ssl.SSLContext; |
---|
| 19 | +import javax.net.ssl.SSLSession; |
---|
| 20 | +import javax.net.ssl.TrustManager; |
---|
| 21 | +import javax.net.ssl.X509TrustManager; |
---|
| 22 | + |
---|
| 23 | +import java.security.cert.X509Certificate; |
---|
| 24 | +import java.net.Authenticator; |
---|
| 25 | +import java.net.PasswordAuthentication; |
---|
| 26 | + |
---|
16 | 27 | //import com.jamonapi.*; |
---|
17 | 28 | public class Grafreed extends Applet implements ActionListener |
---|
18 | 29 | { |
---|
.. | .. |
---|
677 | 688 | |
---|
678 | 689 | public static void main(String argv[]) |
---|
679 | 690 | { |
---|
680 | | - String osArch = System.getProperty("os.arch"); |
---|
| 691 | + String osArch = System.getProperty("os.arch"); |
---|
681 | 692 | if (Globals.DEBUG) |
---|
682 | 693 | System.out.println("os.arch = " + osArch); |
---|
683 | 694 | |
---|
| 695 | + String osName = System.getProperty("os.name"); |
---|
| 696 | + |
---|
| 697 | + isWindows = !osName.equals("Mac OS X"); |
---|
| 698 | + |
---|
684 | 699 | if (argv.length == 0) |
---|
685 | 700 | { |
---|
686 | 701 | String javaPath = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; |
---|
.. | .. |
---|
706 | 721 | // -Djava.library.path=/Users/nbriere/Projects/shared/lib |
---|
707 | 722 | if (jarfile.charAt(2) == ':') |
---|
708 | 723 | { |
---|
709 | | - isWindows = true; |
---|
710 | 724 | command = "\"" + javaPath + "\" -Xmx1024m -Djava.library.path=" + jarpath; |
---|
711 | 725 | // On Windows systems, the path is /C:/ |
---|
712 | 726 | jarfile = jarfile.substring(1, jarfile.length()); |
---|
.. | .. |
---|
1014 | 1028 | } |
---|
1015 | 1029 | } |
---|
1016 | 1030 | /**/ |
---|
| 1031 | + |
---|
| 1032 | + // Create a trust manager that does not validate certificate chains |
---|
| 1033 | + final TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { |
---|
| 1034 | + @Override |
---|
| 1035 | + public void checkClientTrusted(final X509Certificate[] chain, final String authType) { |
---|
| 1036 | + } |
---|
| 1037 | + |
---|
| 1038 | + @Override |
---|
| 1039 | + public void checkServerTrusted(final X509Certificate[] chain, final String authType) { |
---|
| 1040 | + } |
---|
| 1041 | + |
---|
| 1042 | + @Override |
---|
| 1043 | + public X509Certificate[] getAcceptedIssuers() { |
---|
| 1044 | + return null; |
---|
| 1045 | + } |
---|
| 1046 | + } }; |
---|
| 1047 | + |
---|
| 1048 | + try |
---|
| 1049 | + { |
---|
| 1050 | + // Install the all-trusting trust manager |
---|
| 1051 | + final SSLContext sslContext = SSLContext.getInstance("SSL"); |
---|
| 1052 | + sslContext.init(null, trustAllCerts, null); |
---|
| 1053 | + // Create an ssl socket factory with our all-trusting manager |
---|
| 1054 | + HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory()); |
---|
| 1055 | + HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { |
---|
| 1056 | + public boolean verify(String urlHostName, SSLSession session) { |
---|
| 1057 | + return true; |
---|
| 1058 | + } |
---|
| 1059 | + }); |
---|
| 1060 | + // be authentic |
---|
| 1061 | + Authenticator.setDefault(new Authenticator() { |
---|
| 1062 | + @Override |
---|
| 1063 | + protected PasswordAuthentication getPasswordAuthentication() { |
---|
| 1064 | + return new PasswordAuthentication("args[0]", "args[1]".toCharArray()); |
---|
| 1065 | + } |
---|
| 1066 | + }); |
---|
| 1067 | + } |
---|
| 1068 | + catch (Exception e) |
---|
| 1069 | + { |
---|
| 1070 | + e.printStackTrace(); |
---|
| 1071 | + } |
---|
| 1072 | + |
---|
| 1073 | + |
---|
| 1074 | + ///////////// |
---|
1017 | 1075 | |
---|
1018 | 1076 | // javax.swing.ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); |
---|
1019 | 1077 | |
---|