KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snipsnap > net > admin > SetupPermissions


1 /*
2  * This file is part of "SnipSnap Wiki/Weblog".
3  *
4  * Copyright (c) 2002,2003 Fraunhofer Gesellschaft
5  * Fraunhofer Institut for Computer Architecture and Software Technology
6  * All Rights Reserved.
7  *
8  * Please visit http://snipsnap.org/ for updates and contact.
9  *
10  * --LICENSE NOTICE--
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  * --LICENSE NOTICE--
25  */

26 package org.snipsnap.net.admin;
27
28 import org.snipsnap.config.Configuration;
29
30 import javax.servlet.http.HttpServletRequest JavaDoc;
31 import javax.servlet.http.HttpServletResponse JavaDoc;
32 import java.util.Map JavaDoc;
33
34 public class SetupPermissions implements SetupHandler {
35   public String JavaDoc getName() {
36     return "permissions";
37   }
38
39   public Map JavaDoc setup(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, Configuration config, Map JavaDoc errors) {
40     config.setPermRegister(allowDeny(request.getParameter(Configuration.APP_PERM_REGISTER)));
41     config.setPermWeblogsPing(allowDeny(request.getParameter(Configuration.APP_PERM_WEBLOGSPING)));
42     config.setPermNotification(allowDeny(request.getParameter(Configuration.APP_PERM_NOTIFICATION)));
43     config.setPermExternalImages(allowDeny(request.getParameter(Configuration.APP_PERM_EXTERNALIMAGES)));
44     config.setPermMultiplePosts(allowDeny(request.getParameter(Configuration.APP_PERM_MULTIPLEPOSTS)));
45     return errors;
46   }
47
48   private String JavaDoc allowDeny(String JavaDoc value) {
49     if ("allow".equals(value)) {
50       return value;
51     } else {
52       return "deny";
53     }
54   }
55 }
56
Popular Tags