| 1 16 package org.apache.cocoon.transformation; 17 18 import java.io.IOException ; 19 import java.io.UnsupportedEncodingException ; 20 import java.util.Enumeration ; 21 import java.util.HashMap ; 22 import java.util.LinkedList ; 23 import java.util.List ; 24 import java.util.Map ; 25 import java.util.Properties ; 26 import java.util.Vector ; 27 28 import javax.naming.Context ; 29 import javax.naming.NamingEnumeration ; 30 import javax.naming.NamingException ; 31 import javax.naming.directory.Attribute ; 32 import javax.naming.directory.BasicAttribute ; 33 import javax.naming.directory.DirContext ; 34 import javax.naming.directory.InitialDirContext ; 35 import javax.naming.directory.ModificationItem ; 36 import javax.naming.directory.SearchControls ; 37 import javax.naming.directory.SearchResult ; 38 39 import org.apache.avalon.framework.logger.Logger; 40 import org.apache.avalon.framework.parameters.Parameters; 41 import org.apache.cocoon.ProcessingException; 42 import org.apache.cocoon.environment.SourceResolver; 43 import org.apache.cocoon.xml.XMLConsumer; 44 import org.apache.commons.collections.MapUtils; 45 import org.apache.commons.lang.BooleanUtils; 46 import org.apache.commons.lang.ObjectUtils; 47 import org.apache.commons.lang.StringUtils; 48 import org.xml.sax.Attributes ; 49 import org.xml.sax.Locator ; 50 import org.xml.sax.SAXException ; 51 import org.xml.sax.ext.LexicalHandler ; 52 import org.xml.sax.helpers.AttributesImpl ; 53 54 108 public class LDAPTransformer extends AbstractTransformer { 109 110 111 public static final String my_uri = "http://apache.org/cocoon/LDAP/1.0"; 112 public static final String my_name = "LDAPTransformer"; 113 114 115 public static final String MAGIC_ATTRIBUTE_ELEMENT = "attribute"; 116 public static final String MAGIC_ATTRIBUTE_ELEMENT_ATTRIBUTE = "name"; 117 public static final String MAGIC_ATTRIBUTE_ELEMENT_MODE_ATTRIBUTE = "mode"; 118 public static final String MAGIC_ATTRIBUTE_ELEMENT_MODE_ATTRIBUTE_DEFAULT = "replace"; 119 public static final String MAGIC_ATTRIBUTE_ELEMENT_MODE_ATTRIBUTE_VALUE_A = "append"; 120 public static final String MAGIC_AUTHENTICATION_ELEMENT = "authentication"; 121 public static final String MAGIC_COUNT_LIMIT_ELEMENT = "count-limit"; 122 public static final String MAGIC_DEBUG_ELEMENT = "debug"; 123 public static final String MAGIC_DEREF_LINK_ELEMENT = "deref-link"; 124 public static final String MAGIC_DOC_ELEMENT = "doc-element"; 125 public static final String MAGIC_ENCODING_ELEMENT = "encoding"; 126 public static final String MAGIC_ERROR_ELEMENT = "error-element"; 127 public static final String MAGIC_EXECUTE_ADD = "execute-add"; 128 public static final String MAGIC_EXECUTE_INCREMENT = "execute-increment"; 129 public static final String MAGIC_EXECUTE_QUERY = "execute-query"; 130 public static final String MAGIC_EXECUTE_REPLACE = "execute-replace"; 131 public static final String MAGIC_FILTER_ELEMENT = "filter"; 132 public static final String MAGIC_INITIALIZER_ELEMENT = "initializer"; 133 public static final String MAGIC_PASSWORD_ELEMENT = "password"; 134 public static final String MAGIC_PORT_ELEMENT = "port"; 135 public static final String MAGIC_ROOT_DN_ELEMENT = "rootdn"; 136 public static final String MAGIC_ROW_ELEMENT = "row-element"; 137 public static final String MAGIC_SAX_ERROR = "sax-error"; 138 public static final String MAGIC_SCOPE_ELEMENT = "scope"; 139 public static final String MAGIC_SEARCHBASE_ELEMENT = "searchbase"; 140 public static final String MAGIC_SERVERURL_ELEMENT = "serverurl"; 141 public static final String MAGIC_SHOW_ATTRIBUTE_ELEMENT = "show-attribute"; 142 public static final String MAGIC_TIME_LIMIT_ELEMENT = "time-limit"; 143 public static final String MAGIC_VERSION_ELEMENT = "version"; 144 145 146 public static final int STATE_OUTSIDE = 0; 147 public static final int STATE_INSIDE_EXECUTE_QUERY = 1; 148 public static final int STATE_INSIDE_EXECUTE_INCREMENT = 2; 149 public static final int STATE_INSIDE_EXECUTE_ELEMENT = 3; 150 public static final int STATE_INSIDE_INITIALIZER_ELEMENT = 4; 151 public static final int STATE_INSIDE_SERVERURL_ELEMENT = 5; 152 public static final int STATE_INSIDE_PORT_ELEMENT = 6; 153 public static final int STATE_INSIDE_SCOPE_ELEMENT = 7; 154 public static final int STATE_INSIDE_VERSION_ELEMENT = 8; 155 public static final int STATE_INSIDE_AUTHENTICATION_ELEMENT = 9; 156 public static final int STATE_INSIDE_ROOT_DN_ELEMENT = 10; 157 public static final int STATE_INSIDE_PASSWORD_ELEMENT = 11; 158 public static final int STATE_INSIDE_SEARCHBASE_ELEMENT = 12; 159 public static final int STATE_INSIDE_DOC_ELEMENT = 13; 160 public static final int STATE_INSIDE_ROW_ELEMENT = 14; 161 public static final int STATE_INSIDE_ATTRIBUTE_ELEMENT = 15; 162 public static final int STATE_INSIDE_SHOW_ATTRIBUTE_ELEMENT = 16; 163 public static final int STATE_INSIDE_ERROR_ELEMENT = 17; 164 public static final int STATE_INSIDE_FILTER_ELEMENT = 18; 165 public static final int STATE_INSIDE_DEREF_LINK_ELEMENT = 19; 166 public static final int STATE_INSIDE_COUNT_LIMIT_ELEMENT = 20; 167 public static final int STATE_INSIDE_TIME_LIMIT_ELEMENT = 21; 168 public static final int STATE_INSIDE_DEBUG_ELEMENT = 22; 169 public static final int STATE_INSIDE_SAX_ERROR_ELEMENT = 23; 170 public static final int STATE_INSIDE_EXECUTE_REPLACE = 24; 171 public static final int STATE_INSIDE_EXECUTE_ADD = 25; 172 173 174 protected HashMap default_properties = new HashMap (); 175 176 177 protected String current_name; 178 179 180 protected int current_state = STATE_OUTSIDE; 181 182 183 protected StringBuffer current_value = new StringBuffer (); 184 185 186 protected Vector queries = new Vector (); 187 188 189 protected int current_query_index = -1; 190 191 192 protected XMLConsumer xml_consumer; 193 protected LexicalHandler lexical_handler; 194 195 196 197 public void setup(SourceResolver resolver, Map objectModel, String source, Parameters parameters) 198 throws ProcessingException, SAXException , IOException { 199 current_state = STATE_OUTSIDE; 200 201 setDefaultProperty(parameters, MAGIC_INITIALIZER_ELEMENT); setDefaultProperty(parameters, MAGIC_VERSION_ELEMENT); setDefaultProperty(parameters, MAGIC_AUTHENTICATION_ELEMENT); setDefaultProperty(parameters, MAGIC_SCOPE_ELEMENT); setDefaultProperty(parameters, MAGIC_SERVERURL_ELEMENT); setDefaultProperty(parameters, MAGIC_ROOT_DN_ELEMENT); setDefaultProperty(parameters, MAGIC_PASSWORD_ELEMENT); setDefaultProperty(parameters, MAGIC_PORT_ELEMENT); setDefaultProperty(parameters, MAGIC_SEARCHBASE_ELEMENT); setDefaultProperty(parameters, MAGIC_DOC_ELEMENT); setDefaultProperty(parameters, MAGIC_ROW_ELEMENT); setDefaultProperty(parameters, MAGIC_ERROR_ELEMENT); setDefaultProperty(parameters, MAGIC_SAX_ERROR); setDefaultProperty(parameters, MAGIC_DEREF_LINK_ELEMENT); setDefaultProperty(parameters, MAGIC_COUNT_LIMIT_ELEMENT); setDefaultProperty(parameters, MAGIC_TIME_LIMIT_ELEMENT); setDefaultProperty(parameters, MAGIC_DEBUG_ELEMENT); setDefaultProperty(parameters, MAGIC_ENCODING_ELEMENT); setDefaultProperty(parameters, MAGIC_FILTER_ELEMENT); } 221 222 223 224 225 protected void setDefaultProperty(Parameters parameters, String propertyName) { 226 String parameter = parameters.getParameter(propertyName, null); 227 if (parameter != null) { 228 default_properties.put(propertyName, parameter); 229 } 230 } 231 232 233 protected void storeQuery(int nextState) { 234 current_state = nextState; 235 current_query_index = queries.size(); 236 LDAPQuery query = new LDAPQuery(this); 237 queries.addElement(query); 238 getCurrentQuery().toDo = nextState; 239 getCurrentQuery().query_index = current_query_index; 240 } 241 242 245 protected void executeQuery(int index) throws SAXException { 246 this.contentHandler.startPrefixMapping("", LDAPTransformer.my_uri); 247 LDAPQuery query = (LDAPQuery)queries.elementAt(index); 248 try { 249 query.execute(); 250 } catch (NamingException e) { 251 getLogger().error(e.toString()); 252 throw new SAXException (e); 253 } catch (Exception e) { 254 getLogger().error(e.toString()); 255 throw new SAXException (e); 256 } 257 this.contentHandler.endPrefixMapping(""); 258 } 259 260 protected static void throwIllegalStateException(String message) { 261 throw new IllegalStateException (my_name + ": " + message); 262 } 263 264 protected void startExecuteElement() { 265 switch (current_state) { 266 case LDAPTransformer.STATE_OUTSIDE : 267 case LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT : 268 storeQuery(LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY); 269 break; 270 default : 271 throwIllegalStateException("Not expecting a start execute-query element"); 272 } 273 } 274 275 protected void startExecuteElement(int state, String name) { 276 switch (current_state) { 277 case LDAPTransformer.STATE_OUTSIDE : 278 case LDAPTransformer.STATE_INSIDE_EXECUTE_QUERY : 279 storeQuery(state); 280 break; 281 default : 282 throwIllegalStateException("Not expecting a start " + name + " element"); 283 } 284 } 285 286 protected void endExecuteElement(int state, String name) throws SAXException { 287 if (current_state == state) { 288 executeQuery(current_query_index); 289 queries.remove(current_query_index); 290 --current_query_index; 291 if (current_query_index > -1) { 292 current_state = getCurrentQuery().toDo; 293 } else { 294 queries.removeAllElements(); 295 current_state = LDAPTransformer.STATE_OUTSIDE; 296 } 297 } else { 298 throwIllegalStateException("Not expecting a end " + name + " element"); 299 } 300 } 301 302 protected void startQueryParameterElement(int state, String name) { 303 switch (current_state) { 304 case STATE_INSIDE_EXECUTE_QUERY : 305 case STATE_INSIDE_EXECUTE_INCREMENT : 306 case STATE_INSIDE_EXECUTE_REPLACE : 307 case STATE_INSIDE_EXECUTE_ADD : 308 current_value.setLength(0); 309 current_state = state; 310 getCurrentQuery().current_state = state; 311 break; 312 default : 313 throwIllegalStateException("Not expecting a start " + name + " element"); 314 } 315 } 316 317 protected void startParameterElement(int state, String name) { 318 switch (current_state) { 319 case STATE_INSIDE_EXECUTE_QUERY : 320 case STATE_INSIDE_EXECUTE_INCREMENT : 321 case STATE_INSIDE_EXECUTE_REPLACE : 322 case STATE_INSIDE_EXECUTE_ADD : 323 current_value.setLength(0); 324 current_state = state; 325 break; 326 default : 327 throwIllegalStateException("Not expecting a start " + name + " serverurl element"); 328 } 329 } 330 331 protected void endInitializerElement() { 332 switch (current_state) { 333 case LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT : 334 getCurrentQuery().initializer = current_value.toString(); 335 current_state = getCurrentQuery().toDo; 336 break; 337 default : 338 throwIllegalStateException("Not expecting a end initializer element"); 339 } 340 } 341 342 protected void endScopeElement() { 343 switch (current_state) { 344 case LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT : 345 getCurrentQuery().scope = current_value.toString(); 346 current_state = getCurrentQuery().toDo; 347 break; 348 default : 349 throwIllegalStateException("Not expecting a end scope element"); 350 } 351 } 352 353 protected void endAuthenticationElement() { 354 switch (current_state) { 355 case LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT : 356 getCurrentQuery().authentication = current_value.toString(); 357 current_state = getCurrentQuery().toDo; 358 break; 359 default : 360 throwIllegalStateException("Not expecting a end authentication element"); 361 } 362 } 363 364 protected void endServerurlElement() { 365 switch (current_state) { 366 case LDAPTransformer.STATE_INSIDE_SERVERURL_ELEMENT : 367 getCurrentQuery().serverurl = current_value.toString(); 368 current_state = getCurrentQuery().toDo; 369 break; 370 default : 371 throwIllegalStateException("Not expecting a end serverurl element"); 372 } 373 } 374 375 protected void endPortElement() { 376 switch (current_state) { 377 case LDAPTransformer.STATE_INSIDE_PORT_ELEMENT : 378 getCurrentQuery().port = Integer.parseInt(current_value.toString()); 379 current_state = getCurrentQuery().toDo; 380 break; 381 default : 382 throwIllegalStateException("Not expecting a end server element"); 383 } 384 } 385 386 protected void startShowAttributeElement(Attributes attributes) { 387 switch (current_state) { 388 case STATE_INSIDE_EXECUTE_QUERY : 389 case STATE_INSIDE_EXECUTE_INCREMENT : 390 current_value.setLength(0); 392 current_state = LDAPTransformer.STATE_INSIDE_SHOW_ATTRIBUTE_ELEMENT; 393 break; 394 default : 395 throwIllegalStateException("Not expecting a start show-attribute element"); 396 } 397 } 398 399 protected void endShowAttributeElement() { 400 switch (current_state) { 401 case LDAPTransformer.STATE_INSIDE_SHOW_ATTRIBUTE_ELEMENT : 402 if (!BooleanUtils.toBoolean(current_value.toString())) { 403 getCurrentQuery().showAttribute = false; 404 } 405 current_state = getCurrentQuery().toDo; 406 break; 407 default : 408 throwIllegalStateException("Not expecting a end show-attribute element"); 409 } 410 } 411 412 protected void endSearchbaseElement() { 413 switch (current_state) { 414 case LDAPTransformer.STATE_INSIDE_SEARCHBASE_ELEMENT : 415 getCurrentQuery().searchbase = current_value.toString(); 416 current_state = getCurrentQuery().toDo; 417 break; 418 default : 419 throwIllegalStateException("Not expecting a end searchbase element"); 420 } 421 } 422 423 protected void endDocElement() { 424 switch (current_state) { 425 case LDAPTransformer.STATE_INSIDE_DOC_ELEMENT : 426 getCurrentQuery().doc_element = current_value.toString(); 427 current_state = getCurrentQuery().toDo; 428 break; 429 default : 430 throwIllegalStateException("Not expecting a end doc-element element"); 431 } 432 } 433 434 protected void endRowElement() { 435 switch (current_state) { 436 case LDAPTransformer.STATE_INSIDE_ROW_ELEMENT : 437 getCurrentQuery().row_element = current_value.toString(); 438 current_state = getCurrentQuery().toDo; 439 break; 440 default : 441 throwIllegalStateException("Not expecting a end row-element element"); 442 } 443 } 444 445 protected void endErrorElement() { 446 switch (current_state) { 447 case LDAPTransformer.STATE_INSIDE_ERROR_ELEMENT : 448 getCurrentQuery().error_element = current_value.toString(); 449 current_state = getCurrentQuery().toDo; 450 break; 451 default : 452 throwIllegalStateException("Not expecting a end error-element element"); 453 } 454 } 455 456 protected void endSaxError() { 457 switch (current_state) { 458 case LDAPTransformer.STATE_INSIDE_SAX_ERROR_ELEMENT : 459 if (current_value.toString().toUpperCase().equals("TRUE")) { 460 getCurrentQuery().sax_error = true; 461 } 462 current_state = getCurrentQuery().toDo; 463 break; 464 default : 465 throwIllegalStateException("Not expecting a end sax-error element"); 466 } 467 } 468 469 protected void endRootDnElement() { 470 switch (current_state) { 471 case LDAPTransformer.STATE_INSIDE_ROOT_DN_ELEMENT : 472 getCurrentQuery().root_dn = current_value.toString(); 473 current_state = getCurrentQuery().toDo; 474 break; 475 default : 476 throwIllegalStateException("Not expecting a end root-dn element"); 477 } 478 } 479 480 protected void endPasswordElement() { 481 switch (current_state) { 482 case LDAPTransformer.STATE_INSIDE_PASSWORD_ELEMENT : 483 getCurrentQuery().password = current_value.toString(); 484 current_state = getCurrentQuery().toDo; 485 break; 486 default : 487 throwIllegalStateException("Not expecting a end password element"); 488 } 489 } 490 491 protected void startAttributeElement(Attributes attributes) { 492 switch (current_state) { 493 case STATE_INSIDE_EXECUTE_QUERY : 494 case STATE_INSIDE_EXECUTE_INCREMENT : 495 current_state = LDAPTransformer.STATE_INSIDE_ATTRIBUTE_ELEMENT; 496 current_value.setLength(0); 497 break; 498 case STATE_INSIDE_EXECUTE_REPLACE : 499 boolean is_name_present = false; 500 String mode = MAGIC_ATTRIBUTE_ELEMENT_MODE_ATTRIBUTE_DEFAULT; 501 if (attributes != null && attributes.getLength() > 0) { 502 AttributesImpl new_attributes = new AttributesImpl (attributes); 503 for (int i = 0; i < new_attributes.getLength(); i++) { 504 String attr_name = new_attributes.getLocalName(i); 505 if (attr_name.equals(MAGIC_ATTRIBUTE_ELEMENT_ATTRIBUTE)) { 506 String value = new_attributes.getValue(i); 507 getCurrentQuery().addAttrList(value); 508 is_name_present = true; 509 } else if (attr_name.equals(MAGIC_ATTRIBUTE_ELEMENT_MODE_ATTRIBUTE)) { 510 if (new_attributes.getValue(i).equals(MAGIC_ATTRIBUTE_ELEMENT_MODE_ATTRIBUTE_VALUE_A)) 511 mode = MAGIC_ATTRIBUTE_ELEMENT_MODE_ATTRIBUTE_VALUE_A; 512 } else { 513 this.getLogger().debug("Invalid attribute match: " + attr_name); 514 throwIllegalStateException("Invalid attribute match in start attribute element"); 515 } 516 } 517 } 518 if (!is_name_present) { 519 this.getLogger().debug("Do not match 'value' attribute"); 520 throwIllegalStateException("Do not match 'value' attribute in start attribute element"); 521 } 522 getCurrentQuery().addAttrModeVal(mode); 523 current_state = LDAPTransformer.STATE_INSIDE_ATTRIBUTE_ELEMENT; 524 current_value.setLength(0); 525 break; 526 case STATE_INSIDE_EXECUTE_ADD : 527 if (attributes != null && attributes.getLength() > 0) { 528 AttributesImpl new_attributes = new AttributesImpl (attributes); 529 for (int i = 0; i < new_attributes.getLength(); i++) { 530 String attr_name = new_attributes.getLocalName(i); 531 if (attr_name.equals(MAGIC_ATTRIBUTE_ELEMENT_ATTRIBUTE)) { 532 String value = new_attributes.getValue(i); 533 getCurrentQuery().addAttrList(value); 534 } else { 535 this.getLogger().debug("Invalid attribute match: " + attr_name); 536 throwIllegalStateException("Invalid attribute match in start attribute element"); 537 } 538 } 539 } else { 540 this.getLogger().debug("Do not match 'value' attribute"); 541 throwIllegalStateException("Do not match 'value' attribute in start attribute element"); 542 } 543 current_state = LDAPTransformer.STATE_INSIDE_ATTRIBUTE_ELEMENT; 544 current_value.setLength(0); 545 break; 546 default : 547 throwIllegalStateException("Not expecting a start attribute element"); 548 } 549 } 550 551 protected void endAttributeElement() { 552 switch (current_state) { 553 case LDAPTransformer.STATE_INSIDE_ATTRIBUTE_ELEMENT : 554 if ((getCurrentQuery().toDo == STATE_INSIDE_EXECUTE_REPLACE) || (getCurrentQuery().toDo == STATE_INSIDE_EXECUTE_ADD)) { 555 getCurrentQuery().addAttrVal(current_value.toString()); 556 current_state = getCurrentQuery().toDo; 557 break; 558 } 559 getCurrentQuery().addAttrList(current_value.toString()); 560 current_state = getCurrentQuery().toDo; 561 break; 562 default : 563 throwIllegalStateException("Not expecting a end attribute element"); 564 } 565 } 566 567 protected void endVersionElement() { 568 switch (current_state) { 569 case LDAPTransformer.STATE_INSIDE_VERSION_ELEMENT : 570 getCurrentQuery().version = current_value.toString(); 571 current_state = getCurrentQuery().toDo; 572 break; 573 default : 574 throwIllegalStateException("Not expecting a end version element"); 575 } 576 } 577 578 protected void startFilterElement(Attributes attributes) { 579 switch (current_state) { 580 case STATE_INSIDE_EXECUTE_QUERY : 581 case STATE_INSIDE_EXECUTE_INCREMENT : 582 case STATE_INSIDE_EXECUTE_REPLACE : 583 case STATE_INSIDE_EXECUTE_ADD : 584 current_state = LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT; 585 getCurrentQuery().current_state = LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT; 586 current_value.setLength(0); 587 break; 588 default : 589 throwIllegalStateException("Not expecting a start filter element"); 590 } 591 } 592 593 protected void endFilterElement() { 594 switch (current_state) { 595 case LDAPTransformer.STATE_INSIDE_FILTER_ELEMENT : 596 getCurrentQuery().filter = current_value.toString(); 597 current_state = getCurrentQuery().toDo; 598 break; 599 default : 600 throwIllegalStateException("Not expecting a end filter element"); 601 } 602 } 603 604 protected void endDerefLinkElement() { 605 switch (current_state) { 606 case LDAPTransformer.STATE_INSIDE_DEREF_LINK_ELEMENT : 607 getCurrentQuery().deref_link = BooleanUtils.toBoolean(current_value.toString()); 608 current_state = getCurrentQuery().toDo; 609 break; 610 default : 611 throwIllegalStateException("Not expecting a end deref-link element"); 612 } 613 } 614 615 protected void endCountLimitElement() { 616 switch (current_state) { 617 case LDAPTransformer.STATE_INSIDE_COUNT_LIMIT_ELEMENT : 618 getCurrentQuery().count_limit = Integer.parseInt(current_value.toString()); 619 current_state = getCurrentQuery().toDo; 620 break; 621 default : 622 throwIllegalStateException("Not expecting a end count-limit element"); 623 } 624 } 625 626 protected void endTimeLimitElement() { 627 switch (current_state) { 628 case LDAPTransformer.STATE_INSIDE_TIME_LIMIT_ELEMENT : 629 getCurrentQuery().time_limit = Integer.parseInt(current_value.toString()); 630 current_state = getCurrentQuery().toDo; 631 break; 632 default : 633 throwIllegalStateException("Not expecting a end time-limit element"); 634 } 635 } 636 637 protected void endDebugElement() { 638 switch (current_state) { 639 case LDAPTransformer.STATE_INSIDE_DEBUG_ELEMENT : 640 getCurrentQuery().debug = BooleanUtils.toBoolean(current_value.toString()); 641 current_state = getCurrentQuery().toDo; 642 break; 643 default : 644 throwIllegalStateException("Not expecting a end debug element"); 645 } 646 } 647 648 protected LDAPQuery getCurrentQuery() { 649 return (LDAPQuery)queries.elementAt(current_query_index); 650 } 651 652 protected LDAPQuery getQuery(int i) { 653 return (LDAPQuery)queries.elementAt(i); 654 } 655 656 657 658 659 660 public void setDocumentLocator(Locator locator) { 661 if (getLogger().isDebugEnabled()) { 662 getLogger().debug("PUBLIC ID: " + locator.getPublicId()); 663 getLogger().debug("SYSTEM ID: " + locator.getSystemId()); 664 } 665 if (super.contentHandler != null) 666 super.contentHandler.setDocumentLocator(locator); 667 } 668 669 public void startElement(String uri, String name, String raw, Attributes attributes) throws SAXException { 670 if (!uri.equals(my_uri)) { 671 super.startElement(uri, name, raw, attributes); 672 return; 673 } 674 getLogger().debug("RECEIVED START ELEMENT " + name + "(" + uri + ")"); 675 676 if (name.equals(LDAPTransformer.MAGIC_EXECUTE_QUERY)) { 677 startExecuteElement(); 678 } else if (name.equals(LDAPTransformer.MAGIC_EXECUTE_INCREMENT)) { 679 startExecuteElement(LDAPTransformer.STATE_INSIDE_EXECUTE_INCREMENT, name); 680 } else if (name.equals(LDAPTransformer.MAGIC_INITIALIZER_ELEMENT)) { 681 startQueryParameterElement(LDAPTransformer.STATE_INSIDE_INITIALIZER_ELEMENT, name); 682 } else if (name.equals(LDAPTransformer.MAGIC_AUTHENTICATION_ELEMENT)) { 683 startQueryParameterElement(LDAPTransformer.STATE_INSIDE_AUTHENTICATION_ELEMENT, name); 684 } else if (name.equals(LDAPTransformer.MAGIC_SCOPE_ELEMENT)) { 685 startQueryParameterElement(LDAPTransformer.STATE_INSIDE_SCOPE_ELEMENT, name); 686 } else if (name.equals(LDAPTransformer.MAGIC_VERSION_ELEMENT)) { 687 startParameterElement(LDAPTransformer.STATE_INSIDE_VERSION_ELEMENT, name); 688 } else if (name.equals(LDAPTransformer.MAGIC_SERVERURL_ELEMENT)) { 689 startParameterElement(LDAPTransformer.STATE_INSIDE_SERVERURL_ELEMENT, name); 690 } else if (name.equals(LDAPTransformer.MAGIC_PORT_ELEMENT)) { 691 startParameterElement(LDAPTransformer.STATE_INSIDE_PORT_ELEMENT, name); 692 } else if (name.equa
|