annotate src/goodjava/io/IoUtils.java @ 1823:36dfc31fd607

install fix
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 07 Aug 2024 18:29:58 -0600
parents 745f756e719b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1473
6c6ce14db6a8 add goodjava.io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 package goodjava.io;
6c6ce14db6a8 add goodjava.io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2
6c6ce14db6a8 add goodjava.io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 import java.io.File;
1493
471ef3e6a84e more io
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
4 import java.io.InputStream;
471ef3e6a84e more io
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
5 import java.io.OutputStream;
1509
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
6 import java.io.Reader;
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
7 import java.io.InputStreamReader;
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
8 import java.io.Writer;
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
9 import java.io.StringWriter;
1473
6c6ce14db6a8 add goodjava.io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 import java.io.IOException;
1698
2dbcc8360a3e backup security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1661
diff changeset
11 import java.net.InetAddress;
2dbcc8360a3e backup security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1661
diff changeset
12 import java.net.Inet4Address;
2dbcc8360a3e backup security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1661
diff changeset
13 import java.net.NetworkInterface;
1473
6c6ce14db6a8 add goodjava.io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 import java.nio.file.Files;
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1547
diff changeset
15 import java.nio.file.attribute.FileTime;
1506
d80395468b4e ssl security in code
Franklin Schmidt <fschmidt@gmail.com>
parents: 1501
diff changeset
16 import java.security.Security;
1698
2dbcc8360a3e backup security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1661
diff changeset
17 import java.util.Set;
2dbcc8360a3e backup security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1661
diff changeset
18 import java.util.HashSet;
2dbcc8360a3e backup security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1661
diff changeset
19 import java.util.Enumeration;
1506
d80395468b4e ssl security in code
Franklin Schmidt <fschmidt@gmail.com>
parents: 1501
diff changeset
20 import javax.net.ssl.SSLSocketFactory;
d80395468b4e ssl security in code
Franklin Schmidt <fschmidt@gmail.com>
parents: 1501
diff changeset
21 import javax.net.ssl.SSLServerSocketFactory;
1509
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
22 import goodjava.logging.Logger;
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
23 import goodjava.logging.LoggerFactory;
1473
6c6ce14db6a8 add goodjava.io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24
6c6ce14db6a8 add goodjava.io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25
6c6ce14db6a8 add goodjava.io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 public final class IoUtils {
1509
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
27 private static final Logger logger = LoggerFactory.getLogger(IoUtils.class);
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
28
1473
6c6ce14db6a8 add goodjava.io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 private IoUtils() {} // never
6c6ce14db6a8 add goodjava.io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30
6c6ce14db6a8 add goodjava.io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 public static void move( File from, File to ) throws IOException {
6c6ce14db6a8 add goodjava.io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 Files.move( from.toPath(), to.toPath() );
6c6ce14db6a8 add goodjava.io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 }
6c6ce14db6a8 add goodjava.io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34
1661
08177ced7fa0 add file.copy_to
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
35 public static void copy( File from, File to ) throws IOException {
08177ced7fa0 add file.copy_to
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
36 Files.copy( from.toPath(), to.toPath() );
08177ced7fa0 add file.copy_to
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
37 }
08177ced7fa0 add file.copy_to
Franklin Schmidt <fschmidt@gmail.com>
parents: 1548
diff changeset
38
1473
6c6ce14db6a8 add goodjava.io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 public static void delete(File file) throws IOException {
6c6ce14db6a8 add goodjava.io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 Files.deleteIfExists( file.toPath() );
6c6ce14db6a8 add goodjava.io
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 }
1475
c7b86342857f more IoUtils
Franklin Schmidt <fschmidt@gmail.com>
parents: 1473
diff changeset
42
1501
Franklin Schmidt <fschmidt@gmail.com>
parents: 1499
diff changeset
43 public static void mkdirs(File file) throws IOException {
Franklin Schmidt <fschmidt@gmail.com>
parents: 1499
diff changeset
44 Files.createDirectories( file.toPath() );
Franklin Schmidt <fschmidt@gmail.com>
parents: 1499
diff changeset
45 }
Franklin Schmidt <fschmidt@gmail.com>
parents: 1499
diff changeset
46
1475
c7b86342857f more IoUtils
Franklin Schmidt <fschmidt@gmail.com>
parents: 1473
diff changeset
47 public static boolean isSymbolicLink(File file) {
c7b86342857f more IoUtils
Franklin Schmidt <fschmidt@gmail.com>
parents: 1473
diff changeset
48 return Files.isSymbolicLink(file.toPath());
c7b86342857f more IoUtils
Franklin Schmidt <fschmidt@gmail.com>
parents: 1473
diff changeset
49 }
c7b86342857f more IoUtils
Franklin Schmidt <fschmidt@gmail.com>
parents: 1473
diff changeset
50
1795
745f756e719b make copy_to recursive
Franklin Schmidt <fschmidt@gmail.com>
parents: 1698
diff changeset
51 public static void copyRecursively( File from, File to ) throws IOException {
745f756e719b make copy_to recursive
Franklin Schmidt <fschmidt@gmail.com>
parents: 1698
diff changeset
52 copy(from,to);
745f756e719b make copy_to recursive
Franklin Schmidt <fschmidt@gmail.com>
parents: 1698
diff changeset
53 if( from.isDirectory() && !isSymbolicLink(from) ) {
745f756e719b make copy_to recursive
Franklin Schmidt <fschmidt@gmail.com>
parents: 1698
diff changeset
54 for( File f : from.listFiles() ) {
745f756e719b make copy_to recursive
Franklin Schmidt <fschmidt@gmail.com>
parents: 1698
diff changeset
55 copyRecursively( f, new File(to,f.getName()) );
745f756e719b make copy_to recursive
Franklin Schmidt <fschmidt@gmail.com>
parents: 1698
diff changeset
56 }
745f756e719b make copy_to recursive
Franklin Schmidt <fschmidt@gmail.com>
parents: 1698
diff changeset
57 }
745f756e719b make copy_to recursive
Franklin Schmidt <fschmidt@gmail.com>
parents: 1698
diff changeset
58 }
745f756e719b make copy_to recursive
Franklin Schmidt <fschmidt@gmail.com>
parents: 1698
diff changeset
59
1475
c7b86342857f more IoUtils
Franklin Schmidt <fschmidt@gmail.com>
parents: 1473
diff changeset
60 public static void deleteRecursively(File file) throws IOException {
c7b86342857f more IoUtils
Franklin Schmidt <fschmidt@gmail.com>
parents: 1473
diff changeset
61 if( file.isDirectory() && !isSymbolicLink(file) ) {
c7b86342857f more IoUtils
Franklin Schmidt <fschmidt@gmail.com>
parents: 1473
diff changeset
62 for( File f : file.listFiles() ) {
c7b86342857f more IoUtils
Franklin Schmidt <fschmidt@gmail.com>
parents: 1473
diff changeset
63 deleteRecursively(f);
c7b86342857f more IoUtils
Franklin Schmidt <fschmidt@gmail.com>
parents: 1473
diff changeset
64 }
c7b86342857f more IoUtils
Franklin Schmidt <fschmidt@gmail.com>
parents: 1473
diff changeset
65 }
c7b86342857f more IoUtils
Franklin Schmidt <fschmidt@gmail.com>
parents: 1473
diff changeset
66 delete(file);
c7b86342857f more IoUtils
Franklin Schmidt <fschmidt@gmail.com>
parents: 1473
diff changeset
67 }
c7b86342857f more IoUtils
Franklin Schmidt <fschmidt@gmail.com>
parents: 1473
diff changeset
68
1497
f04bfbb08721 link_from
Franklin Schmidt <fschmidt@gmail.com>
parents: 1494
diff changeset
69 public static void link(File existing,File link) throws IOException {
f04bfbb08721 link_from
Franklin Schmidt <fschmidt@gmail.com>
parents: 1494
diff changeset
70 Files.createLink( link.toPath(), existing.toPath() );
f04bfbb08721 link_from
Franklin Schmidt <fschmidt@gmail.com>
parents: 1494
diff changeset
71 }
f04bfbb08721 link_from
Franklin Schmidt <fschmidt@gmail.com>
parents: 1494
diff changeset
72
f04bfbb08721 link_from
Franklin Schmidt <fschmidt@gmail.com>
parents: 1494
diff changeset
73 public static void symlink(File existing,File link) throws IOException {
f04bfbb08721 link_from
Franklin Schmidt <fschmidt@gmail.com>
parents: 1494
diff changeset
74 Files.createSymbolicLink( link.toPath(), existing.toPath() );
1488
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1475
diff changeset
75 }
af55cfad6e12 start lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1475
diff changeset
76
1548
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1547
diff changeset
77 public static long getCreationTime(File f) throws IOException {
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1547
diff changeset
78 return ((FileTime)Files.getAttribute(f.toPath(),"creationTime")).toMillis();
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1547
diff changeset
79 }
736ec76bbf42 lucene log work
Franklin Schmidt <fschmidt@gmail.com>
parents: 1547
diff changeset
80
1494
91c167099462 more io
Franklin Schmidt <fschmidt@gmail.com>
parents: 1493
diff changeset
81 public static void copyAll(InputStream in,OutputStream out)
1493
471ef3e6a84e more io
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
82 throws IOException
471ef3e6a84e more io
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
83 {
471ef3e6a84e more io
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
84 byte[] a = new byte[8192];
471ef3e6a84e more io
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
85 int n;
471ef3e6a84e more io
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
86 while( (n=in.read(a)) != -1 ) {
471ef3e6a84e more io
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
87 out.write(a,0,n);
471ef3e6a84e more io
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
88 }
1499
22e15cf73040 lucene.backup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1497
diff changeset
89 in.close();
1493
471ef3e6a84e more io
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
90 }
471ef3e6a84e more io
Franklin Schmidt <fschmidt@gmail.com>
parents: 1488
diff changeset
91
1509
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
92 public static void copyAll(Reader in,Writer out)
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
93 throws IOException
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
94 {
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
95 char[] a = new char[8192];
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
96 int n;
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
97 while( (n=in.read(a)) != -1 ) {
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
98 out.write(a,0,n);
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
99 }
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
100 in.close();
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
101 }
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
102
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
103 public static String readAll(Reader in)
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
104 throws IOException
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
105 {
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
106 StringWriter sw = new StringWriter();
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
107 copyAll(in,sw);
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
108 return sw.toString();
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
109 }
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
110
1508
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
111 public static long checksum(InputStream in) throws IOException {
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
112 long cs = 0;
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
113 int c;
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
114 while( (c=in.read()) != -1 ) {
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
115 cs = 31 * cs + c;
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
116 }
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
117 in.close();
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
118 return cs;
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
119 }
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
120
1698
2dbcc8360a3e backup security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1661
diff changeset
121 public static Set<InetAddress> getInetAddresses() throws IOException {
2dbcc8360a3e backup security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1661
diff changeset
122 Set<InetAddress> set = new HashSet<InetAddress>();
2dbcc8360a3e backup security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1661
diff changeset
123 for( Enumeration<NetworkInterface> e1 = NetworkInterface.getNetworkInterfaces(); e1.hasMoreElements(); ) {
2dbcc8360a3e backup security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1661
diff changeset
124 NetworkInterface ni = e1.nextElement();
2dbcc8360a3e backup security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1661
diff changeset
125 for( Enumeration<InetAddress> e2 = ni.getInetAddresses(); e2.hasMoreElements(); ) {
2dbcc8360a3e backup security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1661
diff changeset
126 InetAddress ia = e2.nextElement();
2dbcc8360a3e backup security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1661
diff changeset
127 set.add(ia);
2dbcc8360a3e backup security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1661
diff changeset
128 }
2dbcc8360a3e backup security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1661
diff changeset
129 }
2dbcc8360a3e backup security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1661
diff changeset
130 return set;
2dbcc8360a3e backup security
Franklin Schmidt <fschmidt@gmail.com>
parents: 1661
diff changeset
131 }
1506
d80395468b4e ssl security in code
Franklin Schmidt <fschmidt@gmail.com>
parents: 1501
diff changeset
132
1509
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
133
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
134 public static class ProcException extends IOException {
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
135 private ProcException(String msg) {
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
136 super(msg);
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
137 }
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
138 }
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
139
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
140 public static void waitFor(Process proc)
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
141 throws IOException, ProcException
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
142 {
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
143 try {
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
144 proc.waitFor();
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
145 } catch(InterruptedException e) {
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
146 throw new RuntimeException(e);
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
147 }
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
148 int exitVal = proc.exitValue();
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
149 if( exitVal != 0 ) {
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
150 StringWriter sw = new StringWriter();
1547
Franklin Schmidt <fschmidt@gmail.com>
parents: 1509
diff changeset
151 try {
Franklin Schmidt <fschmidt@gmail.com>
parents: 1509
diff changeset
152 copyAll( new InputStreamReader(proc.getInputStream()), sw );
Franklin Schmidt <fschmidt@gmail.com>
parents: 1509
diff changeset
153 } catch(IOException e) {}
1509
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
154 copyAll( new InputStreamReader(proc.getErrorStream()), sw );
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
155 String error = sw.toString();
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
156 throw new ProcException(error);
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
157 }
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
158 }
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
159
0ba144491a42 lucene.backup zip
Franklin Schmidt <fschmidt@gmail.com>
parents: 1508
diff changeset
160
1506
d80395468b4e ssl security in code
Franklin Schmidt <fschmidt@gmail.com>
parents: 1501
diff changeset
161 static {
d80395468b4e ssl security in code
Franklin Schmidt <fschmidt@gmail.com>
parents: 1501
diff changeset
162 // undo restrictions of modern scum
d80395468b4e ssl security in code
Franklin Schmidt <fschmidt@gmail.com>
parents: 1501
diff changeset
163 Security.setProperty("jdk.tls.disabledAlgorithms","SSLv3, RC4, DES, MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC");
d80395468b4e ssl security in code
Franklin Schmidt <fschmidt@gmail.com>
parents: 1501
diff changeset
164 }
d80395468b4e ssl security in code
Franklin Schmidt <fschmidt@gmail.com>
parents: 1501
diff changeset
165
d80395468b4e ssl security in code
Franklin Schmidt <fschmidt@gmail.com>
parents: 1501
diff changeset
166 public static SSLSocketFactory getSSLSocketFactory() {
d80395468b4e ssl security in code
Franklin Schmidt <fschmidt@gmail.com>
parents: 1501
diff changeset
167 return (SSLSocketFactory)SSLSocketFactory.getDefault();
d80395468b4e ssl security in code
Franklin Schmidt <fschmidt@gmail.com>
parents: 1501
diff changeset
168 }
d80395468b4e ssl security in code
Franklin Schmidt <fschmidt@gmail.com>
parents: 1501
diff changeset
169
d80395468b4e ssl security in code
Franklin Schmidt <fschmidt@gmail.com>
parents: 1501
diff changeset
170 public static SSLServerSocketFactory getSSLServerSocketFactory() {
d80395468b4e ssl security in code
Franklin Schmidt <fschmidt@gmail.com>
parents: 1501
diff changeset
171 return (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
d80395468b4e ssl security in code
Franklin Schmidt <fschmidt@gmail.com>
parents: 1501
diff changeset
172 }
d80395468b4e ssl security in code
Franklin Schmidt <fschmidt@gmail.com>
parents: 1501
diff changeset
173
1508
86c5e7000ecf lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents: 1506
diff changeset
174 }