]> git.somenet.org - irc/pjirc-ng.git/blob - src/main/java/irc/security/prv/SpecificMSSecuredProvider.java
Pjirc 2.2.1 as available on the net, reformatted and made it compile.
[irc/pjirc-ng.git] / src / main / java / irc / security / prv / SpecificMSSecuredProvider.java
1 ///*****************************************************/\r
2 ///*          This java file is a part of the          */\r
3 ///*                                                   */\r
4 ///*           -  Plouf's Java IRC Client  -           */\r
5 ///*                                                   */\r
6 ///*   Copyright (C)  2002 - 2004 Philippe Detournay   */\r
7 ///*                                                   */\r
8 ///*         All contacts : theplouf@yahoo.com         */\r
9 ///*                                                   */\r
10 ///*  PJIRC is free software; you can redistribute     */\r
11 ///*  it and/or modify it under the terms of the GNU   */\r
12 ///*  General Public License as published by the       */\r
13 ///*  Free Software Foundation; version 2 or later of  */\r
14 ///*  the License.                                     */\r
15 ///*                                                   */\r
16 ///*  PJIRC is distributed in the hope that it will    */\r
17 ///*  be useful, but WITHOUT ANY WARRANTY; without     */\r
18 ///*  even the implied warranty of MERCHANTABILITY or  */\r
19 ///*  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   */\r
20 ///*  General Public License for more details.         */\r
21 ///*                                                   */\r
22 ///*  You should have received a copy of the GNU       */\r
23 ///*  General Public License along with PJIRC; if      */\r
24 ///*  not, write to the Free Software Foundation,      */\r
25 ///*  Inc., 59 Temple Place, Suite 330, Boston,        */\r
26 ///*  MA  02111-1307  USA                              */\r
27 ///*                                                   */\r
28 ///*****************************************************/\r
29 //\r
30 //package irc.security.prv;\r
31 //\r
32 //import irc.security.SecuredProvider;\r
33 //\r
34 //import java.awt.FileDialog;\r
35 //import java.awt.Frame;\r
36 //import java.io.File;\r
37 //import java.io.FileInputStream;\r
38 //import java.io.FileOutputStream;\r
39 //import java.io.IOException;\r
40 //import java.net.InetAddress;\r
41 //import java.net.ServerSocket;\r
42 //import java.net.Socket;\r
43 //import java.net.UnknownHostException;\r
44 //\r
45 ///**\r
46 // * Specific secured provider to use with microsoft internet explorer.\r
47 // */\r
48 //public class SpecificMSSecuredProvider implements SecuredProvider {\r
49 //\r
50 //      @Override\r
51 //      public Socket getSocket(String host, Integer port)\r
52 //                      throws UnknownHostException, IOException {\r
53 //              try {\r
54 //                      PolicyEngine.assertPermission(PermissionID.NETIO);\r
55 //                      return new Socket(host, port.intValue());\r
56 //              } catch (Throwable e) {\r
57 //                      return new Socket(host, port.intValue());\r
58 //              }\r
59 //      }\r
60 //\r
61 //      @Override\r
62 //      public ServerSocket getServerSocket(Integer port) throws IOException {\r
63 //              try {\r
64 //                      PolicyEngine.assertPermission(PermissionID.NETIO);\r
65 //                      return new SpecificMSSecuredServerSocket(port.intValue());\r
66 //              } catch (Throwable e) {\r
67 //                      return new SpecificMSSecuredServerSocket(port.intValue());\r
68 //              }\r
69 //      }\r
70 //\r
71 //      @Override\r
72 //      public FileInputStream getFileInputStream(File file) throws IOException {\r
73 //              try {\r
74 //                      PolicyEngine.assertPermission(PermissionID.FILEIO);\r
75 //                      return new FileInputStream(file);\r
76 //              } catch (Throwable e) {\r
77 //                      return new FileInputStream(file);\r
78 //              }\r
79 //      }\r
80 //\r
81 //      @Override\r
82 //      public Integer getFileSize(File file) {\r
83 //              try {\r
84 //                      PolicyEngine.assertPermission(PermissionID.FILEIO);\r
85 //                      return new Integer((int) file.length());\r
86 //              } catch (Throwable e) {\r
87 //                      return new Integer((int) file.length());\r
88 //              }\r
89 //      }\r
90 //\r
91 //      @Override\r
92 //      public FileOutputStream getFileOutputStream(File file) throws IOException {\r
93 //              try {\r
94 //                      PolicyEngine.assertPermission(PermissionID.FILEIO);\r
95 //                      return new FileOutputStream(file);\r
96 //              } catch (Throwable e) {\r
97 //                      return new FileOutputStream(file);\r
98 //              }\r
99 //      }\r
100 //\r
101 //      /**\r
102 //       * Open a file dialog.\r
103 //       * \r
104 //       * @param top\r
105 //       *          parent window.\r
106 //       * @param title\r
107 //       *          dialog title.\r
108 //       * @param type\r
109 //       *          dialog type.\r
110 //       * @return newly created file dialog.\r
111 //       */\r
112 //      public FileDialog getFileDialog(Frame top, String title, int type) {\r
113 //              try {\r
114 //                      PolicyEngine.assertPermission(PermissionID.UI);\r
115 //                      return new FileDialog(top, title, type);\r
116 //              } catch (Throwable e) {\r
117 //                      return new FileDialog(top, title, type);\r
118 //              }\r
119 //      }\r
120 //\r
121 //      @Override\r
122 //      public File getLoadFile(String title) {\r
123 //              try {\r
124 //                      PolicyEngine.assertPermission(PermissionID.UI);\r
125 //                      Frame f = new Frame();\r
126 //                      FileDialog dlg = new FileDialog(f, title, FileDialog.LOAD);\r
127 //                      dlg.show();\r
128 //                      File ans = null;\r
129 //                      if (dlg.getFile() != null)\r
130 //                              ans = new File(dlg.getDirectory() + dlg.getFile());\r
131 //                      dlg.hide();\r
132 //                      dlg.dispose();\r
133 //                      f.dispose();\r
134 //                      return ans;\r
135 //              } catch (Throwable e) {\r
136 //                      Frame f = new Frame();\r
137 //                      FileDialog dlg = new FileDialog(f, title, FileDialog.LOAD);\r
138 //                      dlg.show();\r
139 //                      File ans = null;\r
140 //                      if (dlg.getFile() != null)\r
141 //                              ans = new File(dlg.getDirectory() + dlg.getFile());\r
142 //                      dlg.hide();\r
143 //                      dlg.dispose();\r
144 //                      f.dispose();\r
145 //                      return ans;\r
146 //              }\r
147 //      }\r
148 //\r
149 //      @Override\r
150 //      public File getSaveFile(String title) {\r
151 //              try {\r
152 //                      PolicyEngine.assertPermission(PermissionID.UI);\r
153 //                      Frame f = new Frame();\r
154 //                      FileDialog dlg = new FileDialog(f, title, FileDialog.SAVE);\r
155 //                      dlg.show();\r
156 //                      File ans = new File(dlg.getDirectory() + dlg.getFile());\r
157 //                      dlg.hide();\r
158 //                      dlg.dispose();\r
159 //                      f.dispose();\r
160 //                      return ans;\r
161 //              } catch (Throwable e) {\r
162 //                      Frame f = new Frame();\r
163 //                      FileDialog dlg = new FileDialog(f, title, FileDialog.SAVE);\r
164 //                      dlg.show();\r
165 //                      File ans = new File(dlg.getDirectory() + dlg.getFile());\r
166 //                      dlg.hide();\r
167 //                      dlg.dispose();\r
168 //                      f.dispose();\r
169 //                      return ans;\r
170 //              }\r
171 //      }\r
172 //\r
173 //      @Override\r
174 //      public File getSaveFile(String file, String title) {\r
175 //              try {\r
176 //                      PolicyEngine.assertPermission(PermissionID.UI);\r
177 //                      Frame f = new Frame();\r
178 //                      FileDialog dlg = new FileDialog(f, title, FileDialog.SAVE);\r
179 //                      dlg.setFile(file);\r
180 //                      dlg.show();\r
181 //                      File ans = new File(dlg.getDirectory() + dlg.getFile());\r
182 //                      dlg.hide();\r
183 //                      dlg.dispose();\r
184 //                      f.dispose();\r
185 //                      return ans;\r
186 //              } catch (Throwable e) {\r
187 //                      Frame f = new Frame();\r
188 //                      FileDialog dlg = new FileDialog(f, title, FileDialog.SAVE);\r
189 //                      dlg.setFile(file);\r
190 //                      dlg.show();\r
191 //                      File ans = new File(dlg.getDirectory() + dlg.getFile());\r
192 //                      dlg.hide();\r
193 //                      dlg.dispose();\r
194 //                      f.dispose();\r
195 //                      return ans;\r
196 //              }\r
197 //      }\r
198 //\r
199 //      @Override\r
200 //      public InetAddress getLocalHost() throws UnknownHostException {\r
201 //              try {\r
202 //                      PolicyEngine.assertPermission(PermissionID.NETIO);\r
203 //                      InetAddress[] addresses = InetAddress.getAllByName(InetAddress\r
204 //                                      .getLocalHost().getHostName());\r
205 //                      return addresses[addresses.length - 1];\r
206 //              } catch (Throwable e) {\r
207 //                      InetAddress[] addresses = InetAddress.getAllByName(InetAddress\r
208 //                                      .getLocalHost().getHostName());\r
209 //                      return addresses[addresses.length - 1];\r
210 //              }\r
211 //      }\r
212 //\r
213 //      @Override\r
214 //      public String resolve(InetAddress addr) {\r
215 //              try {\r
216 //                      PolicyEngine.assertPermission(PermissionID.NETIO);\r
217 //                      return addr.getHostName();\r
218 //              } catch (Throwable e) {\r
219 //                      return addr.getHostName();\r
220 //              }\r
221 //\r
222 //      }\r
223 //\r
224 //      @Override\r
225 //      public boolean tryProvider() {\r
226 //              try {\r
227 //                      PolicyEngine.assertPermission(PermissionID.FILEIO);\r
228 //                      PolicyEngine.assertPermission(PermissionID.NETIO);\r
229 //                      PolicyEngine.assertPermission(PermissionID.UI);\r
230 //                      return true;\r
231 //              } catch (Throwable e) {\r
232 //                      return false;\r
233 //              }\r
234 //      }\r
235 //\r
236 //      @Override\r
237 //      public String getName() {\r
238 //              return "Microsoft Internet Explorer Security Provider";\r
239 //      }\r
240 // }\r