Source Code Cross Referenced for BasicHandler.java in  » Groupware » LibreSource » org » esupportail » cas » server » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » LibreSource » org.esupportail.cas.server.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.esupportail.cas.server.util;
002:
003:        import org.dom4j.Element;
004:        import org.esupportail.cas.server.util.log.Debug;
005:
006:        /**
007:         * This class implements a basic handler, without any property. 
008:         * This abstract class is inherited by any handler.
009:         *
010:         * @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
011:         */
012:        public abstract class BasicHandler extends Debug {
013:
014:            /**
015:             * The value return by authenticate() when the authentication
016:             * was successfull.
017:             */
018:            public static final int SUCCEEDED = 1;
019:            /**
020:             * The value return by authenticate() when the authentication
021:             * failed but the next handler should be tried.
022:             */
023:            protected static final int FAILED_CONTINUE = 2;
024:            /**
025:             * The value return by authenticate() when the authentication
026:             * failed and the authentication process should stop.
027:             */
028:            public static final int FAILED_STOP = 3;
029:
030:            /**
031:             * The XML element that represents the configuration of the handler
032:             * in the configuration file.
033:             */
034:            private Element configElement;
035:
036:            /**
037:             * Retrieve the XML element the represents the configuration of the handler
038:             * in the configuration file.
039:             * 
040:             * @return an XML element.
041:             */
042:            protected final Element getConfigElement() {
043:                return configElement;
044:            }
045:
046:            /**
047:             * Constructor.
048:             *
049:             * @param handlerElement the XML element that declares the handler 
050:             * in the configuration file
051:             * @param configDebug debugging mode of the global configuration
052:             */
053:            protected BasicHandler(final Element handlerElement,
054:                    final Boolean configDebug) {
055:                super (elementDebugValue(handlerElement, configDebug
056:                        .booleanValue()));
057:                traceBegin();
058:                configElement = handlerElement.element("config");
059:                traceEnd();
060:            }
061:
062:            /**
063:             * Check the "config" XML element if needed.
064:             *
065:             * @param configElementNeeded true if a config element is needed
066:             * @throws Exception Exception
067:             */
068:            protected final void checkConfigElement(
069:                    final boolean configElementNeeded) throws Exception {
070:                traceBegin();
071:                if (configElementNeeded && (getConfigElement() == null)) {
072:                    traceThrow(new MisconfiguredHandlerException(
073:                            "A \"config\" element is needed by \""
074:                                    + getClass().getName() + "\" handlers."));
075:                }
076:                traceEnd();
077:            }
078:
079:            /**
080:             * Tries to Authenticate a user by accessing all the servers..
081:             *
082:             * @param username the username to authenticate
083:             * @param password the corresponding password
084:             *
085:             * @return SUCCEDED on success, FAILED_CONTINUE or FAILED_STOP otherwise.
086:             */
087:            public abstract int authenticate(final String username,
088:                    final String password);
089:
090:            /**
091:             * Retrieve the content of a config sub-element.
092:             * 
093:             * @param elementName the name of the XML element to look for
094:             * @param needed false if the element can be absent or empty, true otherwise
095:             * @return a String
096:             * @throws Exception Exception
097:             */
098:            protected final String getConfigSubElementContent(
099:                    final String elementName, final boolean needed)
100:                    throws Exception {
101:                Element element = getConfigElement().element(elementName);
102:                String str;
103:                if (element == null) {
104:                    str = "";
105:                } else {
106:                    str = element.getTextTrim();
107:                }
108:                if (needed && str.equals("")) {
109:                    traceThrow(new MisconfiguredHandlerException(
110:                            "A non empty nested \"" + elementName
111:                                    + "\" element is needed to configure \""
112:                                    + getClass().getName() + "\" handlers."));
113:                }
114:                return str;
115:            }
116:
117:            /**
118:             * Tell if a config sub-element is present.
119:             * 
120:             * @param elementName the name of the XML element to look for
121:             * @return true if the element is present, false otherwise
122:             * @throws Exception Exception
123:             */
124:            protected final boolean hasConfigSubElement(final String elementName)
125:                    throws Exception {
126:                Element element = getConfigElement().element(elementName);
127:                return (element != null);
128:            }
129:
130:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.