01: /*
02: * This file is part of DrFTPD, Distributed FTP Daemon.
03: *
04: * DrFTPD is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * 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 org.drftpd.permissions;
19:
20: import java.io.BufferedReader;
21: import java.io.FileReader;
22: import java.io.IOException;
23:
24: import java.util.ArrayList;
25: import java.util.Collection;
26: import java.util.Iterator;
27:
28: import org.drftpd.commands.Reply;
29:
30: /**
31: * @author mog
32: *
33: * @version $Id: MessagePathPermission.java 1513 2006-10-13 22:41:08Z tdsoul $
34: */
35: public class MessagePathPermission extends StringPathPermission {
36: private ArrayList<String> _message;
37:
38: public MessagePathPermission(String path, String messageFile,
39: Collection<String> users) throws IOException {
40: super (path, users);
41: _message = new ArrayList<String>();
42:
43: BufferedReader in = new BufferedReader(new FileReader(
44: messageFile));
45: String line;
46:
47: try {
48: while ((line = in.readLine()) != null) {
49: _message.add(line);
50: }
51: } finally {
52: in.close();
53: }
54:
55: _message.trimToSize();
56: }
57:
58: public void printMessage(Reply response) {
59: for (Iterator iter = _message.iterator(); iter.hasNext();) {
60: String line = (String) iter.next();
61: response.addComment(line);
62: }
63: }
64: }
|