Source Code Cross Referenced for LoginFactory.java in  » Content-Management-System » webman » de » webman » acl » 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 » Content Management System » webman » de.webman.acl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package de.webman.acl;
002:
003:        import com.teamkonzept.lib.ConfigurationManager;
004:        import com.teamkonzept.lib.ErrorCodes;
005:        import com.teamkonzept.lib.PropertyManager;
006:        import com.teamkonzept.lib.TKConfigurationException;
007:        import com.teamkonzept.lib.TKException;
008:        import com.teamkonzept.lib.TKReg;
009:        import com.teamkonzept.lib.TKVector;
010:        import de.webman.acl.db.*;
011:        import de.webman.acl.resolver.ResolverFactory;
012:        import com.teamkonzept.webman.mainint.events.TKUserException;
013:        import com.teamkonzept.webman.mainint.events.UserCodes;
014:        import com.teamkonzept.webman.mainint.WebmanExceptionHandler;
015:
016:        /**
017:         * Factory for login, i.e. user or profile objects.
018:         *
019:         * @version 1.0
020:         * @since 1.0
021:         * @author © 2001 Webman AG
022:         */
023:        public class LoginFactory extends ObjectFactoryBase implements 
024:                ObjectFactory {
025:
026:            // $Header: /cvsroot/webman-cms/source/webman/de/webman/acl/LoginFactory.java,v 1.1.6.1 2002/05/30 10:23:54 uli Exp $
027:
028:            // Constants
029:
030:            /**
031:             * Singleton instance.
032:             */
033:            private static LoginFactory SINGLETON = null;
034:
035:            // Attributes
036:
037:            /**
038:             * Regular expression for valid logins.
039:             */
040:            private String validLogins = null;
041:
042:            // Constructors
043:
044:            /**
045:             * Inhibits instantiation from outside.
046:             */
047:            private LoginFactory() {
048:                super ();
049:            }
050:
051:            // Instance
052:
053:            /**
054:             * Returns the singleton instance of the factory.
055:             *
056:             * @return the singleton instance of the factory.
057:             * @exception com.teamkonzept.lib.TKException if an error occured during initialization.
058:             */
059:            public static synchronized final LoginFactory getInstance()
060:                    throws TKException {
061:                if (SINGLETON == null) {
062:                    SINGLETON = new LoginFactory();
063:                    SINGLETON.configurationChanged();
064:                    ConfigurationManager.getInstance()
065:                            .registerConfigurationListener(SINGLETON,
066:                                    PROPERTY_GROUP_NAME);
067:                }
068:
069:                return SINGLETON;
070:            }
071:
072:            // Method implementations
073:
074:            /**
075:             * Returns the login object database interface.
076:             *
077:             * @return the login object database interface.
078:             */
079:            public final ObjectDBInterface getDBInterface() {
080:                return LoginDBInterface.getInstance();
081:            }
082:
083:            /**
084:             * Returns a login data wrapper.
085:             *
086:             * @param id the ID of the login.
087:             * @return a login data wrapper.
088:             */
089:            public final ObjectDBData getDBData(Integer id) {
090:                return new LoginDBData(id, null, null, null);
091:            }
092:
093:            /**
094:             * Returns a login data wrapper.
095:             *
096:             * @param object the login.
097:             * @return a login data wrapper.
098:             */
099:            public final ObjectDBData getDBData(WMObject object) {
100:                return new LoginDBData((Login) object);
101:            }
102:
103:            /**
104:             * Builds a concrete login object, i.e. user or profile object.
105:             *
106:             * @param data the initial login data.
107:             * @return a concrete user or profile object.
108:             */
109:            public final WMObject buildObject(ObjectDBData data) {
110:                return ((LoginDBData) data).isUser() ? (Login) new User(
111:                        (LoginDBData) data) : (Login) new Profile(
112:                        (LoginDBData) data);
113:            }
114:
115:            // Overridden methods
116:
117:            /**
118:             * Informs the factory about changes in its configuration.
119:             *
120:             * @exception com.teamkonzept.lib.TKException if an error occured during configuration.
121:             */
122:            public synchronized final void configurationChanged()
123:                    throws TKException {
124:                // Common configuration value loading.
125:                super .configurationChanged();
126:
127:                // Special configuration value loading.
128:                try {
129:                    // Obtain property manager.
130:                    PropertyManager manager = PropertyManager
131:                            .getPropertyManager(PROPERTY_GROUP_NAME);
132:
133:                    // Get validity property.
134:                    this .validLogins = manager.getValue(PROPERTY_VALID_LOGINS,
135:                            DEFAULT_VALID_LOGINS);
136:                } catch (TKConfigurationException tkce) {
137:                    // Fall back to default.
138:                    this .validLogins = DEFAULT_VALID_LOGINS;
139:                }
140:            }
141:
142:            /**
143:             * Modifies the given object.
144:             *
145:             * @param object the object.
146:             * @exception com.teamkonzept.lib.TKException if an error occured during object modification.
147:             */
148:            public final void modifyObject(WMObject object) throws TKException {
149:                try {
150:                    // Downcast for convenience.
151:                    Login login = (Login) object;
152:
153:                    // Intercept special case for parent order modification.
154:                    if (login.isModifiedParents()) {
155:                        // Create appropriate data.
156:                        ObjectDBData data = getDBData(login);
157:                        data.setQuery(LoginDBInterface.WM_PROFILE_UPDATE);
158:                        data.setPrototype(new ProfileCollectionDBData(login
159:                                .getID()));
160:                        data.setCollection(login.getParentOrder());
161:
162:                        // Database update.
163:                        getDBInterface().updateDependent(data);
164:
165:                        // Remove update information.
166:                        login.updatedParents();
167:                    }
168:
169:                    // Call generic modification method in *every* case.
170:                    super .modifyObject(object);
171:                } catch (Exception x) {
172:                    throw WebmanExceptionHandler.getException(x);
173:                }
174:            }
175:
176:            /**
177:             * Deletes the given object.
178:             *
179:             * @param object the object.
180:             * @exception com.teamkonzept.lib.TKException if an error occured during object deletion.
181:             */
182:            public void deleteObject(WMObject object) throws TKException {
183:                ResolverFactory.getInstance().removeResolver((Login) object);
184:
185:                super .deleteObject(object);
186:            }
187:
188:            // Convenience methods
189:
190:            /**
191:             * Retrieves all known login objects.
192:             *
193:             * @return all known login objects.
194:             * @exception com.teamkonzept.lib.TKException if an error occured during login object retrieval.
195:             */
196:            public final TKVector getLogins() throws TKException {
197:                return getObjects();
198:            }
199:
200:            /**
201:             * Retrieves all login objects referencing the given login object.
202:             *
203:             * @param login the login object.
204:             * @return all login objects referencing the given login object.
205:             * @exception com.teamkonzept.lib.TKException if an error occured during login object retrieval.
206:             */
207:            public final TKVector getLogins(Login login) throws TKException {
208:                TKVector objects = null;
209:
210:                try {
211:                    // Database lookup.
212:                    objects = getObjects(getLoginIDs(login));
213:                } catch (Exception x) {
214:                    throw WebmanExceptionHandler.getException(x);
215:                }
216:
217:                return objects;
218:            }
219:
220:            /**
221:             * Retrieves the specified login object.
222:             *
223:             * @param id the ID of the login object.
224:             * @return the specified login object.
225:             * @exception com.teamkonzept.lib.TKException if an error occured during login object retrieval.
226:             */
227:            public final Login getLogin(Integer id) throws TKException {
228:                return (Login) getObject(id);
229:            }
230:
231:            /**
232:             * Retrieves the specified login object.
233:             *
234:             * @param login the login of the login object.
235:             * @return the specified login object.
236:             * @exception com.teamkonzept.lib.TKException if an error occured during login object retrieval.
237:             */
238:            public final Login getLogin(String login) throws TKException {
239:                Login object = null;
240:
241:                try {
242:                    // Create appropriate data.
243:                    LoginDBData data = new LoginDBData(null, login, null, null);
244:                    data.setQuery(LoginDBInterface.WM_USER_SELECT_BY_LOGIN);
245:                    data.setPrototype(new ObjectCollectionDBData(null, null,
246:                            LoginDBInterface.PRIMARY_KEY_NAME, null));
247:
248:                    // Database lookup.
249:                    TKVector id = getObjectIDs(data);
250:
251:                    if (id != null && id.size() == 1) {
252:                        object = (Login) getObject((Integer) id.firstElement());
253:                    } else {
254:                        throw new TKUserException("The user or group '" + login
255:                                + "' is unknown.", UserCodes.LOGIN_UNKNOWN,
256:                                ErrorCodes.USER_SEVERITY, true,
257:                                new Object[] { login }, null);
258:                    }
259:                } catch (Exception x) {
260:                    throw WebmanExceptionHandler.getException(x);
261:                }
262:
263:                return object;
264:            }
265:
266:            /**
267:             * Retrieves the IDs of all login objects referencing the given login object.
268:             *
269:             * @param login the login object.
270:             * @return the IDs of all login objects referencing the given login object.
271:             * @exception com.teamkonzept.lib.TKException if an error occured during login object retrieval.
272:             */
273:            public final TKVector getLoginIDs(Login login) throws TKException {
274:                TKVector proxies = null;
275:
276:                try {
277:                    // Create appropriate data.
278:                    LoginDBData data = new LoginDBData(null, null, null, null);
279:                    data
280:                            .setQuery(LoginDBInterface.WM_PROFILE_SELECT_BY_PROFILE);
281:                    data.setPrototype(new ObjectCollectionDBData(
282:                            LoginDBInterface.DEPENDENT_KEY_NAME, login.getID(),
283:                            LoginDBInterface.PRIMARY_KEY_NAME, null));
284:
285:                    // Database lookup.
286:                    proxies = getObjectIDs(data);
287:                } catch (Exception x) {
288:                    throw WebmanExceptionHandler.getException(x);
289:                }
290:
291:                return proxies;
292:            }
293:
294:            /**
295:             * Modifies the given login object.
296:             *
297:             * @param login the login object to be modified.
298:             * @exception com.teamkonzept.lib.TKException if an error occured during login object modification.
299:             */
300:            public final void modifyLogin(Login login) throws TKException {
301:                modifyObject(login);
302:            }
303:
304:            /**
305:             * Deletes the given login object.
306:             *
307:             * @param login the login object to be deleted.
308:             * @exception com.teamkonzept.lib.TKException if an error occured during login object deletion.
309:             */
310:            public final void deleteLogin(Login login) throws TKException {
311:                deleteObject(login);
312:            }
313:
314:            /**
315:             * Checks wether the given login string is valid.
316:             *
317:             * @param login the login string to be checked.
318:             * @exception com.teamkonzept.lib.TKException if the login string is invalid.
319:             */
320:            public final void checkLogin(String login) throws TKException {
321:                try {
322:                    if (login == null
323:                            || !TKReg.getMatcher().matches(
324:                                    login,
325:                                    TKReg.getCompiler().compile(
326:                                            this .validLogins))) {
327:                        throw new TKUserException("The login '" + login
328:                                + "' is not valid.",
329:                                UserCodes.INVALID_LOGIN_TOKEN,
330:                                ErrorCodes.USER_SEVERITY, true,
331:                                new Object[] { login }, null);
332:                    }
333:                } catch (Exception x) {
334:                    throw WebmanExceptionHandler.getException(x);
335:                }
336:            }
337:
338:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.