Source Code Cross Referenced for PersonDirInfo.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » services » persondir » support » legacy » 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 » Portal » uPortal_rel 2 6 1 GA » org.jasig.portal.services.persondir.support.legacy 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2004 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal.services.persondir.support.legacy;
007:
008:        import java.util.Arrays;
009:
010:        /**
011:         * Legacy PersonDirInfo bean.
012:         * @author andrew.petro@yale.edu
013:         * @version $Revision: 35515 $ $Date: 2005-04-06 08:31:40 -0700 (Wed, 06 Apr 2005) $
014:         * @since uPortal 2.5
015:         */
016:        class PersonDirInfo {
017:
018:            /**  protocol, server, and initial connection parameters */
019:            private String url;
020:
021:            /**  Resource Reference name for a J2EE style DataSource */
022:            private String ResRefName;
023:
024:            /**
025:             * Name of an LDAP resource configured in LdapServices.
026:             */
027:            private String ldapRefName;
028:
029:            /**  JDBC java class to register */
030:            private String driver;
031:
032:            /**  database userid or LDAP user DN (if needed) */
033:            private String logonid;
034:
035:            /**  password */
036:            private String logonpassword;
037:
038:            /** where are users? "OU=people" or "CN=Users" */
039:            private String usercontext;
040:
041:            /** SELECT or JNDI query for userid */
042:            private String uidquery;
043:
044:            /** timeout for LDAP in milliseconds. 0 means wait forever */
045:            private int ldaptimelimit = 0;
046:
047:            /**
048:             * Names of attributes in the underlying attribute source.
049:             * The ith element of this array corresponds to the ith element of
050:             * attributenames to express a mapping from an attribute in the source to
051:             * an attribute in uPortal.
052:             */
053:            private String[] attributenames;
054:
055:            /**
056:             * Names of attributes in uPortal.
057:             */
058:            private String[] attributealiases;
059:
060:            /**
061:             * @return Returns the attributealiases.
062:             */
063:            public String[] getAttributealiases() {
064:                return this .attributealiases;
065:            }
066:
067:            /**
068:             * @param attributealiases The attributealiases to set.
069:             */
070:            void setAttributealiases(String[] attributealiases) {
071:                this .attributealiases = attributealiases;
072:            }
073:
074:            /**
075:             * @return Returns the attributenames.
076:             */
077:            String[] getAttributenames() {
078:                return this .attributenames;
079:            }
080:
081:            /**
082:             * @param attributenames The attributenames to set.
083:             */
084:            void setAttributenames(String[] attributenames) {
085:                this .attributenames = attributenames;
086:            }
087:
088:            /**
089:             * Get the fully qualified class name of the JDBC driver to use.
090:             * @return fully qualified class name of JDBC driver.
091:             */
092:            String getDriver() {
093:                return this .driver;
094:            }
095:
096:            /**
097:             * Set the name of the class to use as the JDBC driver for a directly-configured
098:             * JDBC PersonDirInfo.
099:             * @param driver The driver to set.
100:             * @throws IllegalStateException if this is an LDAP or Res-Ref PDI.
101:             */
102:            void setDriver(String driver) {
103:                if (isLdap())
104:                    throw new IllegalStateException(
105:                            "Cannot set driver for an LDAP source.");
106:                if (this .ResRefName != null)
107:                    throw new IllegalStateException(
108:                            "Cannot set driver for a JDBC source "
109:                                    + "using reference to an RDBMServices configured source.");
110:                this .driver = driver;
111:            }
112:
113:            /**
114:             * Get the time limit for LDAP queriues, in milliseconds.
115:             * Zero has the special meaning of no time limit.
116:             * @return time limit for ldap queries, in milliseconds. Zero means no time limit.
117:             */
118:            int getLdaptimelimit() {
119:                return this .ldaptimelimit;
120:            }
121:
122:            /**
123:             * Set the time limit, in milliseconds, for LDAP query.
124:             * Special value of zero means no time limit.
125:             * @param ldaptimelimit The ldaptimelimit to set.
126:             * @throws IllegalArgumentException if ldaptimelimt param < 0
127:             * @throws IllegalStateException if using JDBC.
128:             */
129:            void setLdaptimelimit(int ldaptimelimit) {
130:                if (ldaptimelimit < 0)
131:                    throw new IllegalArgumentException(
132:                            "Cannot set an LDAP time limit "
133:                                    + "of less than zero milliseconds: ["
134:                                    + ldaptimelimit + "]");
135:                if (isJdbc())
136:                    throw new IllegalStateException(
137:                            "Cannot set an LDAP time limit on a "
138:                                    + "PDI representing using JDBC.");
139:                this .ldaptimelimit = ldaptimelimit;
140:            }
141:
142:            /**
143:             * Get the username to use to authenticate to the PersonDirInfo-configured
144:             * JDBC or LDAP source.
145:             * @return the username for authenticating to the soruce
146:             */
147:            String getLogonid() {
148:                return this .logonid;
149:            }
150:
151:            /**
152:             * Set the username to use to authenticate to the PersonDirInfo-configured
153:             * JDBC or LDAP source.
154:             * Throws IllegalStateException if this PDI represents using an RDBMServices
155:             * or LdapServices-configured datasource.
156:             * @param logonid The logonid to set.
157:             * @throws IllegalStateException if this is a ResRef or Ldap-ref source.
158:             */
159:            void setLogonid(String logonid) {
160:                if (this .ldapRefName != null)
161:                    throw new IllegalStateException(
162:                            "Cannot set logon id for a source "
163:                                    + "configured to use LdapServices to obtain the LDAP connection.");
164:                if (this .ResRefName != null)
165:                    throw new IllegalStateException(
166:                            "Cannot set logon id for a source "
167:                                    + "configured to use RdbmServices to obtain the Jdbc DataSource.");
168:                this .logonid = logonid;
169:            }
170:
171:            /**
172:             * Get the password to authenticate to the LDAP or JDBC source.
173:             * @return the password
174:             */
175:            String getLogonpassword() {
176:                return this .logonpassword;
177:            }
178:
179:            /**
180:             * Set the password to use to authenticate to the LDAP or JDBC source.
181:             * @param logonpassword password to directly configured source
182:             */
183:            void setLogonpassword(String logonpassword) {
184:                if (this .ldapRefName != null)
185:                    throw new IllegalStateException(
186:                            "Cannot set logon password for a source "
187:                                    + "configured to use LdapServices to obtain the LDAP connection.");
188:                if (this .ResRefName != null)
189:                    throw new IllegalStateException(
190:                            "Cannot set logon password for a source "
191:                                    + "configured to use RdbmServices to obtain the Jdbc DataSource.");
192:                this .logonpassword = logonpassword;
193:            }
194:
195:            /**
196:             * Get the name of the RDBMServices-configured DataSource this PersonDirInfo
197:             * indicates we should use.  Returns null if this PDI does not indicate we should
198:             * use an RDBMServices-configured DataSource.
199:             * @return the name of the RDBMServices-configured DataSource we should use.
200:             */
201:            String getResRefName() {
202:                return this .ResRefName;
203:            }
204:
205:            /**
206:             * Set the name of an RDBMServices-configured DataSource against which
207:             * we should query for user attributes.
208:             * @param resRefName the name of an RDBMServices-configured DataSource.
209:             * @throws IllegalArgumentException if resRefName param is null
210:             * @throws IllegalStateException if url or ldapRefName already set
211:             */
212:            void setResRefName(String resRefName) {
213:                if (resRefName == null)
214:                    throw new IllegalArgumentException(
215:                            "Cannot set resRefName to null.");
216:                if (this .url != null)
217:                    throw new IllegalStateException(
218:                            "Cannot set resRefName when url already set.");
219:                if (this .ldapRefName != null)
220:                    throw new IllegalStateException(
221:                            "Cannot set resRefName when ldapRefName already set.");
222:                this .ResRefName = resRefName;
223:            }
224:
225:            /**
226:             * Get the parameterized JDBC or LDAP query - the single query parameter 
227:             * should be the user identifier.
228:             * @return LDAP or JDBC query parameterized by user identifier
229:             */
230:            String getUidquery() {
231:                return this .uidquery;
232:            }
233:
234:            /**
235:             * Set the LDAP or JDBC uid query.
236:             * @param uidquery The uidquery to set.
237:             * @throws IllegalArgumentException if param uidquery is null.
238:             */
239:            void setUidquery(String uidquery) {
240:                if (uidquery == null)
241:                    throw new IllegalArgumentException(
242:                            "You cannot set the uidquery to null.");
243:                this .uidquery = uidquery;
244:            }
245:
246:            /**
247:             * Get the LDAP or JDBC url.
248:             * @return Returns the url.
249:             */
250:            String getUrl() {
251:                return this .url;
252:            }
253:
254:            /**
255:             * Set the ldap or JDBC url.
256:             * @param url The url to set.
257:             * @throws IllegalArgumentException if the URL doesn't start with jdbc or ldap.
258:             * @throws IllegalStateException if ldapRefName or ResRefName is already set.
259:             */
260:            void setUrl(String url) {
261:                if (this .ldapRefName != null)
262:                    throw new IllegalStateException(
263:                            "Cannot set the URL of a PDI "
264:                                    + "configured to use an LdapServices-configured LDAP source.");
265:                if (this .ResRefName != null)
266:                    throw new IllegalStateException(
267:                            "Cannot set the URL of a PDI "
268:                                    + "configured to use an RDBMServices-configured DataSource.");
269:                if (!url.startsWith("ldap") && !url.startsWith("jdbc")) {
270:                    throw new IllegalArgumentException(
271:                            "The url must start with 'ldap' "
272:                                    + "or 'jdbc', this URL didn't: [" + url
273:                                    + "]");
274:                }
275:                this .url = url;
276:            }
277:
278:            /**
279:             * Get the context in which users are to be found.
280:             * @return the context in which users are to be found.
281:             */
282:            String getUsercontext() {
283:                return this .usercontext;
284:            }
285:
286:            /**
287:             * Set the LDAP context in which users are to be found.
288:             * @param usercontext LDAP context for users
289:             * @throws IllegalStateException if this is a JDBC PDI.
290:             */
291:            void setUsercontext(String usercontext) {
292:                if (isJdbc())
293:                    throw new IllegalStateException(
294:                            "Cannot set usercontext of a JDBC PDI.");
295:                this .usercontext = usercontext;
296:            }
297:
298:            /**
299:             * Does this PersonDirInfo instance represent information about a JDBC 
300:             * information source?
301:             * @return true if a JDBC source, false otherwise
302:             */
303:            boolean isJdbc() {
304:                if (this .ResRefName != null && this .ResRefName.length() > 0)
305:                    return true;
306:                if (this .url != null && this .url.startsWith("jdbc:"))
307:                    return true;
308:                return false;
309:            }
310:
311:            /**
312:             * Does this PersonDirInfo instance represent information about an LDAP 
313:             * information source?
314:             * @return true if a LDAP source, false otherwise
315:             */
316:            boolean isLdap() {
317:                return (this .url != null && this .url.startsWith("ldap") || (this .ldapRefName != null && this .ldapRefName
318:                        .length() > 0));
319:            }
320:
321:            /**
322:             * Get the name of the LDAP source from LdapServices to use.
323:             * @return Returns the ldapRefName, or null if not set.
324:             */
325:            String getLdapRefName() {
326:                return this .ldapRefName;
327:            }
328:
329:            /**
330:             * Set the name of an LDAP resource to use from LdapServices.
331:             * @param ldapRefName The ldapRefName to set.
332:             * @throws IllegalStateException if ResRefName or url already set.
333:             */
334:            void setLdapRefName(String ldapRefName) {
335:                if (this .ResRefName != null)
336:                    throw new IllegalStateException(
337:                            "Cannot set ldapRefName when ResRefName is already set.");
338:                if (this .url != null)
339:                    throw new IllegalStateException(
340:                            "Cannot set ldap ref name when url is already set.");
341:                this .ldapRefName = ldapRefName;
342:            }
343:
344:            public boolean equals(Object other) {
345:                if (other == null)
346:                    return false;
347:                if (!(other instanceof  PersonDirInfo))
348:                    return false;
349:                PersonDirInfo otherPdi = (PersonDirInfo) other;
350:
351:                if (this .attributealiases == null) {
352:                    if (otherPdi.attributealiases != null)
353:                        return false;
354:                } else {
355:                    if (!Arrays.equals(this .attributealiases,
356:                            otherPdi.attributealiases))
357:                        return false;
358:                }
359:
360:                if (this .attributenames == null) {
361:                    if (otherPdi.attributenames != null)
362:                        return false;
363:                } else {
364:                    if (!Arrays.equals(this .attributenames,
365:                            otherPdi.attributenames))
366:                        return false;
367:                }
368:
369:                if (this .driver == null) {
370:                    if (otherPdi.driver != null)
371:                        return false;
372:                } else {
373:                    if (!this .driver.equals(otherPdi.driver))
374:                        return false;
375:                }
376:
377:                if (this .ldapRefName == null) {
378:                    if (otherPdi.ldapRefName != null)
379:                        return false;
380:                } else {
381:                    if (!this .ldapRefName.equals(otherPdi.ldapRefName))
382:                        return false;
383:                }
384:
385:                if (!(this .ldaptimelimit == otherPdi.ldaptimelimit))
386:                    return false;
387:
388:                if (this .logonid == null) {
389:                    if (otherPdi.logonid != null)
390:                        return false;
391:                } else {
392:                    if (!this .logonid.equals(otherPdi.logonid))
393:                        return false;
394:                }
395:
396:                if (this .logonpassword == null) {
397:                    if (otherPdi.logonpassword != null)
398:                        return false;
399:                } else {
400:                    if (!this .logonpassword.equals(otherPdi.logonpassword))
401:                        return false;
402:                }
403:
404:                if (this .ResRefName == null) {
405:                    if (otherPdi.ResRefName != null)
406:                        return false;
407:                } else {
408:                    if (!this .ResRefName.equals(otherPdi.ResRefName))
409:                        return false;
410:                }
411:
412:                if (this .uidquery == null) {
413:                    if (otherPdi.uidquery != null)
414:                        return false;
415:                } else {
416:                    if (!this .uidquery.equals(otherPdi.uidquery))
417:                        return false;
418:                }
419:
420:                if (this .url == null) {
421:                    if (otherPdi.url != null)
422:                        return false;
423:                } else {
424:                    if (!this .url.equals(otherPdi.url))
425:                        return false;
426:                }
427:
428:                if (this .usercontext == null) {
429:                    if (otherPdi.usercontext != null)
430:                        return false;
431:                } else {
432:                    if (!this .usercontext.equals(otherPdi.usercontext))
433:                        return false;
434:                }
435:
436:                return true;
437:            }
438:
439:            public String toString() {
440:                StringBuffer sb = new StringBuffer();
441:                sb.append(getClass().getName()).append("\n");
442:                if (this .ldapRefName != null) {
443:                    sb.append(" ldapRef=[").append(this .ldapRefName).append(
444:                            "]\n");
445:                }
446:                if (this .isLdap()) {
447:                    sb.append(" ldaptimelim=").append(this .ldaptimelimit)
448:                            .append("\n");
449:                    sb.append(" usercontext=[").append(this .usercontext)
450:                            .append("]\n");
451:                }
452:                if (this .isJdbc()) {
453:                    sb.append(" driver=[").append(this .driver).append("]\n");
454:                }
455:                if (this .logonid != null) {
456:                    sb.append(" loginId=[").append(this .logonid).append("]\n");
457:                }
458:                if (this .logonpassword != null) {
459:                    sb.append(" logonpassword=[").append(this .logonpassword)
460:                            .append("]\n");
461:                }
462:                if (this .ResRefName != null) {
463:                    sb.append(" ResRefName=[").append(this .ResRefName).append(
464:                            "]\n");
465:                }
466:                sb.append(" uidQuery=[").append(this .uidquery).append("]\n");
467:                if (this .url != null) {
468:                    sb.append(" url=[").append(this .url).append("]\n");
469:                }
470:
471:                if (this .attributenames != null) {
472:                    sb.append(" attributeNames=\n");
473:                    for (int i = 0; i < this .attributenames.length; i++) {
474:                        sb.append("  ").append("'").append(
475:                                this .attributenames[i]).append("'\n");
476:                    }
477:                } else {
478:                    sb.append(" attributeNames=null\n");
479:                }
480:
481:                if (this .attributealiases != null) {
482:                    sb.append(" attributeAliases=\n");
483:                    for (int i = 0; i < this .attributealiases.length; i++) {
484:                        sb.append("  ").append("'").append(
485:                                this .attributealiases[i]).append("'\n");
486:                    }
487:                } else {
488:                    sb.append(" attributeAliases=null\n");
489:                }
490:
491:                return sb.toString();
492:            }
493:
494:            /**
495:             * Validate this object.
496:             * In the case where this object is insufficient to describe a source for
497:             * attributes, return a String describing the nature of the problem.
498:             * In the case where this object is valid, returns null.
499:             * Note that this method doesn't actually check that ResRefName or 
500:             * ldapRefName refers to an actually configured resource.
501:             * @return null if valid or a String message describing problem
502:             */
503:            String validate() {
504:                String problemMessage = "";
505:                if (this .url == null && this .ldapRefName == null
506:                        && this .ResRefName == null)
507:                    problemMessage += "The url for the LDAP or JDBC source "
508:                            + "or a name of an RDBMServices or LdapServices managed "
509:                            + "data source must be specified.  ";
510:                if (this .uidquery == null)
511:                    problemMessage += "The uidquery must be specifed.  ";
512:                if (this .logonpassword != null && this .logonid == null)
513:                    problemMessage += "There was a logon password specified but no logon id.  ";
514:                if (this .attributenames == null)
515:                    problemMessage += "The names of the uPortal attributes to which to map are not specified.  ";
516:                if (this .attributealiases == null)
517:                    problemMessage += "The names of the attributes in the LDAP or JDBC store from which to map are not specified.  ";
518:                if (this .attributenames != null
519:                        && this .attributealiases != null
520:                        && (this .attributenames.length != this .attributealiases.length))
521:                    problemMessage += "the lengths of the attribute names and attribute aliases arrays are not equal.  ";
522:
523:                if (this .url != null && isJdbc() && this .driver == null)
524:                    problemMessage += "Using PDI-configured JDBC but no driver specified.  ";
525:
526:                if ("".equals(problemMessage))
527:                    problemMessage = null;
528:                return problemMessage;
529:            }
530:        }
w_w___w__.j___a__v___a_2__s_.c___o_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.