Debian Codegraph @

java-sdk/ietfldap/org/ietf/ldap/LDAPUrl.java

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * The Original Code is mozilla.org code.
17 *
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 2001
21 * the Initial Developer. All Rights Reserved.
22 *
23 * Contributor(s):
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38 package org.ietf.ldap;
39
40 import java.net.MalformedURLException;
41 import java.util.Enumeration;
42 import java.util.NoSuchElementException;
43 import java.util.StringTokenizer;
44 import java.util.Vector;
45
46 import org.ietf.ldap.factory.JSSESocketFactory;
47
48 /**
49 * Represents an LDAP URL. The complete specification for LDAP URLs is in
50 * <A HREF="http://ds.internic.net/rfc/rfc1959.txt"
51 * TARGET="_blank">RFC 1959</A>. In addition, the secure ldap (ldaps://) is also
52 * supported. LDAP URLs have the following format:
53 *
54 * <PRE>
55 * "ldap[s]://" [ <I>hostName</I> [":" <I>portNumber</I>] ] "/"
56 * <I>distinguishedName</I>
57 * ["?" <I>attributeList</I> ["?" <I>scope</I>
58 * "?" <I>filterString</I> ] ]
59 * </PRE>
60 * where
61 * <P>
62 * <UL>
63 * <LI>all text within double-quotes are literal<P>
64 * <LI><CODE><I>hostName</I></CODE> and <CODE><I>portNumber</I></CODE>
65 * identify the location of the LDAP server.<P>
66 * <LI><CODE><I>distinguishedName</I></CODE> is the name of an entry
67 * within the given directory (the entry represents the starting point
68 * of the search)<P>
69 * <LI><CODE><I>attributeList</I></CODE> contains a list of attributes
70 * to retrieve (if null, fetch all attributes). This is a comma-delimited
71 * list of attribute names.<P>
72 * <LI><CODE><I>scope</I></CODE> is one of the following:
73 * <UL>
74 * <LI><CODE>base</CODE> indicates that this is a search only for the
75 * specified entry
76 * <LI><CODE>one</CODE> indicates that this is a search for matching entries
77 * one level under the specified entry (and not including the entry itself)
78 * <LI><CODE>sub</CODE> indicates that this is a search for matching entries
79 * at all levels under the specified entry (including the entry itself)
80 * </UL>
81 * <P>
82 * If not specified, <CODE><I>scope</I></CODE> is <CODE>base</CODE> by
83 * default. <P>
84 * <LI><CODE><I>filterString</I></CODE> is a human-readable representation
85 * of the search criteria. This value is used only for one-level or subtree
86 * searches.<P>
87 * </UL>
88 * <P>
89 * Note that if <CODE><I>scope</I></CODE> and <CODE><I>filterString</I></CODE>
90 * are not specified, an LDAP URL identifies exactly one entry in the
91 * directory. <P>
92 * The same encoding rules for other URLs (e.g. HTTP) apply for LDAP
93 * URLs. Specifically, any "illegal" characters are escaped with
94 * <CODE>%<I>HH</I></CODE>, where <CODE><I>HH</I></CODE> represent the
95 * two hex digits which correspond to the ASCII value of the character.
96 * This encoding is only legal (or necessary) on the DN and filter portions
97 * of the URL.
98 *
99 * @version 1.0
100 */
101 public class LDAPUrl implements java.io.Serializable {
102
103 static final long serialVersionUID = -3245440798565713640L;
104 public static String defaultFilter = "(objectClass=*)";
105
106 private String _hostName;
107 private int _portNumber;
108 private String _DN;
109 private Vector<String> _attributes;
110 private int _scope;
111 private String _filter;
112 private String _URL;
113 private boolean _secure;
114 private String[] _extensions;
115
116 private static LDAPSocketFactory _factory;
117
118 /**
119 * The default port number for secure LDAP connections.
120 * @see org.ietf.ldap.LDAPUrl#LDAPUrl(String, int, String, String[], int,
121 * String, String[])
122 */
123 public static final int DEFAULT_SECURE_PORT = 636;
124
125 /**
126 * Constructs a URL object with the specified string as URL.
127 * @param url LDAP search expression in URL form
128 * @exception MalformedURLException failed to parse URL
129 */
130 public LDAPUrl( String url ) throws java.net.MalformedURLException {
131 _attributes = null;
132 _scope = LDAPConnection.SCOPE_BASE;
133 _filter = defaultFilter;
134 _URL = url;
135
136 parseUrl(url);
137 }
138
139 /**
140 * Constructs with the specified host, port, and DN. This form is used to
141 * create URL references to a particular object in the directory.
142 * @param host host name of the LDAP server, or null for "nearest X.500/LDAP"
143 * @param port port number of the LDAP server (use LDAPConnection.DEFAULT_PORT for
144 * the default port)
145 * @param DN distinguished name of the object
146 */
147 public LDAPUrl( String host,
148 int port,
149 String DN ) {
150 initialize( host, port, DN, null,
151 LDAPConnection.SCOPE_BASE,
152 defaultFilter,
153 null );
154 }
155
156 /**
157 * Constructs a full-blown LDAP URL to specify an LDAP search operation.
158 * @param host host name of the LDAP server, or null for "nearest X.500/LDAP"
159 * @param port port number of the LDAP server (use LDAPConnection.DEFAULT_PORT for
160 * the default non-secure port or LDAPUrl.DEFAULT_SECURE_PORT for the default
161 * secure port)
162 * @param DN distinguished name of the object
163 * @param attributes list of the attributes to return. Use null for "all
164 * attributes."
165 * @param scope depth of the search (in DN namespace). Use one of the LDAPConnection scopes:
166 * SCOPE_BASE, SCOPE_ONE, or SCOPE_SUB.
167 * @param filter LDAP filter string (as defined in RFC 1558). Use null for
168 * no filter (this effectively makes the URL reference a single object).
169 * @param extensions LDAP URL extensions specified; may be null or
170 * empty. Each extension is a type=value expression.
171 * The =value part MAY be omitted. The expression
172 * may be prefixed with '!' if it is mandatory for
173 * evaluation of the URL.
174 */
175 public LDAPUrl( String host,
176 int port,
177 String DN,
178 String[] attributes,
179 int scope,
180 String filter,
181 String[] extensions ) {
182
183 if ( attributes != null ) {
184 Vector<String> list = new Vector<>();
185 for ( int k = 0; k < attributes.length; k++ ) {
186 list.addElement(attributes[k]);
187 }
188 initialize( host, port, DN, list.elements(), scope, filter,
189 extensions );
190 } else {
191 initialize( host, port, DN, null, scope, filter,
192 extensions );
193 }
194 }
195
196 /**
197 * Decodes a URL-encoded string. Any occurences of %HH are decoded to the
198 * hex value represented. However, this routine does NOT decode "+"
199 * into " ". See RFC 1738 for full details about URL encoding/decoding.
200 * @param URLEncoded a segment of a URL which was encoded using the URL
201 * encoding rules
202 * @exception MalformedURLException failed to parse URL
203 */
204 public static String decode( String URLEncoded )
205 throws MalformedURLException {
206 StringBuffer decoded = new StringBuffer (URLEncoded);
207 int srcPos = 0, dstPos = 0;
208
209 try {
210 while (srcPos < decoded.length()) {
211 if (decoded.charAt (srcPos) != '%') {
212 if (srcPos != dstPos)
213 decoded.setCharAt (dstPos, decoded.charAt (srcPos));
214 srcPos++;
215 dstPos++;
216 continue;
217 }
218 decoded.setCharAt (dstPos, (char)
219 ((hexValue(decoded.charAt (srcPos+1))<<4) |
220 (hexValue(decoded.charAt (srcPos+2)))));
221 dstPos++;
222 srcPos += 3;
223 }
224 } catch (StringIndexOutOfBoundsException sioob) {
225 // Indicates that a "%" character occured without the following HH
226 throw new MalformedURLException ();
227 }
228
229 /* 070497 Url problems submitted by Netscape */
230 /* decoded.setLength (dstPos+1); */
231 decoded.setLength (dstPos);
232 return decoded.toString ();
233 }
234
235 /**
236 * Encodes an arbitrary string. Any illegal characters are encoded as
237 * %HH. However, this routine does NOT decode "+" into " " (this is a HTTP
238 * thing, not a general URL thing). Note that, because Sun's URLEncoder
239 * does do this encoding, we can't use it.
240 * See RFC 1738 for full details about URL encoding/decoding.
241 * @param toEncode an arbitrary string to encode for embedding within a URL
242 */
243 public static String encode( String toEncode ) {
244 StringBuffer encoded = new StringBuffer (toEncode.length()+10);
245
246 for (int currPos = 0; currPos < toEncode.length(); currPos++) {
247 char currChar = toEncode.charAt (currPos);
248 if ((currChar >= 'a' && currChar <= 'z') ||
249 (currChar >= 'A' && currChar <= 'Z') ||
250 (currChar >= '0' && currChar <= '9') ||
251 ("$-_.+!*'(),".indexOf (currChar) > 0)) {
252 // this is the criteria for "doesn't need to be encoded" (whew!)
253 encoded.append (currChar);
254 } else {
255 encoded.append ("%");
256 encoded.append (hexChar ((currChar & 0xF0) >> 4));
257 encoded.append (hexChar (currChar & 0x0F));
258 }
259 }
260
261 return encoded.toString();
262 }
263
264 /**
265 * Return the collection of attributes specified in the URL, or null
266 * for "every attribute"
267 * @return string array of attributes.
268 */
269 public String[] getAttributeArray() {
270 if ( _attributes == null ) {
271 return new String[0];
272 } else {
273 String[] attrNames = new String[_attributes.size()];
274 Enumeration<String> attrs = getAttributes();
275 int i = 0;
276 while ( attrs.hasMoreElements() ) {
277 attrNames[i++] = attrs.nextElement();
278 }
279 return attrNames;
280 }
281 }
282
283 /**
284 * Return the collection of attributes specified in the URL, or null
285 * for "every attribute"
286 * @return enumeration of attributes.
287 */
288 public Enumeration<String> getAttributes() {
289 if ( _attributes == null ) {
290 return null;
291 } else {
292 return _attributes.elements();
293 }
294 }
295
296 /**
297 * Return the distinguished name encapsulated in the URL
298 * @return target distinguished name.
299 */
300 public String getDN() {
301 return _DN;
302 }
303
304 /**
305 * Returns the search filter (RFC 1558), or the default if none was
306 * specified.
307 * @return the search filter.
308 */
309 public String getFilter() {
310 return _filter;
311 }
312
313 /**
314 * Return the host name of the LDAP server
315 * @return LDAP host.
316 */
317 public String getHost() {
318 return _hostName;
319 }
320
321 /**
322 * Return the port number for the LDAP server
323 * @return port number.
324 */
325 public int getPort() {
326 return _portNumber;
327 }
328
329 /**
330 * Returns the scope of the search, according to the values
331 * SCOPE_BASE, SCOPE_ONE, SCOPE_SUB as defined in LDAPConnection. This refers
332 * to how deep within the directory namespace the search will look
333 * @return search scope.
334 */
335 public int getScope() {
336 return _scope;
337 }
338
339 /**
340 * Returns the scope of the search. If the scope returned is -1, then
341 * the given string is not for the scope.
342 * @param str the string against which to compare the scope type
343 * @returns the scope of the search, -1 is returned if the given string is
344 * not SUB, ONE or BASE (the acceptable LDAPConnection values for scope).
345 */
346 private int getScope(String str) {
347
348 int s = -1;
349 if (str.equalsIgnoreCase("base"))
350 s = LDAPConnection.SCOPE_BASE;
351 else if (str.equalsIgnoreCase("one"))
352 s = LDAPConnection.SCOPE_ONE;
353 else if (str.equalsIgnoreCase("sub"))
354 s = LDAPConnection.SCOPE_SUB;
355
356 return s;
357 }
358
359 /**
360 * Gets the socket factory to be used for ldaps:// URLs.
361 * <P>
362 * If the factory is not explicitly specified with
363 * <CODE>LDAPUrl.setSocketFactory</CODE>, the method will
364 * attempt the determine the default factory based on the
365 * available factories in the org.ietf.ldap.factory package.
366 *
367 * @return the socket factory to be used for ldaps:// URLs
368 */
369 public static LDAPSocketFactory getSocketFactory() {
370
371 if (_factory == null) {
372
373 // No factory explicity set, try to determine
374 // the default one.
375 try {
376 // First try iPlanet JSSSocketFactory
377 Class<?> c = Class.forName("org.ietf.ldap.factory.JSSSocketFactory");
378 _factory = (LDAPSocketFactory) c.newInstance();
379 }
380 catch (Throwable e) {
381 }
382
383 if (_factory != null) {
384 return _factory;
385 }
386
387 try {
388 // then try Sun JSSESocketFactory
389 _factory = new JSSESocketFactory((String[])null);
390 }
391 catch (Throwable e) {
392 }
393 }
394
395 return _factory;
396 }
397
398 /**
399 * Returns true if the secure ldap protocol is used.
400 * @return true if ldaps is used.
401 */
402 public boolean isSecure() {
403 return _secure;
404 }
405
406 /**
407 * Sets the socket factory to be used for ldaps:// URLs.
408 * Overrides the default factory assigned by the LDAPUrl
409 * class.
410 * @param the socket factory to be used for ldaps:// URLs
411 * @see org.ietf.ldap.LDAPUrl#getSocketFactory
412 */
413 public static void setSocketFactory( LDAPSocketFactory factory ) {
414 _factory = factory;
415 }
416
417 /**
418 * Sets the protocol to ldaps or ldap
419 *
420 * @param secure <CODE>true</CODE> for ldaps
421 */
422 public void setSecure( boolean secure ) {
423 _secure = secure;
424 initialize( _hostName, _portNumber, _DN, getAttributes(), _scope,
425 _filter, _extensions );
426 }
427
428 /**
429 * Returns the URL in String format
430 *
431 * @return the URL in String format
432 */
433 public String toString() {
434 return _URL;
435 }
436
437 /**
438 * Parse URL as defined in RFC 1959. Beyond the RFC, the secure ldap
439 * (ldaps) is also supported.
440 */
441 private void parseUrl(String url) throws MalformedURLException {
442 StringTokenizer urlParser = new StringTokenizer (url, ":/?", true);
443 String currentToken;
444 String str = null;
445
446 try {
447 currentToken = urlParser.nextToken();
448 if (currentToken.equalsIgnoreCase ("LDAPS")) {
449 _secure = true;
450 }
451 else if (!currentToken.equalsIgnoreCase ("LDAP")) {
452 throw new MalformedURLException ();
453 }
454
455 currentToken = urlParser.nextToken();
456 if (!currentToken.equals(":")) {
457 throw new MalformedURLException ();
458 }
459 currentToken = urlParser.nextToken();
460 if (!currentToken.equals("/")) {
461 throw new MalformedURLException ();
462 }
463 currentToken = urlParser.nextToken();
464 if (!currentToken.equals("/")) {
465 throw new MalformedURLException ();
466 }
467
468 currentToken = urlParser.nextToken();
469 }
470 catch (NoSuchElementException e) {
471 throw new MalformedURLException ();
472 }
473
474 // host-port
475 if (currentToken.equals ("/")) {
476 _hostName = null;
477 _portNumber = _secure ? DEFAULT_SECURE_PORT : LDAPConnection.DEFAULT_PORT;
478 } else if (currentToken.equals (":")) {
479 // port number without host name is not allowed
480 throw new MalformedURLException ("No hostname");
481 } else if (currentToken.equals ("?")) {
482 throw new MalformedURLException ("No host[:port]");
483 } else {
484 _hostName = currentToken;
485 if (urlParser.countTokens() == 0) {
486 _portNumber = _secure ? DEFAULT_SECURE_PORT : LDAPConnection.DEFAULT_PORT;
487 return;
488 }
489 currentToken = urlParser.nextToken (); // either ":" or "/"
490
491 if (currentToken.equals (":")) {
492 try {
493 _portNumber = Integer.parseInt (urlParser.nextToken());
494 } catch (NumberFormatException nf) {
495 throw new MalformedURLException ("Port not a number");
496 } catch (NoSuchElementException ex) {
497 throw new MalformedURLException ("No port number");
498 }
499
500 if (urlParser.countTokens() == 0) {
501 return;
502 }
503 else if (! urlParser.nextToken().equals("/")) {
504 throw new MalformedURLException ();
505 }
506
507 } else if (currentToken.equals ("/")) {
508 _portNumber = _secure ? DEFAULT_SECURE_PORT : LDAPConnection.DEFAULT_PORT;
509 } else {
510 // expecting ":" or "/"
511 throw new MalformedURLException ();
512 }
513 }
514
515
516 // DN
517 if (!urlParser.hasMoreTokens ()) {
518 return;
519 }
520 _DN = decode(readNextConstruct(urlParser));
521 if (_DN.equals("?")) {
522 _DN = "";
523 }
524 else if (_DN.equals("/")) {
525 throw new MalformedURLException ();
526 }
527
528 // attribute
529 if (!urlParser.hasMoreTokens ()) {
530 return;
531 }
532 str = readNextConstruct(urlParser);
533 if (!str.equals("?")) {
534 StringTokenizer attributeParser = new
535 StringTokenizer (decode(str), ", ");
536 _attributes = new Vector<String>();
537
538 while (attributeParser.hasMoreTokens()) {
539 _attributes.addElement (attributeParser.nextToken());
540 }
541 }
542
543 // scope
544 if (!urlParser.hasMoreTokens ()) {
545 return;
546 }
547 str = readNextConstruct(urlParser);
548 if (!str.equals("?")) {
549 _scope = getScope(str);
550 if (_scope < 0) {
551 throw new MalformedURLException("Bad scope:" + str);
552 }
553 }
554
555 // filter
556 if (!urlParser.hasMoreTokens ()) {
557 return;
558 }
559 str = readNextConstruct(urlParser);
560 _filter = decode(str);
561 checkBalancedParentheses(_filter);
562 if (!_filter.startsWith("(") && !_filter.endsWith(")")) {
563 _filter = "(" + _filter + ")";
564 }
565
566 // Nothing after the filter is allowed
567 if (urlParser.hasMoreTokens()) {
568 throw new MalformedURLException();
569 }
570 }
571
572 private void checkBalancedParentheses( String filter )
573 throws MalformedURLException {
574 int parenCnt =0;
575 StringTokenizer filterParser =
576 new StringTokenizer (filter, "()", true);
577 while (filterParser.hasMoreElements()) {
578 String token = filterParser.nextToken();
579 if (token.equals("(")) {
580 parenCnt++;
581 }
582 else if (token.equals(")")) {
583 if (--parenCnt < 0) {
584 throw new MalformedURLException(
585 "Unbalanced filter parentheses");
586 }
587 }
588 }
589
590 if (parenCnt != 0) {
591 throw new MalformedURLException("Unbalanced filter parentheses");
592 }
593 }
594
595 /**
596 * Initializes URL object.
597 */
598 private void initialize( String host,
599 int port,
600 String DN,
601 Enumeration<String> attributes,
602 int scope,
603 String filter,
604 String[] extensions ) {
605
606 _hostName = host;
607 _DN = DN;
608 _portNumber = port;
609 _filter = (filter != null) ? filter : defaultFilter;
610 _scope = scope;
611 _extensions = extensions;
612
613 if (attributes != null) {
614 _attributes = new Vector<String>();
615 while (attributes.hasMoreElements()) {
616 _attributes.addElement (attributes.nextElement());
617 }
618 } else
619 _attributes = null;
620
621 StringBuffer url = new StringBuffer (_secure ? "LDAPS://" :"LDAP://");
622
623 if (host != null) {
624 url.append (host);
625 url.append (':');
626 url.append (String.valueOf (port));
627 }
628
629 url.append ('/');
630 url.append (encode (DN));
631
632 if (attributes != null) {
633 url.append ('?');
634 Enumeration<String> attrList = _attributes.elements();
635 boolean firstElement = true;
636
637 while (attrList.hasMoreElements()) {
638 if (!firstElement)
639 url.append (',');
640 else
641 firstElement = false;
642
643 url.append (attrList.nextElement());
644 }
645 }
646
647 if (filter != null) {
648 if (attributes == null)
649 url.append ('?');
650
651 url.append ('?');
652
653 switch (scope) {
654 default:
655 case LDAPConnection.SCOPE_BASE:
656 url.append ("base"); break;
657 case LDAPConnection.SCOPE_ONE:
658 url.append ("one"); break;
659 case LDAPConnection.SCOPE_SUB:
660 url.append ("sub"); break;
661 }
662
663 url.append ('?');
664 url.append (filter);
665 }
666
667 _URL = url.toString();
668 }
669
670 /**
671 * Reads next construct from the given string parser.
672 * @param parser the string parser
673 * @return the next construct which can be an attribute, scope or filter.
674 * @exception java.net.MalformedURLException Get thrown when the url format
675 * is incorrect.
676 */
677 private String readNextConstruct(StringTokenizer parser) throws
678 MalformedURLException {
679
680 try {
681 if (parser.hasMoreTokens()) {
682 String tkn = parser.nextToken();
683 if (tkn.equals("?")) { // empty construct
684 return tkn;
685 }
686 else if (parser.hasMoreTokens()){
687 // Remove '?' delimiter
688 String delim = parser.nextToken();
689 if (!delim.equals("?")) {
690 throw new MalformedURLException();
691 }
692 }
693
694 return tkn;
695 }
696 } catch (NoSuchElementException e) {
697 throw new MalformedURLException();
698 }
699
700 return null;
701 }
702
703 /**
704 * Parses hex character into integer.
705 */
706 private static int hexValue (char hexChar) throws MalformedURLException {
707 if (hexChar >= '0' && hexChar <= '9')
708 return hexChar - '0';
709 if (hexChar >= 'A' && hexChar <= 'F')
710 return hexChar - 'A' + 10;
711 if (hexChar >= 'a' && hexChar <= 'f')
712 return hexChar - 'a' + 10;
713
714 throw new MalformedURLException ();
715 }
716
717 private static char hexChar (int hexValue) {
718 if (hexValue < 0 || hexValue > 0xF)
719 return 'x';
720
721 if (hexValue < 10)
722 return (char)(hexValue + '0');
723
724 return (char)((hexValue - 10) + 'a');
725 }
726
727 /**
728 * Reports if the two objects represent the same URL
729 *
730 * @param url the object to be compared to
731 * @return <CODE>true</CODE> if the two are equivalent
732 */
733 public boolean equals( LDAPUrl url ) {
734 if ( getHost() == null ) {
735 if ( url.getHost() != null ) {
736 return false;
737 }
738 } else if ( !getHost().equals( url.getHost() ) ) {
739 return false;
740 }
741 if ( getPort() != url.getPort() ) {
742 return false;
743 }
744 if ( getDN() == null ) {
745 if ( url.getDN() != null ) {
746 return false;
747 }
748 } else if ( !getDN().equals( url.getDN() ) ) {
749 return false;
750 }
751 if ( getFilter() == null ) {
752 if ( url.getFilter() != null ) {
753 return false;
754 }
755 } else if ( !getFilter().equals( url.getFilter() ) ) {
756 return false;
757 }
758 if ( getScope() != url.getScope() ) {
759 return false;
760 }
761
762 if ( _attributes == null ) {
763 if ( url._attributes != null ) {
764 return false;
765 }
766 } else if ( _attributes.size() != url._attributes.size() ) {
767 return false;
768 } else {
769 for( int i = 0; i < _attributes.size(); i++ ) {
770 if ( _attributes.elementAt( i ) !=
771 url._attributes.elementAt( i ) ) {
772 return false;
773 }
774 }
775 }
776 return true;
777 }
778 }