Source Code Cross Referenced for Login.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 java.util.Enumeration;
004:        import java.util.Hashtable;
005:        import java.util.Properties;
006:        import com.teamkonzept.lib.ErrorCodes;
007:        import com.teamkonzept.lib.TKException;
008:        import com.teamkonzept.lib.TKVector;
009:        import de.webman.acl.db.LoginDBData;
010:        import de.webman.acl.resolver.ResolverFactory;
011:        import com.teamkonzept.webman.mainint.events.TKUserException;
012:        import com.teamkonzept.webman.mainint.events.UserCodes;
013:
014:        /**
015:         * A login represents an identifiable user or user group whose access
016:         * to WebMan functionality is controlled.
017:         *
018:         * @version 1.0
019:         * @since 1.0
020:         * @author © 2001 Webman AG
021:         */
022:        public abstract class Login extends WMObject {
023:
024:            // $Header: /cvsroot/webman-cms/source/webman/de/webman/acl/Login.java,v 1.2 2001/11/15 10:35:30 gregor Exp $
025:
026:            // Attributes
027:
028:            /**
029:             * Specifies wether the ordering of the parents has changed.
030:             */
031:            private boolean parentsModified = false;
032:
033:            /**
034:             * The name of the login object.
035:             */
036:            private String name = null;
037:
038:            /**
039:             * The login of the login object.
040:             */
041:            private String login = null;
042:
043:            /**
044:             * The priority order of parent login obects.
045:             */
046:            private TKVector parents = null;
047:
048:            // Constructors
049:
050:            /**
051:             * Provide instantion only to package classes or subclasses.
052:             *
053:             * @param data the initial login data.
054:             */
055:            protected Login(LoginDBData data) {
056:                super (data);
057:
058:                this .name = data.getName();
059:                this .login = data.getLogin();
060:            }
061:
062:            // Method signatures
063:
064:            /**
065:             * Checks wether this login object represents a user.
066:             *
067:             * @return <CODE>true</CODE> if this login object represents a user,
068:             * otherwise <CODE>false</CODE>.
069:             */
070:            public abstract boolean isUser();
071:
072:            /**
073:             * Checks wether this login object represents a profile.
074:             *
075:             * @return <CODE>true</CODE> if this login object represents a profile,
076:             * otherwise <CODE>false</CODE>.
077:             */
078:            public abstract boolean isProfile();
079:
080:            /**
081:             * Checks wether this login object is a parent of the given login object.
082:             *
083:             * @param login the login object.
084:             * @return <CODE>true</CODE> if this login object is a parent of the
085:             * given login object, otherwise <CODE>false</CODE>.
086:             * @exception com.teamkonzept.lib.TKException if an error occured during login retrieval.
087:             */
088:            public abstract boolean isParent(Login login) throws TKException;
089:
090:            // Method implementations
091:
092:            /**
093:             * Returns the name of the login object.
094:             *
095:             * @return the name of the login object.
096:             */
097:            public final String getName() {
098:                return name;
099:            }
100:
101:            /**
102:             * Assigns the name of the login object.
103:             *
104:             * @param name the name of the login object.
105:             */
106:            public final void setName(String name) {
107:                super .modifyAttribute(this .name, name);
108:                this .name = name;
109:            }
110:
111:            /**
112:             * Returns the login of the login object.
113:             *
114:             * @return the login of the login object.
115:             */
116:            public final String getLogin() {
117:                return login;
118:            }
119:
120:            /**
121:             * Assigns the login of the login object.
122:             *
123:             * @param login the login of the login object.
124:             * @exception com.teamkonzept.lib.TKException if an error occured while checking the
125:             * login or the login is invalid.
126:             */
127:            public final void setLogin(String login) throws TKException {
128:                // Check login token.
129:                LoginFactory.getInstance().checkLogin(login);
130:
131:                // Proceed if no errors occur.
132:                super .modifyAttribute(this .login, login);
133:                this .login = login;
134:            }
135:
136:            /**
137:             * Returns all profiles referencing the login.
138:             *
139:             * @return all profiles referencing the login.
140:             * @exception com.teamkonzept.lib.TKException if an error occured during login object retrieval.
141:             */
142:            public final TKVector getParents() throws TKException {
143:                return LoginFactory.getInstance().getLogins(this );
144:            }
145:
146:            // Parent order handling methods
147:
148:            /**
149:             * Checks wether the current analysis order of all profiles referencing
150:             * the login has been changed.
151:             *
152:             * @return <CODE>true</CODE> if the current analysis order of all profiles
153:             * referencing the login has been changed, otherwise <CODE>false</CODE>.
154:             */
155:            public final boolean isModifiedParents() {
156:                return this .parentsModified;
157:            }
158:
159:            /**
160:             * Informs the login about the succesful update of the current analysis order
161:             * or changes in the kinship.
162:             */
163:            protected final void updatedParents() {
164:                this .parentsModified = false;
165:                this .parents = null;
166:            }
167:
168:            /**
169:             * Returns the IDs of all profiles referencing the login in the current
170:             * analysis order.
171:             *
172:             * @return the IDs of all profiles referencing the login in the current
173:             * analysis order.
174:             * @exception com.teamkonzept.lib.TKException if an error occured during login retrieval.
175:             */
176:            public final TKVector getParentOrder() throws TKException {
177:                if (this .parents == null) {
178:                    this .parents = LoginFactory.getInstance().getLoginIDs(this );
179:                }
180:
181:                return this .parents;
182:            }
183:
184:            /**
185:             * Assigns the current analysis order of all profiles referencing the login.
186:             *
187:             * @param order the current analysis order of all profiles referencing the login.
188:             * @exception com.teamkonzept.lib.TKException if an error occured during login retrieval
189:             * or the given profiles do not match the parent profiles.
190:             */
191:            public final void setParentOrder(TKVector order) throws TKException {
192:                if (order != null) {
193:                    TKVector current = getParentOrder();
194:
195:                    if (current != null) {
196:                        // Check number of parents.
197:                        if (current.size() != order.size()) {
198:                            throw new TKUserException(
199:                                    "The number of groups given ("
200:                                            + order.size()
201:                                            + ") does not match the number of the parent groups ("
202:                                            + current.size() + ").",
203:                                    UserCodes.INVALID_PARENT_COUNT,
204:                                    ErrorCodes.USER_SEVERITY, true,
205:                                    new Object[] {
206:                                            String.valueOf(order.size()),
207:                                            String.valueOf(current.size()) },
208:                                    null);
209:                        }
210:
211:                        // Check membership of parents.
212:                        int index = 0;
213:                        int size = current.size();
214:
215:                        this .parents = new TKVector(size);
216:
217:                        while (index < size) {
218:                            Integer parent = (Integer) order.elementAt(index++);
219:
220:                            if (!current.contains(parent)) {
221:                                // Remove update information in error cases.
222:                                updatedParents();
223:
224:                                // Retrieve name.
225:                                String name = ProfileFactory.getInstance()
226:                                        .getProfile(parent).getName();
227:
228:                                throw new TKUserException(
229:                                        "The group '"
230:                                                + name
231:                                                + "' does not belong to the parent groups.",
232:                                        UserCodes.INVALID_PARENT_GROUP,
233:                                        ErrorCodes.USER_SEVERITY, true,
234:                                        new Object[] { name }, null);
235:                            }
236:
237:                            this .parents.addElement(parent);
238:                        }
239:
240:                        // Set update information.
241:                        this .parentsModified = true;
242:                    }
243:                }
244:            }
245:
246:            // Access right handling methods
247:
248:            /**
249:             * Retrieves all allowed events in the specified application context.
250:             *
251:             * @param context the ID of the current context.
252:             * @return all allowed events in the specified application context.
253:             * @exception com.teamkonzept.lib.TKException if an error occured during event retrieval.
254:             */
255:            public final boolean isAllowed(Integer event, Integer context)
256:                    throws TKException {
257:                // Convenience.
258:                return isAllowed(event, context, null, null);
259:            }
260:
261:            /**
262:             * Retrieves all allowed events in the specified application context.
263:             *
264:             * @param context the ID of the current context.
265:             * @param type the current object type.
266:             * @param reference the current object reference.
267:             * @return all allowed events in the specified application context.
268:             * @exception com.teamkonzept.lib.TKException if an error occured during event retrieval.
269:             */
270:            public final boolean isAllowed(Integer event, Integer context,
271:                    Integer type, Integer reference) throws TKException {
272:                boolean allowed = false;
273:                Hashtable checks = new Hashtable();
274:
275:                // Resolve allowed events.
276:                ResolverFactory.getInstance().getResolver(this ).resolve(checks,
277:                        context, type, reference);
278:
279:                // Check given event.
280:                allowed = checks.containsKey(event);
281:
282:                return allowed;
283:            }
284:
285:            /**
286:             * Retrieves all allowed events in the specified application context.
287:             *
288:             * @param context the ID of the current context.
289:             * @return all allowed events in the specified application context.
290:             * @exception com.teamkonzept.lib.TKException if an error occured during event retrieval.
291:             */
292:            public final TKVector getAllowedEvents(Integer context)
293:                    throws TKException {
294:                // Convenience.
295:                return getAllowedEvents(context, null, null);
296:            }
297:
298:            /**
299:             * Retrieves all allowed events in the specified application context.
300:             *
301:             * @param context the ID of the current context.
302:             * @param type the current object type.
303:             * @param reference the current object reference.
304:             * @return all allowed events in the specified application context.
305:             * @exception com.teamkonzept.lib.TKException if an error occured during event retrieval.
306:             */
307:            public final TKVector getAllowedEvents(Integer context,
308:                    Integer type, Integer reference) throws TKException {
309:                Hashtable resolutions = new Hashtable();
310:
311:                // Resolve allowed events.
312:                ResolverFactory.getInstance().getResolver(this ).resolve(
313:                        resolutions, context, type, reference);
314:
315:                // Copy result.
316:                TKVector events = new TKVector(resolutions.size());
317:                events.fill(resolutions.keys());
318:
319:                // Get and return the event objects.
320:                return EventFactory.getInstance().getObjects(events);
321:            }
322:
323:            /**
324:             * Retrieves all policies referencing the login.
325:             *
326:             * @return all policies referencing the login.
327:             * @exception com.teamkonzept.lib.TKException if an error occured during policy retrieval.
328:             */
329:            public final TKVector getPolicies() throws TKException {
330:                return PolicyFactory.getInstance().getObjects(
331:                        PolicyFactory.getInstance().getPolicyProxies(
332:                                this .getID(), null, null, null));
333:            }
334:
335:            /**
336:             * Retrieves all policies referencing the login.
337:             *
338:             * @param context the context additionally constraining the result set.
339:             * @return all policies referencing the login.
340:             * @exception com.teamkonzept.lib.TKException if an error occured during policy retrieval.
341:             */
342:            public final TKVector getPolicies(Context context)
343:                    throws TKException {
344:                return PolicyFactory.getInstance().getObjects(
345:                        PolicyFactory.getInstance().getPolicyProxies(
346:                                this .getID(), context.getID(), null, null));
347:            }
348:
349:            /**
350:             * Retrieves all policies referencing the login.
351:             *
352:             * @param context the context additionally constraining the result set.
353:             * @param type the object type additionally constraining the result set.
354:             * @return all policies referencing the login.
355:             * @exception com.teamkonzept.lib.TKException if an error occured during policy retrieval.
356:             */
357:            public final TKVector getPolicies(Context context, Integer type)
358:                    throws TKException {
359:                return PolicyFactory.getInstance().getObjects(
360:                        PolicyFactory.getInstance().getPolicyProxies(
361:                                this .getID(), context.getID(), type, null));
362:            }
363:
364:            /**
365:             * Retrieves all policies referencing the login.
366:             *
367:             * @param context the context additionally constraining the result set.
368:             * @param type the object type additionally constraining the result set.
369:             * @param reference the object reference additionally constraining the result set.
370:             * @return all policies referencing the login.
371:             * @exception com.teamkonzept.lib.TKException if an error occured during policy retrieval.
372:             */
373:            public final TKVector getPolicies(Context context, Integer type,
374:                    Integer reference) throws TKException {
375:                return PolicyFactory.getInstance()
376:                        .getObjects(
377:                                PolicyFactory.getInstance().getPolicyProxies(
378:                                        this .getID(), context.getID(), type,
379:                                        reference));
380:            }
381:
382:            // User or user group specific properties
383:
384:            /**
385:             * Retrieves the login specific properties.
386:             *
387:             * @return the login specific properties.
388:             * @exception com.teamkonzept.lib.TKException if an error occured during
389:             * property retrieval.
390:             */
391:            public final Properties getProperties() throws TKException {
392:                // Create property container.
393:                Properties properties = new Properties();
394:
395:                // Apply own properties.
396:                applyOwnProperties(properties);
397:
398:                // Return own properties.
399:                return properties;
400:            }
401:
402:            /**
403:             * Assigns the login specific properties.
404:             *
405:             * @param properties the login specific properties.
406:             * @exception com.teamkonzept.lib.TKException if an error occured during
407:             * property assignment.
408:             */
409:            public final void setProperties(Properties properties)
410:                    throws TKException {
411:                // Remove old properties.
412:                TKVector own = PropertyFactory.getInstance()
413:                        .getProperties(this );
414:
415:                for (int i = 0; i < own.size(); i++) {
416:                    PropertyFactory.getInstance().deleteProperty(
417:                            (Property) own.elementAt(i));
418:                }
419:
420:                // Create new properties.
421:                if (properties != null) {
422:                    Enumeration keys = properties.keys();
423:                    String key = null;
424:
425:                    while (keys.hasMoreElements()) {
426:                        key = (String) keys.nextElement();
427:
428:                        PropertyFactory.getInstance().createProperty(this , key,
429:                                properties.getProperty(key));
430:                    }
431:                }
432:            }
433:
434:            /**
435:             * Retrieves the inherited properties.
436:             *
437:             * @return the inherited properties.
438:             * @exception com.teamkonzept.lib.TKException if an error occured during
439:             * property retrieval.
440:             */
441:            public final Properties getInheritedProperties() throws TKException {
442:                // Create property container.
443:                Properties properties = new Properties();
444:
445:                // Apply inherited properties.
446:                applyInheritedProperties(properties);
447:
448:                // Return inherited properties.
449:                return properties;
450:            }
451:
452:            /**
453:             * Resolves the inherited properties.
454:             *
455:             * @param properties the inherited properties.
456:             * @exception com.teamkonzept.lib.TKException if an error occured during
457:             * property retrieval.
458:             */
459:            private final void resolveInheritedProperties(Properties properties)
460:                    throws TKException {
461:                // Apply inherited properties.
462:                applyInheritedProperties(properties);
463:
464:                // Apply own properties.
465:                applyOwnProperties(properties);
466:            }
467:
468:            /**
469:             * Fills in the inherited properties.
470:             *
471:             * @param properties the inherited properties.
472:             * @exception com.teamkonzept.lib.TKException if an error occured during
473:             * property retrieval.
474:             */
475:            private final void applyInheritedProperties(Properties properties)
476:                    throws TKException {
477:                TKVector inherited = getParentOrder();
478:
479:                if (inherited != null) {
480:                    // jtest has some problems noticing that the method 
481:                    // resolveInheritedProperties() is really used ...
482:                    Login actLogin = null;
483:                    for (int i = 0; i < inherited.size(); i++) {
484:                        actLogin = LoginFactory.getInstance().getLogin(
485:                                (Integer) inherited.elementAt(i));
486:                        actLogin.resolveInheritedProperties(properties);
487:                    }
488:                }
489:            }
490:
491:            /**
492:             * Fills in the inherited properties.
493:             *
494:             * @param properties the inherited properties.
495:             * @exception com.teamkonzept.lib.TKException if an error occured during
496:             * property retrieval.
497:             */
498:            private final void applyOwnProperties(Properties properties)
499:                    throws TKException {
500:                TKVector own = PropertyFactory.getInstance()
501:                        .getProperties(this );
502:
503:                Property property = null;
504:
505:                for (int i = 0; i < own.size(); i++) {
506:                    property = (Property) own.elementAt(i);
507:                    properties.setProperty(property.getName(), property
508:                            .getValue());
509:                }
510:            }
511:
512:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.