KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > drftpd > master > config > MessagePathPermission


1 /*
2  * This file is part of DrFTPD, Distributed FTP Daemon.
3  *
4  * DrFTPD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * DrFTPD is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with DrFTPD; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18 package net.sf.drftpd.master.config;
19
20 import java.io.BufferedReader JavaDoc;
21 import java.io.FileReader JavaDoc;
22 import java.io.IOException JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.Collection JavaDoc;
25 import java.util.Iterator JavaDoc;
26
27 import net.sf.drftpd.master.FtpReply;
28
29 /**
30  * @author mog
31  *
32  * @version $Id: MessagePathPermission.java,v 1.6 2004/02/10 00:03:08 mog Exp $
33  */

34 public class MessagePathPermission extends StringPathPermission {
35     private ArrayList JavaDoc message;
36     public MessagePathPermission(
37         String JavaDoc path,
38         String JavaDoc messageFile,
39         Collection JavaDoc users)
40         throws IOException JavaDoc {
41         super(path, users);
42         message = new ArrayList JavaDoc();
43         BufferedReader JavaDoc in = new BufferedReader JavaDoc(new FileReader JavaDoc(messageFile));
44         String JavaDoc line;
45         try {
46             while ((line = in.readLine()) != null) {
47                 message.add(line);
48             }
49         } finally {
50             in.close();
51         }
52         message.trimToSize();
53     }
54
55     public void printMessage(FtpReply response) {
56         for (Iterator JavaDoc iter = message.iterator(); iter.hasNext();) {
57             String JavaDoc line = (String JavaDoc) iter.next();
58             response.addComment(line);
59         }
60     }
61 }
62
Popular Tags