Mercurial Hosting > luan
comparison src/goodjava/lucene/backup/BackupServer.java @ 1673:1b9f9fdb3b41
remove backup password
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 28 May 2022 21:00:30 -0600 |
parents | 8dd8c556c449 |
children | af18eacf187c |
comparison
equal
deleted
inserted
replaced
1672:8dd8c556c449 | 1673:1b9f9fdb3b41 |
---|---|
87 rpc.write( new RpcException("login expected") ); | 87 rpc.write( new RpcException("login expected") ); |
88 rpc.close(); | 88 rpc.close(); |
89 return; | 89 return; |
90 } | 90 } |
91 String name = (String)call.args[0]; | 91 String name = (String)call.args[0]; |
92 String password = (String)call.args[1]; | |
93 synchronized(backups) { | 92 synchronized(backups) { |
94 backup = backups.get(name); | 93 backup = backups.get(name); |
95 if( backup == null ) { | 94 if( backup == null ) { |
96 backup = new Backup(new File(backupDir,name)); | 95 backup = new Backup(new File(backupDir,name)); |
97 backups.put(name,backup); | 96 backups.put(name,backup); |
98 } | 97 } |
99 } | |
100 File pwd = new File(backupDir,name+".pwd"); | |
101 try { | |
102 if( !pwd.exists() ) { | |
103 Writer out = new FileWriter(pwd); | |
104 out.write(password); | |
105 out.close(); | |
106 } else { | |
107 Reader in = new FileReader(pwd); | |
108 if( !IoUtils.readAll(in).equals(password) ) { | |
109 rpc.write( new RpcException("wrong password") ); | |
110 rpc.close(); | |
111 return; | |
112 } | |
113 } | |
114 } catch(IOException e) { | |
115 throw new RuntimeException(e); | |
116 } | 98 } |
117 rpc.write(Rpc.OK); | 99 rpc.write(Rpc.OK); |
118 } | 100 } |
119 while( !rpc.isClosed() ) { | 101 while( !rpc.isClosed() ) { |
120 RpcCall call = rpc.read(); | 102 RpcCall call = rpc.read(); |