01: ///////////////////////////////////////////////////////////////////////////////
02: //
03: // This program is free software; you can redistribute it and/or modify
04: // it under the terms of the GNU General Public License and GNU Library
05: // General Public License as published by the Free Software Foundation;
06: // either version 2, or (at your option) any later version.
07: //
08: // This program is distributed in the hope that it will be useful,
09: // but WITHOUT ANY WARRANTY; without even the implied warranty of
10: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11: // GNU General Public License and GNU Library General Public License
12: // for more details.
13: //
14: // You should have received a copy of the GNU General Public License
15: // and GNU Library General Public License along with this program; if
16: // not, write to the Free Software Foundation, 675 Mass Ave, Cambridge,
17: // MA 02139, USA.
18: //
19: ///////////////////////////////////////////////////////////////////////////////
20:
21: package org.rdesktop.server.rdp;
22:
23: import java.io.*;
24:
25: public abstract class RdpAbstractLicenseStore {
26: public byte[] load_license(String host) {
27: String path = RdpOptions.license_path + "/license." + host;
28: byte[] data = null;
29:
30: try {
31: FileInputStream fd = new FileInputStream(path);
32: data = new byte[fd.available()];
33: fd.read(data);
34: } catch (FileNotFoundException e) {
35: e.printStackTrace();
36: } catch (IOException e) {
37: e.printStackTrace();
38: }
39: return data;
40: }
41:
42: public void save_license(String host, byte[] databytes) {
43: /* set and create the directory -- if it doesn't exist. */
44: //String home = "/root";
45: String dirpath = RdpOptions.license_path;//home+"/.rdesktop";
46: String filepath = dirpath + "/license." + host;
47:
48: File file = new File(dirpath);
49: file.mkdir();
50: try {
51: FileOutputStream fd = new FileOutputStream(filepath);
52:
53: /* write to the license file */
54: fd.write(databytes);
55: fd.close();
56: } catch (FileNotFoundException e) {
57: e.printStackTrace();
58: } catch (IOException e) {
59: e.printStackTrace();
60: }
61: }
62: }
|