01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: AbstractLogoutTemplate.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.authentication.elements;
09:
10: import com.uwyn.rife.engine.exceptions.PropertyRequiredException;
11: import com.uwyn.rife.engine.exceptions.UnsupportedTemplateTypeException;
12: import com.uwyn.rife.template.Template;
13: import com.uwyn.rife.template.TemplateFactory;
14:
15: public abstract class AbstractLogoutTemplate extends AbstractLogout {
16: protected String mTemplateName = null;
17:
18: protected AbstractLogoutTemplate() {
19: }
20:
21: protected void setTemplateName(String name) {
22: mTemplateName = name;
23: }
24:
25: protected void init() {
26: }
27:
28: protected void entrance(Template template) {
29: }
30:
31: protected void loggedOut(Template template) {
32: }
33:
34: public void processElement() {
35: assert mSessionManager != null;
36:
37: init();
38:
39: if (!hasProperty("template_name") && null == mTemplateName) {
40: throw new PropertyRequiredException(getDeclarationName(),
41: "template_name");
42: }
43: if (!hasProperty("authvar_name")) {
44: throw new PropertyRequiredException(getDeclarationName(),
45: "authvar_name");
46: }
47:
48: // obtain the optional template_type property
49: String template_type = null;
50: if (hasProperty("template_type")) {
51: template_type = getPropertyString("template_type");
52: } else {
53: template_type = "enginehtml";
54: }
55:
56: // obtain the optional template_encoding property
57: String template_encoding = null;
58: if (hasProperty("template_encoding")) {
59: template_encoding = getPropertyString("template_encoding");
60: }
61:
62: // obtain the mandatory template_name property
63: String template_name = null;
64: if (mTemplateName != null) {
65: template_name = mTemplateName;
66: } else {
67: template_name = getPropertyString("template_name");
68: }
69:
70: TemplateFactory template_factory = null;
71: Template template = null;
72:
73: template_factory = TemplateFactory.getFactory(template_type);
74: if (null == template_factory) {
75: throw new UnsupportedTemplateTypeException(template_type);
76: }
77: template = template_factory.get(template_name,
78: template_encoding, null);
79:
80: entrance(template);
81:
82: performLogout();
83:
84: loggedOut(template);
85:
86: print(template);
87: }
88: }
|