Source Code Cross Referenced for Server.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 abstract class implements a generic server class, inherited 
008:         * by DatabaseServer and LDAPServer.
009:         *
010:         * @author Pascal Aubry <pascal.aubry at univ-rennes1.fr>
011:         */
012:
013:        public abstract class Server extends Debug {
014:
015:            /**
016:             * The error set by the connect() method on success.
017:             */
018:            protected static final int CONNECT_SUCCESS = 0;
019:            /**
020:             * The error code set by the connect() method when the connection 
021:             * with the server could not be achieved because of the bind
022:             * information provided (the server responded but refused the 
023:             * connection). Returned by getConnectError().
024:             */
025:            protected static final int CONNECT_NOAUTH = 1;
026:            /**
027:             * The error code set by the connect() method when the connection 
028:             * with the server could not be achieved because of a service failure.
029:             * Returned by getConnectError().
030:             */
031:            protected static final int CONNECT_FAILURE = 2;
032:            /**
033:             * an integer to store the error code of the connect() calls, set by
034:             * setConnectError(), retrieved by getConnectError().
035:             */
036:            private int connectError = CONNECT_SUCCESS;
037:            /**
038:             * The result of the authenticate() method on success (when the 
039:             * user has been authenticated).
040:             */
041:            protected static final int AUTHENTICATE_SUCCESS = 0;
042:            /**
043:             * The result of the authenticate() method when the user could not 
044:             * be authenticated (but the server was accessed without any problem).
045:             * When testing many servers, the next servers will not be called.
046:             */
047:            protected static final int AUTHENTICATE_NOAUTH = 1;
048:            /**
049:             * The result of the authenticate() method on failure (when the server 
050:             * could not be accessed for instance). When testing many servers, the
051:             * next server will be called.
052:             */
053:            protected static final int AUTHENTICATE_FAILURE = 2;
054:
055:            /**
056:             * The handler the server will be used for.
057:             */
058:            private RedundantHandler handler;
059:
060:            /**
061:             * Constructor.
062:             *
063:             * @param handlerDebug debugging mode
064:             * @param parentHandler the handler the server will be used by
065:             * @param serverElement an XML element corresponding to the server configuration
066:             */
067:            public Server(final Boolean handlerDebug,
068:                    final RedundantHandler parentHandler,
069:                    final Element serverElement) {
070:                super (elementDebugValue(serverElement, handlerDebug
071:                        .booleanValue()));
072:                handler = parentHandler;
073:            }
074:
075:            /**
076:             * Get the handler the server will be used by.
077:             *
078:             * @return a RedundantHandler object.
079:             */
080:            protected final RedundantHandler getHandler() {
081:                return handler;
082:            }
083:
084:            /**
085:             * Try to authenticate a user.
086:             *
087:             * @param username the user's name
088:             * @param password the user's password
089:             *
090:             * @return Server.AUTHENTICATE_SUCCESS, Server.AUTHENTICATE_NOAUTH
091:             * or Server.AUTHENTICATE_FAILURE.
092:             */
093:            protected abstract int authenticate(final String username,
094:                    final String password);
095:
096:            /**
097:             * Set the error code of the last connect() call.
098:             *
099:             * @param errCode an integer equal to Server.CONNECT_SUCCESS, 
100:             * Server.CONNECT_NOAUTH or Server.CONNECT_FAILURE.
101:             */
102:            protected final void setConnectError(final int errCode) {
103:                connectError = errCode;
104:            }
105:
106:            /**
107:             * Retrieve the error code of the last connect() call.
108:             *
109:             * @return Server.CONNECT_SUCCESS, Server.CONNECT_NOAUTH
110:             * or Server.CONNECT_FAILURE.
111:             */
112:            protected final int getConnectError() {
113:                int error = connectError;
114:                connectError = CONNECT_SUCCESS;
115:                return error;
116:            }
117:
118:            /**
119:             * Retrieve the content of a server sub-element.
120:             * 
121:             * @param serverElement the XML element representing the server in the configuration
122:             * @param elementName the name of the XML element to look for
123:             * @param needed false if the element can be absent or empty, true otherwise
124:             * @return a String
125:             * @throws Exception Exception
126:             */
127:            protected final String getServerSubElementContent(
128:                    final Element serverElement, final String elementName,
129:                    final boolean needed) throws Exception {
130:                Element element = serverElement.element(elementName);
131:                String str;
132:                if (element == null) {
133:                    str = "";
134:                } else {
135:                    str = element.getTextTrim();
136:                }
137:                if (needed && str.equals("")) {
138:                    traceThrow(new MisconfiguredHandlerException(
139:                            "A non empty nested \"" + elementName
140:                                    + "\" element is needed to configure \""
141:                                    + getClass().getName() + "\" servers."));
142:                }
143:                return str;
144:            }
145:
146:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.