01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.framework;
11:
12: import java.util.*;
13:
14: import javax.servlet.http.*;
15: import java.io.*;
16: import org.mmbase.util.functions.*;
17: import org.mmbase.util.logging.Logger;
18: import org.mmbase.util.logging.Logging;
19:
20: /**
21: * Renderer which can be used in stead, if rendering of a certain block proved to be not allowed for
22: * the current user.
23: *
24: * @author Michiel Meeuwissen
25: * @version $Id: DeniedRenderer.java,v 1.4 2008/02/23 12:15:54 michiel Exp $
26: * @since MMBase-1.9
27: */
28:
29: public class DeniedRenderer extends AbstractRenderer {
30: private static final Logger log = Logging
31: .getLoggerInstance(DeniedRenderer.class);
32:
33: public DeniedRenderer(Type t, Block parent) {
34: super (t, parent);
35: }
36:
37: public Parameter[] getParameters() {
38: return new Parameter[] { Parameter.RESPONSE, Parameter.REQUEST,
39: Parameter.LOCALE };
40: }
41:
42: public void render(Parameters blockParameters,
43: Parameters frameworkParameters, Writer w,
44: Renderer.WindowState state) throws FrameworkException {
45: switch (getType()) {
46: case BODY:
47: try {
48: HttpServletRequest request = blockParameters
49: .get(Parameter.REQUEST);
50: HttpServletResponse response = blockParameters
51: .get(Parameter.RESPONSE);
52: Locale locale = blockParameters.get(Parameter.LOCALE);
53: decorateIntro(request, w, "denied");
54: w.write("<h1>Denied</h1>");
55: decorateOutro(request, w);
56:
57: } catch (IOException eio) {
58: throw new FrameworkException(eio.getMessage(), eio);
59: }
60: break;
61: default:
62: }
63: }
64:
65: public String toString() {
66: return "DENIED";
67: }
68:
69: }
|