]> git.somenet.org - irc/pjirc-ng.git/blob - src/main/java/irc/security/SecuredProvider.java
Pjirc 2.2.1 as available on the net, reformatted and made it compile.
[irc/pjirc-ng.git] / src / main / java / irc / security / SecuredProvider.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;\r
31 \r
32 import java.io.File;\r
33 import java.io.FileInputStream;\r
34 import java.io.FileOutputStream;\r
35 import java.io.IOException;\r
36 import java.net.InetAddress;\r
37 import java.net.ServerSocket;\r
38 import java.net.Socket;\r
39 import java.net.UnknownHostException;\r
40 \r
41 /**\r
42  * Provide methods for accessing protected operations.\r
43  */\r
44 public interface SecuredProvider {\r
45         /**\r
46          * Get a new Socket.\r
47          * \r
48          * @param host\r
49          *          server host.\r
50          * @param port\r
51          *          server port.\r
52          * @throws UnknownHostException\r
53          *           is host is not found.\r
54          * @throws IOException\r
55          *           if an error occurs.\r
56          * @return a new Socket.\r
57          */\r
58         public Socket getSocket(String host, Integer port) throws UnknownHostException, IOException;\r
59 \r
60         /**\r
61          * Get a new ServerSocket.\r
62          * \r
63          * @param port\r
64          *          local port.\r
65          * @return the created server socket.\r
66          * @throws IOException\r
67          *           if an error occurs.\r
68          */\r
69         public ServerSocket getServerSocket(Integer port) throws IOException;\r
70 \r
71         /**\r
72          * Get an FileInputStream from a local file.\r
73          * \r
74          * @param file\r
75          *          the local file.\r
76          * @throws IOException\r
77          *           if an error occurs.\r
78          * @return an FileInputStream from the file.\r
79          */\r
80         public FileInputStream getFileInputStream(File file) throws IOException;\r
81 \r
82         /**\r
83          * Get an FileOutputStream to a local file.\r
84          * \r
85          * @param file\r
86          *          the local file.\r
87          * @throws IOException\r
88          *           if an error occurs.\r
89          * @return an FileOutputStream from the file.\r
90          */\r
91         public FileOutputStream getFileOutputStream(File file) throws IOException;\r
92 \r
93         /**\r
94          * Get the file size.\r
95          * \r
96          * @param file\r
97          *          the file to get size.\r
98          * @return the file size, of a negative value if not able.\r
99          */\r
100         public Integer getFileSize(File file);\r
101 \r
102         /**\r
103          * Open a load file dialog with the given title and return the user choice.\r
104          * \r
105          * @param title\r
106          *          dialog title.\r
107          * @return user choice.\r
108          */\r
109         public File getLoadFile(String title);\r
110 \r
111         /**\r
112          * Open a save file dialog with the given title and return the user choice.\r
113          * \r
114          * @param title\r
115          *          dialog title.\r
116          * @return user choice.\r
117          */\r
118         public File getSaveFile(String title);\r
119 \r
120         /**\r
121          * Open a save file dialog with the given title and return the user choice.\r
122          * \r
123          * @param file\r
124          *          default file.\r
125          * @param title\r
126          *          dialog title.\r
127          * @return user choice.\r
128          */\r
129         public File getSaveFile(String file, String title);\r
130 \r
131         /**\r
132          * Get the local host address.\r
133          * \r
134          * @return local host address.\r
135          * @throws UnknownHostException\r
136          *           if error occurs.\r
137          */\r
138         public InetAddress getLocalHost() throws UnknownHostException;\r
139 \r
140         /**\r
141          * Perform a dns resolve of the given address.\r
142          * \r
143          * @param addr\r
144          *          address to resolve.\r
145          * @return resolved address.\r
146          */\r
147         public String resolve(InetAddress addr);\r
148 \r
149         /**\r
150          * Try to use this provider. Return false if this provider is not able to\r
151          * perform its task.\r
152          * \r
153          * @return true if this provider can be used, false otherwise.\r
154          */\r
155         public boolean tryProvider();\r
156 \r
157         /**\r
158          * Get this provider's name.\r
159          * \r
160          * @return the provder name.\r
161          */\r
162         public String getName();\r
163 }\r