001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.shared.dsmlv2.reponse; 021 022 023import java.io.IOException; 024import java.lang.reflect.Array; 025import java.util.HashMap; 026import java.util.HashSet; 027import java.util.Set; 028 029import org.apache.directory.shared.asn1.DecoderException; 030import org.apache.directory.shared.asn1.util.Oid; 031import org.apache.directory.shared.dsmlv2.AbstractDsmlMessageDecorator; 032import org.apache.directory.shared.dsmlv2.AbstractGrammar; 033import org.apache.directory.shared.dsmlv2.DsmlControl; 034import org.apache.directory.shared.dsmlv2.DsmlDecorator; 035import org.apache.directory.shared.dsmlv2.Dsmlv2Container; 036import org.apache.directory.shared.dsmlv2.Dsmlv2StatesEnum; 037import org.apache.directory.shared.dsmlv2.Grammar; 038import org.apache.directory.shared.dsmlv2.GrammarAction; 039import org.apache.directory.shared.dsmlv2.GrammarTransition; 040import org.apache.directory.shared.dsmlv2.ParserUtils; 041import org.apache.directory.shared.dsmlv2.Tag; 042import org.apache.directory.shared.dsmlv2.reponse.ErrorResponse.ErrorResponseType; 043import org.apache.directory.shared.i18n.I18n; 044import org.apache.directory.shared.ldap.codec.api.CodecControl; 045import org.apache.directory.shared.ldap.model.exception.LdapException; 046import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException; 047import org.apache.directory.shared.ldap.model.exception.LdapURLEncodingException; 048import org.apache.directory.shared.ldap.model.message.AddResponseImpl; 049import org.apache.directory.shared.ldap.model.message.BindResponseImpl; 050import org.apache.directory.shared.ldap.model.message.CompareResponseImpl; 051import org.apache.directory.shared.ldap.model.message.Control; 052import org.apache.directory.shared.ldap.model.message.DeleteResponseImpl; 053import org.apache.directory.shared.ldap.model.message.ExtendedResponse; 054import org.apache.directory.shared.ldap.model.message.ExtendedResponseImpl; 055import org.apache.directory.shared.ldap.model.message.LdapResult; 056import org.apache.directory.shared.ldap.model.message.Message; 057import org.apache.directory.shared.ldap.model.message.ModifyDnResponseImpl; 058import org.apache.directory.shared.ldap.model.message.ModifyResponseImpl; 059import org.apache.directory.shared.ldap.model.message.ReferralImpl; 060import org.apache.directory.shared.ldap.model.message.Response; 061import org.apache.directory.shared.ldap.model.message.ResultCodeEnum; 062import org.apache.directory.shared.ldap.model.message.ResultResponse; 063import org.apache.directory.shared.ldap.model.message.SearchResultDoneImpl; 064import org.apache.directory.shared.ldap.model.message.SearchResultEntryImpl; 065import org.apache.directory.shared.ldap.model.message.SearchResultReference; 066import org.apache.directory.shared.ldap.model.message.SearchResultReferenceImpl; 067import org.apache.directory.shared.ldap.model.message.controls.OpaqueControl; 068import org.apache.directory.shared.ldap.model.name.Dn; 069import org.apache.directory.shared.ldap.model.url.LdapUrl; 070import org.apache.directory.shared.util.Base64; 071import org.apache.directory.shared.util.Strings; 072import org.xmlpull.v1.XmlPullParser; 073import org.xmlpull.v1.XmlPullParserException; 074 075 076/** 077 * This Class represents the DSMLv2 Response Grammar 078 * 079 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 080 */ 081public final class Dsmlv2ResponseGrammar extends AbstractGrammar implements Grammar 082{ 083 /** The instance of grammar. Dsmlv2ResponseGrammar is a singleton */ 084 private static Dsmlv2ResponseGrammar instance = new Dsmlv2ResponseGrammar(); 085 086 /** The DSMLv2 description tags */ 087 private static final Set<String> DSMLV2_DESCR_TAGS; 088 static 089 { 090 DSMLV2_DESCR_TAGS = new HashSet<String>(); 091 DSMLV2_DESCR_TAGS.add( "success" ); 092 DSMLV2_DESCR_TAGS.add( "operationsError" ); 093 DSMLV2_DESCR_TAGS.add( "protocolError" ); 094 DSMLV2_DESCR_TAGS.add( "timeLimitExceeded" ); 095 DSMLV2_DESCR_TAGS.add( "sizeLimitExceeded" ); 096 DSMLV2_DESCR_TAGS.add( "compareFalse" ); 097 DSMLV2_DESCR_TAGS.add( "compareTrue" ); 098 DSMLV2_DESCR_TAGS.add( "authMethodNotSupported" ); 099 DSMLV2_DESCR_TAGS.add( "strongAuthRequired" ); 100 DSMLV2_DESCR_TAGS.add( "referral" ); 101 DSMLV2_DESCR_TAGS.add( "adminLimitExceeded" ); 102 DSMLV2_DESCR_TAGS.add( "unavailableCriticalExtension" ); 103 DSMLV2_DESCR_TAGS.add( "confidentialityRequired" ); 104 DSMLV2_DESCR_TAGS.add( "saslBindInProgress" ); 105 DSMLV2_DESCR_TAGS.add( "noSuchAttribute" ); 106 DSMLV2_DESCR_TAGS.add( "undefinedAttributeType" ); 107 DSMLV2_DESCR_TAGS.add( "inappropriateMatching" ); 108 DSMLV2_DESCR_TAGS.add( "constraintViolation" ); 109 DSMLV2_DESCR_TAGS.add( "attributeOrValueExists" ); 110 DSMLV2_DESCR_TAGS.add( "invalidAttributeSyntax" ); 111 DSMLV2_DESCR_TAGS.add( "noSuchObject" ); 112 DSMLV2_DESCR_TAGS.add( "aliasProblem" ); 113 DSMLV2_DESCR_TAGS.add( "invalidDNSyntax" ); 114 DSMLV2_DESCR_TAGS.add( "aliasDereferencingProblem" ); 115 DSMLV2_DESCR_TAGS.add( "inappropriateAuthentication" ); 116 DSMLV2_DESCR_TAGS.add( "invalidCredentials" ); 117 DSMLV2_DESCR_TAGS.add( "insufficientAccessRights" ); 118 DSMLV2_DESCR_TAGS.add( "busy" ); 119 DSMLV2_DESCR_TAGS.add( "unavailable" ); 120 DSMLV2_DESCR_TAGS.add( "unwillingToPerform" ); 121 DSMLV2_DESCR_TAGS.add( "loopDetect" ); 122 DSMLV2_DESCR_TAGS.add( "namingViolation" ); 123 DSMLV2_DESCR_TAGS.add( "objectClassViolation" ); 124 DSMLV2_DESCR_TAGS.add( "notAllowedOnNonLeaf" ); 125 DSMLV2_DESCR_TAGS.add( "notAllowedOnRDN" ); 126 DSMLV2_DESCR_TAGS.add( "entryAlreadyExists" ); 127 DSMLV2_DESCR_TAGS.add( "objectClassModsProhibited" ); 128 DSMLV2_DESCR_TAGS.add( "affectMultipleDSAs" ); 129 DSMLV2_DESCR_TAGS.add( "other" ); 130 } 131 132 133 @SuppressWarnings("unchecked") 134 private Dsmlv2ResponseGrammar() 135 { 136 name = Dsmlv2ResponseGrammar.class.getName(); 137 138 // Create the transitions table 139 super.transitions = ( HashMap<Tag, GrammarTransition>[] ) Array.newInstance( HashMap.class, 300 ); // TODO Change this value 140 141 //==================================================== 142 // Transitions concerning : BATCH RESPONSE 143 //==================================================== 144 super.transitions[Dsmlv2StatesEnum.INIT_GRAMMAR_STATE.ordinal()] = new HashMap<Tag, GrammarTransition>(); 145 146 // ** OPEN BATCH Reponse ** 147 // State: [INIT_GRAMMAR_STATE] - Tag: <batchResponse> 148 super.transitions[Dsmlv2StatesEnum.INIT_GRAMMAR_STATE.ordinal()].put( new Tag( "batchResponse", Tag.START ), 149 new GrammarTransition( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, 150 batchResponseCreation ) ); 151 152 //==================================================== 153 // Transitions concerning : BATCH RESPONSE LOOP 154 //==================================================== 155 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()] = new HashMap<Tag, GrammarTransition>(); 156 157 // State: [BATCH_RESPONSE_LOOP] - Tag: <addResponse> 158 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "addResponse", Tag.START ), 159 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT, 160 addResponseCreation ) ); 161 162 // State: [BATCH_RESPONSE_LOOP] - Tag: <authResponse> 163 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "authResponse", Tag.START ), 164 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT, 165 authResponseCreation ) ); 166 167 // State: [BATCH_RESPONSE_LOOP] - Tag: <compareResponse> 168 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "compareResponse", Tag.START ), 169 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT, 170 compareResponseCreation ) ); 171 172 // State: [BATCH_RESPONSE_LOOP] - Tag: <delResponse> 173 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "delResponse", Tag.START ), 174 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT, 175 delResponseCreation ) ); 176 177 // State: [BATCH_RESPONSE_LOOP] - Tag: <modifyResponse> 178 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "modifyResponse", Tag.START ), 179 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT, 180 modifyResponseCreation ) ); 181 182 // State: [BATCH_RESPONSE_LOOP] - Tag: <modDNResponse> 183 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "modDNResponse", Tag.START ), 184 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT, 185 modDNResponseCreation ) ); 186 187 // State: [BATCH_RESPONSE_LOOP] - Tag: <extendedResponse> 188 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "extendedResponse", Tag.START ), 189 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.EXTENDED_RESPONSE, 190 extendedResponseCreation ) ); 191 192 // State: [BATCH_RESPONSE_LOOP] - Tag: <errorResponse> 193 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "errorResponse", Tag.START ), 194 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.ERROR_RESPONSE, 195 errorResponseCreation ) ); 196 197 // State: [BATCH_RESPONSE_LOOP] - Tag: <searchReponse> 198 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "searchResponse", Tag.START ), 199 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.SEARCH_RESPONSE, 200 searchResponseCreation ) ); 201 202 // State: [BATCH_RESPONSE_LOOP] - Tag: </batchResponse> 203 super.transitions[Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP.ordinal()].put( new Tag( "batchResponse", Tag.END ), 204 new GrammarTransition( Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, Dsmlv2StatesEnum.GRAMMAR_END, null ) ); 205 206 //==================================================== 207 // Transitions concerning : ERROR RESPONSE 208 //==================================================== 209 super.transitions[Dsmlv2StatesEnum.ERROR_RESPONSE.ordinal()] = new HashMap<Tag, GrammarTransition>(); 210 super.transitions[Dsmlv2StatesEnum.MESSAGE_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 211 super.transitions[Dsmlv2StatesEnum.DETAIL_START.ordinal()] = new HashMap<Tag, GrammarTransition>(); 212 super.transitions[Dsmlv2StatesEnum.DETAIL_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 213 214 // State: [ERROR_RESPONSE] - Tag: <message> 215 super.transitions[Dsmlv2StatesEnum.ERROR_RESPONSE.ordinal()].put( new Tag( "message", Tag.START ), new GrammarTransition( 216 Dsmlv2StatesEnum.ERROR_RESPONSE, Dsmlv2StatesEnum.MESSAGE_END, errorResponseAddMessage ) ); 217 218 // State: [ERROR_RESPONSE] - Tag: <detail> 219 super.transitions[Dsmlv2StatesEnum.ERROR_RESPONSE.ordinal()].put( new Tag( "detail", Tag.START ), new GrammarTransition( 220 Dsmlv2StatesEnum.ERROR_RESPONSE, Dsmlv2StatesEnum.DETAIL_START, errorResponseAddDetail ) ); 221 222 // State: [MESSAGE_END] - Tag: </errorResponse> 223 super.transitions[Dsmlv2StatesEnum.MESSAGE_END.ordinal()].put( new Tag( "errorResponse", Tag.END ), 224 new GrammarTransition( Dsmlv2StatesEnum.MESSAGE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) ); 225 226 // State: [MESSAGE_END] - Tag: <detail> 227 super.transitions[Dsmlv2StatesEnum.MESSAGE_END.ordinal()].put( new Tag( "detail", Tag.START ), new GrammarTransition( 228 Dsmlv2StatesEnum.MESSAGE_END, Dsmlv2StatesEnum.DETAIL_START, errorResponseAddDetail ) ); 229 230 // State: [DETAIL_START] - Tag: </detail> 231 super.transitions[Dsmlv2StatesEnum.DETAIL_START.ordinal()].put( new Tag( "detail", Tag.END ), new GrammarTransition( 232 Dsmlv2StatesEnum.DETAIL_START, Dsmlv2StatesEnum.DETAIL_END, null ) ); 233 234 // State: [DETAIL_END] - Tag: <detail> 235 super.transitions[Dsmlv2StatesEnum.DETAIL_END.ordinal()].put( new Tag( "detail", Tag.END ), new GrammarTransition( 236 Dsmlv2StatesEnum.DETAIL_END, Dsmlv2StatesEnum.DETAIL_END, errorResponseAddDetail ) ); 237 238 // State: [ERROR_RESPONSE] - Tag: </errorResponse> 239 super.transitions[Dsmlv2StatesEnum.ERROR_RESPONSE.ordinal()].put( new Tag( "errorResponse", Tag.END ), 240 new GrammarTransition( Dsmlv2StatesEnum.ERROR_RESPONSE, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) ); 241 242 //==================================================== 243 // Transitions concerning : EXTENDED RESPONSE 244 //==================================================== 245 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE.ordinal()] = new HashMap<Tag, GrammarTransition>(); 246 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START.ordinal()] = new HashMap<Tag, GrammarTransition>(); 247 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 248 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 249 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_START.ordinal()] = new HashMap<Tag, GrammarTransition>(); 250 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 251 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 252 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 253 super.transitions[Dsmlv2StatesEnum.RESPONSE_NAME_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 254 super.transitions[Dsmlv2StatesEnum.RESPONSE_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 255 256 // State: [EXTENDED_RESPONSE] - Tag: <control> 257 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE.ordinal()].put( new Tag( "control", Tag.START ), 258 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE, 259 Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START, ldapResultControlCreation ) ); 260 261 // State: [EXTENDED_RESPONSE_CONTROL_START] - Tag: <controlValue> 262 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START.ordinal()].put( new Tag( "controlValue", Tag.START ), 263 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START, 264 Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_END, ldapResultControlValueCreation ) ); 265 266 // State: [EXTENDED_RESPONSE_CONTROL_VALUE_END] - Tag: </control> 267 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_END.ordinal()].put( new Tag( "control", Tag.END ), 268 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_VALUE_END, 269 Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END, null ) ); 270 271 // State: [EXTENDED_RESPONSE_CONTROL_START] - Tag: </control> 272 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START.ordinal()].put( new Tag( "control", Tag.END ), 273 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START, 274 Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END, null ) ); 275 276 // State: [EXTENDED_RESPONSE_CONTROL_END] - Tag: <control> 277 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END.ordinal()].put( new Tag( "control", Tag.START ), 278 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END, 279 Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_START, ldapResultControlCreation ) ); 280 281 // State: [EXTENDED_RESPONSE_CONTROL_END] - Tag: <resultCode> 282 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END.ordinal()].put( new Tag( "resultCode", Tag.START ), 283 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_CONTROL_END, 284 Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_START, extendedResponseAddResultCode ) ); 285 286 // State: [EXTENDED_RESPONSE] - Tag: <resultCode> 287 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE.ordinal()].put( new Tag( "resultCode", Tag.START ), 288 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE, 289 Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_START, extendedResponseAddResultCode ) ); 290 291 // State: [EXTENDED_RESPONSE_RESULT_CODE_START] - Tag: </resultCode> 292 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_START.ordinal()].put( new Tag( "resultCode", Tag.END ), 293 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_START, 294 Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, null ) ); 295 296 // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: <errorMessage> 297 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END.ordinal()].put( 298 new Tag( "errorMessage", Tag.START ), new GrammarTransition( 299 Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, 300 Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END, extendedResponseAddErrorMessage ) ); 301 302 // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: <referral> 303 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END.ordinal()].put( new Tag( "referral", Tag.START ), 304 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, 305 Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, extendedResponseAddReferral ) ); 306 307 // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: <responseName> 308 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END.ordinal()].put( 309 new Tag( "responseName", Tag.START ), new GrammarTransition( 310 Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, Dsmlv2StatesEnum.RESPONSE_NAME_END, 311 extendedResponseAddResponseName ) ); 312 313 // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: <response> 314 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END.ordinal()].put( new Tag( "response", Tag.START ), 315 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, Dsmlv2StatesEnum.RESPONSE_END, 316 extendedResponseAddResponse ) ); 317 318 // State: [EXTENDED_RESPONSE_RESULT_CODE_END] - Tag: </extendedResponse> 319 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END.ordinal()].put( 320 new Tag( "extendedResponse", Tag.END ), new GrammarTransition( 321 Dsmlv2StatesEnum.EXTENDED_RESPONSE_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) ); 322 323 // State: [EXTENDED_RESPONSE_ERROR_MESSAGE_END] - Tag: <referral> 324 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END.ordinal()].put( new Tag( "referral", Tag.START ), 325 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END, 326 Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, extendedResponseAddReferral ) ); 327 328 // State: [EXTENDED_RESPONSE_ERROR_MESSAGE_END] - Tag: <responseName> 329 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END.ordinal()].put( 330 new Tag( "responseName", Tag.START ), new GrammarTransition( 331 Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END, Dsmlv2StatesEnum.RESPONSE_NAME_END, 332 extendedResponseAddResponseName ) ); 333 334 // State: [EXTENDED_RESPONSE_ERROR_MESSAGE_END] - Tag: <response> 335 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END.ordinal()].put( new Tag( "response", Tag.START ), 336 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END, Dsmlv2StatesEnum.RESPONSE_END, 337 extendedResponseAddResponse ) ); 338 339 // State: [EXTENDED_RESPONSE_ERROR_MESSAGE_END] - Tag: </extendedResponse> 340 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END.ordinal()].put( new Tag( "extendedResponse", 341 Tag.END ), new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_ERROR_MESSAGE_END, 342 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) ); 343 344 // State: [EXTENDED_RESPONSE_REFERRAL_END] - Tag: <referral> 345 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END.ordinal()].put( new Tag( "referral", Tag.START ), 346 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, 347 Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, extendedResponseAddReferral ) ); 348 349 // State: [EXTENDED_RESPONSE_REFERRAL_END] - Tag: <responseName> 350 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END.ordinal()].put( new Tag( "responseName", Tag.START ), 351 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, Dsmlv2StatesEnum.RESPONSE_NAME_END, 352 extendedResponseAddResponseName ) ); 353 354 // State: [EXTENDED_RESPONSE_REFERRAL_END] - Tag: <reponse> 355 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END.ordinal()].put( new Tag( "reponse", Tag.START ), 356 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, Dsmlv2StatesEnum.RESPONSE_END, 357 extendedResponseAddResponse ) ); 358 359 // State: [EXTENDED_RESPONSE_REFERRAL_END] - Tag: </extendedResponse> 360 super.transitions[Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END.ordinal()].put( new Tag( "extendedResponse", Tag.END ), 361 new GrammarTransition( Dsmlv2StatesEnum.EXTENDED_RESPONSE_REFERRAL_END, 362 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) ); 363 364 // State: [RESPONSE_NAME_END] - Tag: <response> 365 super.transitions[Dsmlv2StatesEnum.RESPONSE_NAME_END.ordinal()].put( new Tag( "response", Tag.START ), 366 new GrammarTransition( Dsmlv2StatesEnum.RESPONSE_NAME_END, Dsmlv2StatesEnum.RESPONSE_END, 367 extendedResponseAddResponse ) ); 368 369 // State: [RESPONSE_NAME_END] - Tag: </extendedResponse> 370 super.transitions[Dsmlv2StatesEnum.RESPONSE_NAME_END.ordinal()].put( new Tag( "extendedResponse", Tag.END ), 371 new GrammarTransition( Dsmlv2StatesEnum.RESPONSE_NAME_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) ); 372 373 // State: [RESPONSE_END] - Tag: </extendedResponse> 374 super.transitions[Dsmlv2StatesEnum.RESPONSE_END.ordinal()].put( new Tag( "extendedResponse", Tag.END ), 375 new GrammarTransition( Dsmlv2StatesEnum.RESPONSE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) ); 376 377 //==================================================== 378 // Transitions concerning : LDAP RESULT 379 //==================================================== 380 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT.ordinal()] = new HashMap<Tag, GrammarTransition>(); 381 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START.ordinal()] = new HashMap<Tag, GrammarTransition>(); 382 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 383 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 384 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_START.ordinal()] = new HashMap<Tag, GrammarTransition>(); 385 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 386 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 387 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 388 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 389 390 // State: [LDAP_RESULT] - Tag: <control> 391 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT.ordinal()].put( new Tag( "control", Tag.START ), new GrammarTransition( 392 Dsmlv2StatesEnum.LDAP_RESULT, Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START, ldapResultControlCreation ) ); 393 394 // State: [LDAP_RESULT] - Tag: <resultCode> 395 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT.ordinal()].put( new Tag( "resultCode", Tag.START ), new GrammarTransition( 396 Dsmlv2StatesEnum.LDAP_RESULT, Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_START, ldapResultAddResultCode ) ); 397 398 // State: [LDAP_RESULT_CONTROL_START] - Tag: <controlValue> 399 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START.ordinal()].put( new Tag( "controlValue", Tag.START ), 400 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START, 401 Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_END, ldapResultControlValueCreation ) ); 402 403 // State: [LDAP_RESULT_CONTROL_VALUE_END] - Tag: </control> 404 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_END.ordinal()].put( new Tag( "control", Tag.END ), 405 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_VALUE_END, 406 Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END, null ) ); 407 408 // State: [LDAP_RESULT_CONTROL_START] - Tag: </control> 409 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START.ordinal()].put( new Tag( "control", Tag.END ), 410 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START, 411 Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END, null ) ); 412 413 // State: [LDAP_RESULT_CONTROL_END] - Tag: <control> 414 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END.ordinal()].put( new Tag( "control", Tag.START ), 415 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END, 416 Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_START, ldapResultControlCreation ) ); 417 418 // State: [LDAP_RESULT_CONTROL_END] - Tag: <resultCode> 419 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END.ordinal()].put( new Tag( "resultCode", Tag.START ), 420 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_CONTROL_END, 421 Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_START, ldapResultAddResultCode ) ); 422 423 // State: [LDAP_RESULT_RESULT_CODE_START] - Tag: </resultCode> 424 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_START.ordinal()].put( new Tag( "resultCode", Tag.END ), 425 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_START, 426 Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, null ) ); 427 428 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: <errorMessage> 429 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put( new Tag( "errorMessage", Tag.START ), 430 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, 431 Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END, ldapResultAddErrorMessage ) ); 432 433 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: <referral> 434 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put( new Tag( "referral", Tag.START ), 435 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, 436 Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, ldapResultAddReferral ) ); 437 438 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </addResponse> 439 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put( new Tag( "addResponse", Tag.END ), 440 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, 441 null ) ); 442 443 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </authResponse> 444 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put( new Tag( "authResponse", Tag.END ), 445 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, 446 null ) ); 447 448 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </compareResponse> 449 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put( new Tag( "compareResponse", Tag.END ), 450 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, 451 null ) ); 452 453 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </delResponse> 454 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put( new Tag( "delResponse", Tag.END ), 455 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, 456 null ) ); 457 458 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </modifyResponse> 459 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put( new Tag( "modifyResponse", Tag.END ), 460 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, 461 null ) ); 462 463 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </modDNResponse> 464 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put( new Tag( "modDNResponse", Tag.END ), 465 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, 466 null ) ); 467 468 // State: [LDAP_RESULT_RESULT_CODE_END] - Tag: </searchResultDone> 469 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END.ordinal()].put( new Tag( "searchResultDone", Tag.END ), 470 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_RESULT_CODE_END, 471 Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END, null ) ); 472 473 // State: [SEARCH_RESULT_DONE_END] - Tag: </searchResponse> 474 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END.ordinal()] 475 .put( new Tag( "searchResponse", Tag.END ), new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END, 476 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) ); 477 478 // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: <referral> 479 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()].put( new Tag( "referral", Tag.START ), 480 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END, 481 Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, ldapResultAddReferral ) ); 482 483 // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </addResponse> 484 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()].put( new Tag( "addResponse", Tag.END ), 485 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END, 486 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) ); 487 488 // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </authResponse> 489 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()].put( new Tag( "authResponse", Tag.END ), 490 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END, 491 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) ); 492 493 // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </compareResponse> 494 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()].put( new Tag( "compareResponse", Tag.END ), 495 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END, 496 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) ); 497 498 // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </delResponse> 499 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()].put( new Tag( "delResponse", Tag.END ), 500 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END, 501 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) ); 502 503 // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </modifyResponse> 504 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()].put( new Tag( "modifyResponse", Tag.END ), 505 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END, 506 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) ); 507 508 // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </modDNResponse> 509 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()].put( new Tag( "modDNResponse", Tag.END ), 510 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END, 511 Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, null ) ); 512 513 // State: [LDAP_RESULT_ERROR_MESSAGE_END] - Tag: </searchResultDone> 514 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END.ordinal()].put( new Tag( "searchResultDone", Tag.END ), 515 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_ERROR_MESSAGE_END, 516 Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END, null ) ); 517 518 // State: [LDAP_RESULT_REFERRAL_END] - Tag: <referral> 519 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()].put( new Tag( "referral", Tag.START ), 520 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, 521 Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, ldapResultAddReferral ) ); 522 523 // State: [LDAP_RESULT_REFERRAL_END] - Tag: </addResponse> 524 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()].put( new Tag( "addResponse", Tag.END ), 525 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, 526 null ) ); 527 528 // State: [LDAP_RESULT_REFERRAL_END] - Tag: </authResponse> 529 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()].put( new Tag( "authResponse", Tag.END ), 530 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, 531 null ) ); 532 533 // State: [LDAP_RESULT_REFERRAL_END] - Tag: </compareResponse> 534 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()].put( new Tag( "compareResponse", Tag.END ), 535 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, 536 null ) ); 537 538 // State: [LDAP_RESULT_REFERRAL_END] - Tag: </delResponse> 539 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()].put( new Tag( "delResponse", Tag.END ), 540 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, 541 null ) ); 542 543 // State: [LDAP_RESULT_REFERRAL_END] - Tag: </modifyResponse> 544 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()].put( new Tag( "modifyResponse", Tag.END ), 545 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, 546 null ) ); 547 548 // State: [LDAP_RESULT_REFERRAL_END] - Tag: </modDNResponse> 549 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()].put( new Tag( "modDNResponse", Tag.END ), 550 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP, 551 null ) ); 552 553 // State: [LDAP_RESULT_REFERRAL_END] - Tag: </searchResultDone> 554 super.transitions[Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END.ordinal()].put( new Tag( "searchResultDone", Tag.END ), 555 new GrammarTransition( Dsmlv2StatesEnum.LDAP_RESULT_REFERRAL_END, Dsmlv2StatesEnum.SEARCH_RESULT_DONE_END, 556 null ) ); 557 558 //==================================================== 559 // Transitions concerning : SEARCH RESPONSE 560 //==================================================== 561 super.transitions[Dsmlv2StatesEnum.SEARCH_RESPONSE.ordinal()] = new HashMap<Tag, GrammarTransition>(); 562 563 // State: [SEARCH_REPONSE] - Tag: <searchResultEntry> 564 super.transitions[Dsmlv2StatesEnum.SEARCH_RESPONSE.ordinal()].put( new Tag( "searchResultEntry", Tag.START ), 565 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESPONSE, Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY, 566 searchResultEntryCreation ) ); 567 568 // State: [SEARCH_REPONSE] - Tag: <searchResultReference> 569 super.transitions[Dsmlv2StatesEnum.SEARCH_RESPONSE.ordinal()].put( new Tag( "searchResultReference", Tag.START ), 570 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESPONSE, Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE, 571 searchResultReferenceCreation ) ); 572 573 // State: [SEARCH_REPONSE] - Tag: <searchResultDone> 574 super.transitions[Dsmlv2StatesEnum.SEARCH_RESPONSE.ordinal()].put( new Tag( "searchResultDone", Tag.START ), 575 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESPONSE, Dsmlv2StatesEnum.LDAP_RESULT, 576 searchResultDoneCreation ) ); 577 578 //==================================================== 579 // Transitions concerning : SEARCH RESULT ENTRY 580 //==================================================== 581 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY.ordinal()] = new HashMap<Tag, GrammarTransition>(); 582 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START.ordinal()] = new HashMap<Tag, GrammarTransition>(); 583 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 584 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 585 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START.ordinal()] = new HashMap<Tag, GrammarTransition>(); 586 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 587 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 588 589 // State: [SEARCH_RESULT_ENTRY] - Tag: <control> 590 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY.ordinal()].put( new Tag( "control", Tag.START ), 591 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY, 592 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START, searchResultEntryControlCreation ) ); 593 594 // State: [SEARCH_RESULT_ENTRY] - Tag: <attr> 595 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY.ordinal()].put( new Tag( "attr", Tag.START ), 596 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY, 597 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START, searchResultEntryAddAttr ) ); 598 599 // State: [SEARCH_RESULT_ENTRY] - Tag: </searchResultEntry> 600 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY.ordinal()].put( new Tag( "searchResultEntry", Tag.END ), 601 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY, Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP, 602 null ) ); 603 604 // State: [SEARCH_RESULT_ENTRY_CONTROL_START] - Tag: <controlValue> 605 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START.ordinal()].put( 606 new Tag( "controlValue", Tag.START ), new GrammarTransition( 607 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START, 608 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_END, searchResultEntryControlValueCreation ) ); 609 610 // State: [SEARCH_RESULT_ENTRY_CONTROL_VALUE_END] - Tag: </control> 611 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_END.ordinal()].put( new Tag( "control", Tag.END ), 612 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_VALUE_END, 613 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END, null ) ); 614 615 // State: [SEARCH_RESULT_ENTRY_CONTROL_START] - Tag: </control> 616 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START.ordinal()].put( new Tag( "control", Tag.END ), 617 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START, 618 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END, null ) ); 619 620 // State: [SEARCH_RESULT_ENTRY_CONTROL_END] - Tag: <control> 621 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END.ordinal()].put( new Tag( "control", Tag.START ), 622 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END, 623 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_START, searchResultEntryControlCreation ) ); 624 625 // State: [SEARCH_RESULT_ENTRY_CONTROL_END] - Tag: </searchResultEntry> 626 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END.ordinal()].put( 627 new Tag( "searchResultEntry", Tag.END ), new GrammarTransition( 628 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END, Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP, null ) ); 629 630 // State: [SEARCH_RESULT_ENTRY_CONTROL_END] - Tag: <attr> 631 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END.ordinal()].put( new Tag( "attr", Tag.START ), 632 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_CONTROL_END, 633 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START, null ) ); 634 635 // State: [SEARCH_RESULT_ENTRY_ATTR_START] - Tag: </attr> 636 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START.ordinal()].put( new Tag( "attr", Tag.END ), 637 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START, 638 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END, null ) ); 639 640 // State: [SEARCH_RESULT_ENTRY_ATTR_START] - Tag: <value> 641 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START.ordinal()].put( new Tag( "value", Tag.START ), 642 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START, 643 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END, searchResultEntryAddValue ) ); 644 645 // State: [SEARCH_RESULT_ENTRY_ATTR_END] - Tag: <attr> 646 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END.ordinal()].put( new Tag( "attr", Tag.START ), 647 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END, 648 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_START, searchResultEntryAddAttr ) ); 649 650 // State: [SEARCH_RESULT_ENTRY_ATTR_END] - Tag: </searchResultEntry> 651 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END.ordinal()].put( new Tag( "searchResultEntry", Tag.END ), 652 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END, 653 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP, null ) ); 654 655 // State: [SEARCH_RESULT_ENTRY_VALUE_END] - Tag: <value> 656 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END.ordinal()].put( new Tag( "value", Tag.START ), 657 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END, 658 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END, searchResultEntryAddValue ) ); 659 660 // State: [SEARCH_RESULT_ENTRY_VALUE_END] - Tag: </attr> 661 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END.ordinal()].put( new Tag( "attr", Tag.END ), 662 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_VALUE_END, 663 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_ATTR_END, null ) ); 664 665 //==================================================== 666 // Transitions concerning : SEARCH RESULT ENTRY LOOP 667 //==================================================== 668 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP.ordinal()] = new HashMap<Tag, GrammarTransition>(); 669 670 // State: [SEARCH_RESULT_ENTRY_LOOP] - Tag: <searchResultEntry> 671 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP.ordinal()].put( new Tag( "searchResultEntry", Tag.START ), 672 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP, Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY, 673 searchResultEntryCreation ) ); 674 675 // State: [SEARCH_RESULT_ENTRY_LOOP] - Tag: <searchResultReference> 676 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP.ordinal()].put( 677 new Tag( "searchResultReference", Tag.START ), new GrammarTransition( 678 Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP, Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE, 679 searchResultReferenceCreation ) ); 680 681 // State: [SEARCH_RESULT_ENTRY_LOOP] - Tag: <searchResultDone> 682 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP.ordinal()].put( new Tag( "searchResultDone", Tag.START ), 683 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_ENTRY_LOOP, Dsmlv2StatesEnum.LDAP_RESULT, 684 searchResultDoneCreation ) ); 685 686 //==================================================== 687 // Transitions concerning : SEARCH RESULT REFERENCE 688 //==================================================== 689 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE.ordinal()] = new HashMap<Tag, GrammarTransition>(); 690 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START.ordinal()] = new HashMap<Tag, GrammarTransition>(); 691 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 692 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 693 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END.ordinal()] = new HashMap<Tag, GrammarTransition>(); 694 695 // State: [SEARCH_RESULT_REFERENCE] - Tag: <control> 696 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE.ordinal()].put( new Tag( "control", Tag.START ), 697 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE, 698 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START, searchResultReferenceControlCreation ) ); 699 700 // State: [SEARCH_RESULT_REFERENCE] - Tag: <ref> 701 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE.ordinal()].put( new Tag( "ref", Tag.START ), 702 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE, 703 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END, searchResultReferenceAddRef ) ); 704 705 // State: [SEARCH_RESULT_REFERENCE_CONTROL_START] - Tag: <controlValue> 706 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START.ordinal()].put( new Tag( "controlValue", 707 Tag.START ), new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START, 708 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END, searchResultReferenceControlValueCreation ) ); 709 710 // State: [sEARCH_RESULT_REFERENCE_CONTROL_VALUE_END] - Tag: </control> 711 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END.ordinal()].put( 712 new Tag( "control", Tag.END ), new GrammarTransition( 713 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_VALUE_END, 714 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END, null ) ); 715 716 // State: [SEARCH_RESULT_REFERENCE_CONTROL_START] - Tag: </control> 717 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START.ordinal()].put( new Tag( "control", Tag.END ), 718 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START, 719 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END, null ) ); 720 721 // State: [SEARCH_RESULT_REFERENCE_CONTROL_END] - Tag: <control> 722 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END.ordinal()].put( new Tag( "control", Tag.START ), 723 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END, 724 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_START, searchResultReferenceControlCreation ) ); 725 726 // State: [SEARCH_RESULT_REFERENCE_CONTROL_END] - Tag: <ref> 727 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END.ordinal()].put( new Tag( "ref", Tag.START ), 728 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_CONTROL_END, 729 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END, searchResultReferenceAddRef ) ); 730 731 // State: [SEARCH_RESULT_REFERENCE_REF_END] - Tag: <ref> 732 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END.ordinal()].put( new Tag( "ref", Tag.START ), 733 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END, 734 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END, searchResultReferenceAddRef ) ); 735 736 // State: [SEARCH_RESULT_REFERENCE_REF_END] - Tag: </searchResultReference> 737 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END.ordinal()].put( new Tag( "searchResultReference", 738 Tag.END ), new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_REF_END, 739 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP, null ) ); 740 741 //========================================================== 742 // Transitions concerning : SEARCH RESULT REFERENCE LOOP 743 //========================================================== 744 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP.ordinal()] = new HashMap<Tag, GrammarTransition>(); 745 746 // State: [SEARCH_RESULT_REFERENCE_LOOP] - Tag: <searchResultReference> 747 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP.ordinal()].put( new Tag( "searchResultReference", 748 Tag.START ), new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP, 749 Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE, searchResultReferenceCreation ) ); 750 751 // State: [SEARCH_RESULT_REFERENCE_LOOP] - Tag: <searchResultDone> 752 super.transitions[Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP.ordinal()].put( new Tag( "searchResultDone", Tag.START ), 753 new GrammarTransition( Dsmlv2StatesEnum.SEARCH_RESULT_REFERENCE_LOOP, Dsmlv2StatesEnum.LDAP_RESULT, 754 searchResultDoneCreation ) ); 755 } 756 757 /** 758 * GrammarAction that creates the Batch Response 759 */ 760 private final GrammarAction batchResponseCreation = new GrammarAction( "Create Batch Response" ) 761 { 762 public void action( Dsmlv2Container container ) throws XmlPullParserException 763 { 764 BatchResponseDsml batchResponse = new BatchResponseDsml(); 765 766 container.setBatchResponse( batchResponse ); 767 768 XmlPullParser xpp = container.getParser(); 769 770 // Checking and adding the batchRequest's attributes 771 String attributeValue; 772 // requestID 773 attributeValue = xpp.getAttributeValue( "", "requestID" ); 774 775 if ( attributeValue != null ) 776 { 777 batchResponse.setRequestID( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) ); 778 } 779 } 780 }; 781 782 /** 783 * GrammarAction that creates the Add Response 784 */ 785 private final GrammarAction addResponseCreation = new GrammarAction( "Create Add Response" ) 786 { 787 public void action( Dsmlv2Container container ) throws XmlPullParserException 788 { 789 AddResponseDsml addResponse = new AddResponseDsml( 790 container.getLdapCodecService(), new AddResponseImpl() ); 791 container.getBatchResponse().addResponse( addResponse ); 792 793 LdapResult ldapResult = addResponse.getLdapResult(); 794 795 XmlPullParser xpp = container.getParser(); 796 797 // Checking and adding the batchRequest's attributes 798 String attributeValue; 799 // requestID 800 attributeValue = xpp.getAttributeValue( "", "requestID" ); 801 802 if ( attributeValue != null ) 803 { 804 addResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) ); 805 } 806 807 // MatchedDN 808 attributeValue = xpp.getAttributeValue( "", "matchedDN" ); 809 810 if ( attributeValue != null ) 811 { 812 try 813 { 814 ldapResult.setMatchedDn( new Dn( attributeValue ) ); 815 } 816 catch ( LdapInvalidDnException e ) 817 { 818 throw new XmlPullParserException( "" + e.getMessage(), xpp, null ); 819 } 820 } 821 } 822 }; 823 824 /** 825 * GrammarAction that creates the Auth Response 826 */ 827 private final GrammarAction authResponseCreation = new GrammarAction( "Create Auth Response" ) 828 { 829 public void action( Dsmlv2Container container ) throws XmlPullParserException 830 { 831 BindResponseDsml bindResponse = new BindResponseDsml( 832 container.getLdapCodecService(), new BindResponseImpl() ); 833 container.getBatchResponse().addResponse( bindResponse ); 834 835 LdapResult ldapResult = bindResponse.getLdapResult(); 836 837 XmlPullParser xpp = container.getParser(); 838 839 // Checking and adding the batchRequest's attributes 840 String attributeValue; 841 // requestID 842 attributeValue = xpp.getAttributeValue( "", "requestID" ); 843 844 if ( attributeValue != null ) 845 { 846 bindResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) ); 847 848 } 849 850 // MatchedDN 851 attributeValue = xpp.getAttributeValue( "", "matchedDN" ); 852 853 if ( attributeValue != null ) 854 { 855 try 856 { 857 ldapResult.setMatchedDn( new Dn( attributeValue ) ); 858 } 859 catch ( LdapInvalidDnException e ) 860 { 861 throw new XmlPullParserException( "" + e.getMessage(), xpp, null ); 862 } 863 } 864 } 865 }; 866 867 /** 868 * GrammarAction that creates the Compare Response 869 */ 870 private final GrammarAction compareResponseCreation = new GrammarAction( "Create Compare Response" ) 871 { 872 public void action( Dsmlv2Container container ) throws XmlPullParserException 873 { 874 CompareResponseDsml compareResponse = new CompareResponseDsml( 875 container.getLdapCodecService(), new CompareResponseImpl() ); 876 container.getBatchResponse().addResponse( compareResponse ); 877 878 LdapResult ldapResult = compareResponse.getLdapResult(); 879 880 XmlPullParser xpp = container.getParser(); 881 882 // Checking and adding the batchRequest's attributes 883 String attributeValue; 884 // requestID 885 attributeValue = xpp.getAttributeValue( "", "requestID" ); 886 887 if ( attributeValue != null ) 888 { 889 compareResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) ); 890 } 891 892 // MatchedDN 893 attributeValue = xpp.getAttributeValue( "", "matchedDN" ); 894 895 if ( attributeValue != null ) 896 { 897 try 898 { 899 ldapResult.setMatchedDn( new Dn( attributeValue ) ); 900 } 901 catch ( LdapInvalidDnException e ) 902 { 903 throw new XmlPullParserException( "" + e.getMessage(), xpp, null ); 904 } 905 } 906 } 907 }; 908 909 /** 910 * GrammarAction that creates the Del Response 911 */ 912 private final GrammarAction delResponseCreation = new GrammarAction( "Create Del Response" ) 913 { 914 public void action( Dsmlv2Container container ) throws XmlPullParserException 915 { 916 DelResponseDsml delResponse = new DelResponseDsml( 917 container.getLdapCodecService(), new DeleteResponseImpl() ); 918 container.getBatchResponse().addResponse( delResponse ); 919 920 LdapResult ldapResult = delResponse.getLdapResult(); 921 922 XmlPullParser xpp = container.getParser(); 923 924 // Checking and adding the batchRequest's attributes 925 String attributeValue; 926 // requestID 927 attributeValue = xpp.getAttributeValue( "", "requestID" ); 928 929 if ( attributeValue != null ) 930 { 931 delResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) ); 932 } 933 934 // MatchedDN 935 attributeValue = xpp.getAttributeValue( "", "matchedDN" ); 936 937 if ( attributeValue != null ) 938 { 939 try 940 { 941 ldapResult.setMatchedDn( new Dn( attributeValue ) ); 942 } 943 catch ( LdapInvalidDnException e ) 944 { 945 throw new XmlPullParserException( "" + e.getMessage(), xpp, null ); 946 } 947 } 948 } 949 }; 950 951 /** 952 * GrammarAction that creates the Modify Response 953 */ 954 private final GrammarAction modifyResponseCreation = new GrammarAction( "Create Modify Response" ) 955 { 956 public void action( Dsmlv2Container container ) throws XmlPullParserException 957 { 958 ModifyResponseDsml modifyResponse = new ModifyResponseDsml( 959 container.getLdapCodecService(), new ModifyResponseImpl() ); 960 container.getBatchResponse().addResponse( modifyResponse ); 961 962 LdapResult ldapResult = modifyResponse.getLdapResult(); 963 964 XmlPullParser xpp = container.getParser(); 965 966 // Checking and adding the batchRequest's attributes 967 String attributeValue; 968 // requestID 969 attributeValue = xpp.getAttributeValue( "", "requestID" ); 970 971 if ( attributeValue != null ) 972 { 973 modifyResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) ); 974 } 975 976 // MatchedDN 977 attributeValue = xpp.getAttributeValue( "", "matchedDN" ); 978 979 if ( attributeValue != null ) 980 { 981 try 982 { 983 ldapResult.setMatchedDn( new Dn( attributeValue ) ); 984 } 985 catch ( LdapInvalidDnException e ) 986 { 987 throw new XmlPullParserException( "" + e.getMessage(), xpp, null ); 988 } 989 } 990 } 991 }; 992 993 /** 994 * GrammarAction that creates the Mod Dn Response 995 */ 996 private final GrammarAction modDNResponseCreation = new GrammarAction( "Create Mod Dn Response" ) 997 { 998 public void action( Dsmlv2Container container ) throws XmlPullParserException 999 { 1000 ModDNResponseDsml modDNResponse = new ModDNResponseDsml( 1001 container.getLdapCodecService(), new ModifyDnResponseImpl() ); 1002 container.getBatchResponse().addResponse( modDNResponse ); 1003 1004 LdapResult ldapResult = modDNResponse.getLdapResult(); 1005 1006 XmlPullParser xpp = container.getParser(); 1007 1008 // Checking and adding the batchRequest's attributes 1009 String attributeValue; 1010 // requestID 1011 attributeValue = xpp.getAttributeValue( "", "requestID" ); 1012 1013 if ( attributeValue != null ) 1014 { 1015 modDNResponse.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) ); 1016 } 1017 1018 // MatchedDN 1019 attributeValue = xpp.getAttributeValue( "", "matchedDN" ); 1020 1021 if ( attributeValue != null ) 1022 { 1023 try 1024 { 1025 ldapResult.setMatchedDn( new Dn( attributeValue ) ); 1026 } 1027 catch ( LdapInvalidDnException e ) 1028 { 1029 throw new XmlPullParserException( "" + e.getMessage(), xpp, null ); 1030 } 1031 } 1032 } 1033 }; 1034 1035 /** 1036 * GrammarAction that creates the Extended Response 1037 */ 1038 private final GrammarAction extendedResponseCreation = new GrammarAction( "Create Extended Response" ) 1039 { 1040 public void action( Dsmlv2Container container ) throws XmlPullParserException 1041 { 1042 ExtendedResponseDsml extendedResponse = null; 1043 1044 // Checking and adding the batchRequest's attributes 1045 String attributeValue; 1046 1047 XmlPullParser xpp = container.getParser(); 1048 1049 // requestID 1050 attributeValue = xpp.getAttributeValue( "", "requestID" ); 1051 1052 if ( attributeValue != null ) 1053 { 1054 extendedResponse = new ExtendedResponseDsml( 1055 container.getLdapCodecService(), new ExtendedResponseImpl( 1056 ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) ) ); 1057 } 1058 else 1059 { 1060 extendedResponse = new ExtendedResponseDsml( 1061 container.getLdapCodecService(), new ExtendedResponseImpl( -1 ) ); 1062 } 1063 1064 container.getBatchResponse().addResponse( extendedResponse ); 1065 1066 LdapResult ldapResult = extendedResponse.getLdapResult(); 1067 1068 // MatchedDN 1069 attributeValue = xpp.getAttributeValue( "", "matchedDN" ); 1070 1071 if ( attributeValue != null ) 1072 { 1073 try 1074 { 1075 ldapResult.setMatchedDn( new Dn( attributeValue ) ); 1076 } 1077 catch ( LdapInvalidDnException e ) 1078 { 1079 throw new XmlPullParserException( "" + e.getMessage(), xpp, null ); 1080 } 1081 } 1082 } 1083 }; 1084 1085 /** 1086 * GrammarAction that creates the Error Response 1087 */ 1088 private final GrammarAction errorResponseCreation = new GrammarAction( "Create Error Response" ) 1089 { 1090 public void action( Dsmlv2Container container ) throws XmlPullParserException 1091 { 1092 ErrorResponse errorResponse = null; 1093 XmlPullParser xpp = container.getParser(); 1094 1095 // Checking and adding the batchRequest's attributes 1096 String attributeValue; 1097 // requestID 1098 attributeValue = xpp.getAttributeValue( "", "requestID" ); 1099 1100 if ( attributeValue != null ) 1101 { 1102 errorResponse = new ErrorResponse( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ), null ); 1103 1104 container.getBatchResponse().addResponse( errorResponse ); 1105 } 1106 // type 1107 attributeValue = xpp.getAttributeValue( "", "type" ); 1108 if ( attributeValue != null ) 1109 { 1110 if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.NOT_ATTEMPTED ) ) ) 1111 { 1112 errorResponse.setErrorType( ErrorResponseType.NOT_ATTEMPTED ); 1113 } 1114 else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.COULD_NOT_CONNECT ) ) ) 1115 { 1116 errorResponse.setErrorType( ErrorResponseType.COULD_NOT_CONNECT ); 1117 } 1118 else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.CONNECTION_CLOSED ) ) ) 1119 { 1120 errorResponse.setErrorType( ErrorResponseType.CONNECTION_CLOSED ); 1121 } 1122 else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.MALFORMED_REQUEST ) ) ) 1123 { 1124 errorResponse.setErrorType( ErrorResponseType.MALFORMED_REQUEST ); 1125 } 1126 else if ( attributeValue 1127 .equals( errorResponse.getTypeDescr( ErrorResponseType.GATEWAY_INTERNAL_ERROR ) ) ) 1128 { 1129 errorResponse.setErrorType( ErrorResponseType.GATEWAY_INTERNAL_ERROR ); 1130 } 1131 else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.AUTHENTICATION_FAILED ) ) ) 1132 { 1133 errorResponse.setErrorType( ErrorResponseType.AUTHENTICATION_FAILED ); 1134 } 1135 else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.UNRESOLVABLE_URI ) ) ) 1136 { 1137 errorResponse.setErrorType( ErrorResponseType.UNRESOLVABLE_URI ); 1138 } 1139 else if ( attributeValue.equals( errorResponse.getTypeDescr( ErrorResponseType.OTHER ) ) ) 1140 { 1141 errorResponse.setErrorType( ErrorResponseType.OTHER ); 1142 } 1143 else 1144 { 1145 throw new XmlPullParserException( I18n.err( I18n.ERR_03004 ), xpp, null ); 1146 } 1147 } 1148 else 1149 { 1150 throw new XmlPullParserException( I18n.err( I18n.ERR_03005 ), xpp, null ); 1151 } 1152 } 1153 }; 1154 1155 /** 1156 * GrammarAction that adds Message to an Error Response 1157 */ 1158 private final GrammarAction errorResponseAddMessage = new GrammarAction( "Add Message to Error Response" ) 1159 { 1160 public void action( Dsmlv2Container container ) throws XmlPullParserException 1161 { 1162 ErrorResponse errorResponse = ( ErrorResponse ) container.getBatchResponse().getCurrentResponse(); 1163 1164 XmlPullParser xpp = container.getParser(); 1165 try 1166 { 1167 String nextText = xpp.nextText(); 1168 if ( !nextText.equals( "" ) ) 1169 { 1170 errorResponse.setMessage( nextText.trim() ); 1171 } 1172 } 1173 catch ( IOException e ) 1174 { 1175 throw new XmlPullParserException( e.getMessage(), xpp, null ); 1176 } 1177 } 1178 }; 1179 1180 /** 1181 * GrammarAction that adds Detail to an Error Response 1182 */ 1183 private final GrammarAction errorResponseAddDetail = null; // TODO Look for documentation about this Detail element (the DSML documentation doesn't give enough information) 1184 1185 1186 /** 1187 * Creates a Control parsing the current node and adds it to the given parent 1188 * @param container the DSMLv2Container 1189 * @param parent the parent 1190 * @throws XmlPullParserException 1191 */ 1192 private void createAndAddControl( Dsmlv2Container container, 1193 AbstractDsmlMessageDecorator<? extends Message> parent ) throws XmlPullParserException 1194 { 1195 CodecControl<? extends Control> control = null; 1196 1197 XmlPullParser xpp = container.getParser(); 1198 1199 // Checking and adding the Control's attributes 1200 String attributeValue; 1201 // TYPE 1202 attributeValue = xpp.getAttributeValue( "", "type" ); 1203 1204 if ( attributeValue != null ) 1205 { 1206 if ( !Oid.isOid(attributeValue) ) 1207 { 1208 throw new XmlPullParserException( I18n.err( I18n.ERR_03006 ), xpp, null ); 1209 } 1210 1211 control = container.getLdapCodecService().newControl( new OpaqueControl( attributeValue ) ); 1212 parent.addControl( control ); 1213 } 1214 else 1215 { 1216 throw new XmlPullParserException( I18n.err( I18n.ERR_03005 ), xpp, null ); 1217 } 1218 // CRITICALITY 1219 attributeValue = xpp.getAttributeValue( "", "criticality" ); 1220 1221 if ( attributeValue != null ) 1222 { 1223 if ( attributeValue.equals( "true" ) ) 1224 { 1225 control.setCritical( true ); 1226 } 1227 else if ( attributeValue.equals( "false" ) ) 1228 { 1229 control.setCritical( false ); 1230 } 1231 else 1232 { 1233 throw new XmlPullParserException( I18n.err( I18n.ERR_03007 ), xpp, null ); 1234 } 1235 } 1236 } 1237 1238 /** 1239 * GrammarAction that creates a Control for LDAP Result 1240 */ 1241 private final GrammarAction ldapResultControlCreation = new GrammarAction( "Create Control for LDAP Result" ) 1242 { 1243 public void action( Dsmlv2Container container ) throws XmlPullParserException 1244 { 1245 AbstractDsmlMessageDecorator<? extends Message> message = 1246 ( AbstractDsmlMessageDecorator<? extends Message> ) 1247 container.getBatchResponse().getCurrentResponse(); 1248 1249 if ( message instanceof SearchResponseDsml ) 1250 { 1251 createAndAddControl( container, 1252 ( ( SearchResponse ) ( ( SearchResponseDsml ) message ).getDecorated() ).getSearchResultDone() ); 1253 } 1254 else 1255 { 1256 createAndAddControl( container, message ); 1257 } 1258 } 1259 }; 1260 1261 /** 1262 * GrammarAction that creates a Control for Search Result Entry 1263 */ 1264 private final GrammarAction searchResultEntryControlCreation = new GrammarAction( 1265 "Create Control for Search Result Entry" ) 1266 { 1267 public void action( Dsmlv2Container container ) throws XmlPullParserException 1268 { 1269 SearchResponse response = ( SearchResponse ) 1270 ( ( SearchResponseDsml ) container.getBatchResponse() 1271 .getCurrentResponse() ).getDecorated(); 1272 1273 createAndAddControl( container, response.getCurrentSearchResultEntry() ); 1274 } 1275 }; 1276 1277 /** 1278 * GrammarAction that creates a Control for Search Result Entry 1279 */ 1280 private final GrammarAction searchResultReferenceControlCreation = new GrammarAction( 1281 "Create Control for Search Result Reference" ) 1282 { 1283 public void action( Dsmlv2Container container ) throws XmlPullParserException 1284 { 1285 SearchResponse response = ( SearchResponse ) 1286 ( ( SearchResponseDsml ) container.getBatchResponse() 1287 .getCurrentResponse() ).getDecorated(); 1288 1289 createAndAddControl( container, response.getCurrentSearchResultReference() ); 1290 } 1291 }; 1292 1293 1294 /** 1295 * Creates a Control Value parsing the current node and adds it to the given parent 1296 * @param container the DSMLv2Container 1297 * @param parent the parent 1298 * @throws XmlPullParserException 1299 */ 1300 private void createAndAddControlValue( Dsmlv2Container container, 1301 AbstractDsmlMessageDecorator<? extends Message> parent ) 1302 throws XmlPullParserException 1303 { 1304 DsmlControl<? extends Control> control = 1305 ( ( AbstractDsmlMessageDecorator<?> ) parent ).getCurrentControl(); 1306 1307 XmlPullParser xpp = container.getParser(); 1308 try 1309 { 1310 // We have to catch the type Attribute Value before going to the next Text node 1311 String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp ); 1312 1313 // Getting the value 1314 String nextText = xpp.nextText(); 1315 1316 if ( !nextText.equals( "" ) ) 1317 { 1318 if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) ) 1319 { 1320 control.setValue( Base64.decode(nextText.trim().toCharArray()) ); 1321 } 1322 else 1323 { 1324 control.setValue( nextText.trim().getBytes() ); 1325 } 1326 } 1327 } 1328 catch ( IOException e ) 1329 { 1330 throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null ); 1331 } 1332 } 1333 1334 /** 1335 * GrammarAction that creates a Control Value for LDAP Result 1336 */ 1337 private final GrammarAction ldapResultControlValueCreation = new GrammarAction( 1338 "Add ControlValue to Control for LDAP Result" ) 1339 { 1340 public void action( Dsmlv2Container container ) throws XmlPullParserException 1341 { 1342 AbstractDsmlMessageDecorator<? extends Response> response 1343 = ( AbstractDsmlMessageDecorator<? extends Response> ) 1344 container.getBatchResponse().getCurrentResponse(); 1345 1346 if ( response instanceof SearchResponseDsml ) 1347 { 1348 SearchResponse searchResponse = ( SearchResponse ) 1349 response.getDecorated(); 1350 createAndAddControlValue( container, 1351 searchResponse.getSearchResultDone() ); 1352 } 1353 else 1354 { 1355 createAndAddControlValue( container, response ); 1356 } 1357 } 1358 }; 1359 1360 /** 1361 * GrammarAction that creates a Control Value for Search Result Entry 1362 */ 1363 private final GrammarAction searchResultEntryControlValueCreation = new GrammarAction( 1364 "Add ControlValue to Control for Search Result Entry" ) 1365 { 1366 public void action( Dsmlv2Container container ) throws XmlPullParserException 1367 { 1368 SearchResponse response = ( SearchResponse ) 1369 container.getBatchResponse().getCurrentResponse().getDecorated(); 1370 createAndAddControlValue( container, 1371 response.getCurrentSearchResultEntry() ); 1372 } 1373 }; 1374 1375 /** 1376 * GrammarAction that creates a Control Value for Search Result Reference 1377 */ 1378 private final GrammarAction searchResultReferenceControlValueCreation = new GrammarAction( 1379 "Add ControlValue to Control for Search Result Entry" ) 1380 { 1381 public void action( Dsmlv2Container container ) throws XmlPullParserException 1382 { 1383 SearchResponseDsml response = ( SearchResponseDsml ) 1384 container.getBatchResponse().getCurrentResponse(); 1385 createAndAddControlValue( container, 1386 ( ( SearchResponse ) response.getDecorated() ).getCurrentSearchResultReference() ); 1387 } 1388 }; 1389 1390 /** 1391 * GrammarAction that adds a Result Code to a LDAP Result 1392 */ 1393 private final GrammarAction ldapResultAddResultCode = new GrammarAction( "Add ResultCode to LDAP Result" ) 1394 { 1395 public void action( Dsmlv2Container container ) throws XmlPullParserException 1396 { 1397 DsmlDecorator<? extends Response> ldapResponse = 1398 container.getBatchResponse().getCurrentResponse(); 1399 1400 LdapResult ldapResult = null; 1401 1402 // Search Response is a special case 1403 // ResultCode can only occur in a case of Search Result Done in a Search Response 1404 if ( ldapResponse.getDecorated() instanceof SearchResponse ) 1405 { 1406 SearchResponse searchResponse = ( SearchResponse ) ldapResponse.getDecorated(); 1407 ldapResult = searchResponse.getSearchResultDone().getLdapResult(); 1408 } 1409 else 1410 { 1411 ldapResult = ( ( ResultResponse ) ldapResponse.getDecorated() ).getLdapResult(); 1412 } 1413 1414 XmlPullParser xpp = container.getParser(); 1415 1416 // Checking and adding the request's attributes 1417 String attributeValue; 1418 // code 1419 attributeValue = xpp.getAttributeValue( "", "code" ); 1420 1421 if ( attributeValue != null ) 1422 { 1423 try 1424 { 1425 ldapResult.setResultCode( ResultCodeEnum.getResultCode(Integer.parseInt(attributeValue)) ); 1426 } 1427 catch ( NumberFormatException e ) 1428 { 1429 throw new XmlPullParserException( I18n.err( I18n.ERR_03009 ), xpp, null ); 1430 } 1431 } 1432 else 1433 { 1434 throw new XmlPullParserException( I18n.err( I18n.ERR_03010 ), xpp, null ); 1435 } 1436 1437 // descr 1438 attributeValue = xpp.getAttributeValue( "", "descr" ); 1439 1440 if ( ( attributeValue != null ) && !DSMLV2_DESCR_TAGS.contains( attributeValue ) ) 1441 { 1442 throw new XmlPullParserException( I18n.err( I18n.ERR_03011, attributeValue ), xpp, null ); 1443 } 1444 } 1445 }; 1446 1447 /** 1448 * GrammarAction that adds a Error Message to a LDAP Result 1449 */ 1450 private final GrammarAction ldapResultAddErrorMessage = new GrammarAction( "Add Error Message to LDAP Result" ) 1451 { 1452 public void action( Dsmlv2Container container ) throws XmlPullParserException 1453 { 1454 DsmlDecorator<? extends Response> ldapResponse = 1455 container.getBatchResponse().getCurrentResponse(); 1456 1457 LdapResult ldapResult = null; 1458 1459 // Search Response is a special case 1460 // ResultCode can only occur in a case of Search Result Done in a Search Response 1461 if ( ldapResponse.getDecorated() instanceof SearchResponse ) 1462 { 1463 SearchResponse searchResponse = ( SearchResponse ) ldapResponse.getDecorated(); 1464 ldapResult = searchResponse.getSearchResultDone().getLdapResult(); 1465 } 1466 else 1467 { 1468 ldapResult = ( ( ResultResponse ) ldapResponse.getDecorated() ).getLdapResult(); 1469 } 1470 1471 XmlPullParser xpp = container.getParser(); 1472 1473 try 1474 { 1475 String nextText = xpp.nextText(); 1476 1477 if ( !nextText.equals( "" ) ) 1478 { 1479 ldapResult.setDiagnosticMessage( nextText.trim() ); 1480 } 1481 } 1482 catch ( IOException e ) 1483 { 1484 throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null ); 1485 } 1486 } 1487 }; 1488 1489 /** 1490 * GrammarAction that adds a Referral to a LDAP Result 1491 */ 1492 private final GrammarAction ldapResultAddReferral = new GrammarAction( "Add Referral to LDAP Result" ) 1493 { 1494 public void action( Dsmlv2Container container ) throws XmlPullParserException 1495 { 1496 DsmlDecorator<? extends Response> ldapResponse = 1497 container.getBatchResponse().getCurrentResponse(); 1498 1499 LdapResult ldapResult = null; 1500 1501 // Search Response is a special case 1502 // ResultCode can only occur in a case of Search Result Done in a Search Response 1503 if ( ldapResponse.getDecorated() instanceof SearchResponse ) 1504 { 1505 SearchResponse searchResponse = ( SearchResponse ) ldapResponse.getDecorated(); 1506 ldapResult = searchResponse.getSearchResultDone().getLdapResult(); 1507 } 1508 else 1509 { 1510 ldapResult = ( ( ResultResponse ) ldapResponse.getDecorated() ).getLdapResult(); 1511 } 1512 1513 // Initialization of the Referrals if needed 1514 if ( ldapResult.getReferral() == null ) 1515 { 1516 ldapResult.setReferral( new ReferralImpl() ); 1517 } 1518 1519 XmlPullParser xpp = container.getParser(); 1520 1521 try 1522 { 1523 String nextText = xpp.nextText(); 1524 1525 if ( !nextText.equals( "" ) ) 1526 { 1527 try 1528 { 1529 String urlStr = nextText.trim(); 1530 LdapUrl ldapUrl = new LdapUrl( urlStr ); 1531 ldapResult.getReferral().addLdapUrl( ldapUrl.toString() ); 1532 } 1533 catch ( LdapURLEncodingException e ) 1534 { 1535 throw new XmlPullParserException( e.getMessage(), xpp, null ); 1536 } 1537 } 1538 } 1539 catch ( IOException e ) 1540 { 1541 throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null ); 1542 } 1543 } 1544 }; 1545 1546 /** 1547 * GrammarAction that creates the Search Response 1548 */ 1549 private final GrammarAction searchResponseCreation = new GrammarAction( "Create Search Response" ) 1550 { 1551 public void action( Dsmlv2Container container ) throws XmlPullParserException 1552 { 1553 XmlPullParser xpp = container.getParser(); 1554 SearchResponse searchResponse = null; 1555 1556 // Checking and adding the batchRequest's attributes 1557 String attributeValue = xpp.getAttributeValue( "", "requestID" ); 1558 1559 if ( attributeValue != null ) 1560 { 1561 searchResponse = new SearchResponse( 1562 ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ), null ); 1563 } 1564 else 1565 { 1566 searchResponse = new SearchResponse( -1, null ); 1567 } 1568 1569 container.getBatchResponse().addResponse( new SearchResponseDsml( 1570 container.getLdapCodecService(), searchResponse ) ); 1571 } 1572 }; 1573 1574 /** 1575 * GrammarAction that creates a Search Result Entry 1576 */ 1577 private final GrammarAction searchResultEntryCreation = new GrammarAction( 1578 "Add Search Result Entry to Search Response" ) 1579 { 1580 public void action( Dsmlv2Container container ) throws XmlPullParserException 1581 { 1582 SearchResultEntryDsml searchResultEntry = 1583 new SearchResultEntryDsml( container.getLdapCodecService(), 1584 new SearchResultEntryImpl() ); 1585 SearchResponseDsml searchResponse = ( SearchResponseDsml ) 1586 container.getBatchResponse().getCurrentResponse(); 1587 searchResponse.addResponse( searchResultEntry ); 1588 1589 XmlPullParser xpp = container.getParser(); 1590 1591 // Checking and adding the request's attributes 1592 String attributeValue; 1593 // requestID 1594 attributeValue = xpp.getAttributeValue( "", "requestID" ); 1595 1596 if ( attributeValue != null ) 1597 { 1598 searchResultEntry.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) ); 1599 } 1600 1601 // dn 1602 attributeValue = xpp.getAttributeValue( "", "dn" ); 1603 1604 if ( attributeValue != null ) 1605 { 1606 try 1607 { 1608 searchResultEntry.setObjectName( new Dn( attributeValue ) ); 1609 } 1610 catch ( LdapInvalidDnException e ) 1611 { 1612 throw new XmlPullParserException( e.getMessage(), xpp, null ); 1613 } 1614 } 1615 else 1616 { 1617 throw new XmlPullParserException( "dn attribute is required", xpp, null ); 1618 } 1619 } 1620 }; 1621 1622 /** 1623 * GrammarAction that creates a Search Result Reference 1624 */ 1625 private final GrammarAction searchResultReferenceCreation = new GrammarAction( 1626 "Add Search Result Reference to Search Response" ) 1627 { 1628 public void action( Dsmlv2Container container ) throws XmlPullParserException 1629 { 1630 SearchResultReferenceDsml searchResultReference = 1631 new SearchResultReferenceDsml( 1632 container.getLdapCodecService(), 1633 new SearchResultReferenceImpl() ); 1634 1635 SearchResponseDsml searchResponseDsml = ( SearchResponseDsml ) 1636 container.getBatchResponse().getCurrentResponse(); 1637 1638 searchResponseDsml.addResponse( searchResultReference ); 1639 1640 XmlPullParser xpp = container.getParser(); 1641 1642 // Checking and adding the request's attributes 1643 String attributeValue; 1644 // requestID 1645 attributeValue = xpp.getAttributeValue( "", "requestID" ); 1646 1647 if ( attributeValue != null ) 1648 { 1649 searchResultReference.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) ); 1650 } 1651 } 1652 }; 1653 1654 /** 1655 * GrammarAction that creates a Search Result Done 1656 */ 1657 private final GrammarAction searchResultDoneCreation = new GrammarAction( 1658 "Add Search Result Done to Search Response" ) 1659 { 1660 public void action( Dsmlv2Container container ) throws XmlPullParserException 1661 { 1662 SearchResultDoneDsml searchResultDone = 1663 new SearchResultDoneDsml( container.getLdapCodecService(), 1664 new SearchResultDoneImpl() ); 1665 1666 SearchResponseDsml searchResponseDsml = ( SearchResponseDsml ) 1667 container.getBatchResponse().getCurrentResponse(); 1668 searchResponseDsml.addResponse( searchResultDone ); 1669 1670 XmlPullParser xpp = container.getParser(); 1671 1672 // Checking and adding the batchRequest's attributes 1673 String attributeValue; 1674 // requestID 1675 attributeValue = xpp.getAttributeValue( "", "requestID" ); 1676 1677 if ( attributeValue != null ) 1678 { 1679 searchResultDone.setMessageId( ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) ); 1680 } 1681 1682 // MatchedDN 1683 attributeValue = xpp.getAttributeValue( "", "matchedDN" ); 1684 1685 if ( attributeValue != null ) 1686 { 1687 try 1688 { 1689 searchResultDone.getLdapResult().setMatchedDn( new Dn( attributeValue ) ); 1690 } 1691 catch ( LdapInvalidDnException e ) 1692 { 1693 throw new XmlPullParserException( "" + e.getMessage(), xpp, null ); 1694 } 1695 } 1696 } 1697 }; 1698 1699 /** 1700 * GrammarAction that adds an Attr to a Search Result Entry 1701 */ 1702 private final GrammarAction searchResultEntryAddAttr = new GrammarAction( "Add Attr to Search Result Entry" ) 1703 { 1704 public void action( Dsmlv2Container container ) throws XmlPullParserException 1705 { 1706 SearchResponse searchResponse = ( SearchResponse ) 1707 container.getBatchResponse().getCurrentResponse().getDecorated(); 1708 1709 SearchResultEntryDsml searchResultEntry = ( SearchResultEntryDsml ) 1710 searchResponse.getCurrentSearchResultEntry(); 1711 1712 XmlPullParser xpp = container.getParser(); 1713 1714 // Checking and adding the request's attributes 1715 String attributeValue; 1716 // name 1717 attributeValue = xpp.getAttributeValue( "", "name" ); 1718 1719 if ( attributeValue != null ) 1720 { 1721 try 1722 { 1723 searchResultEntry.addAttribute( attributeValue ); 1724 } 1725 catch ( LdapException le ) 1726 { 1727 throw new XmlPullParserException( I18n.err( I18n.ERR_03012 ), xpp, null ); 1728 } 1729 } 1730 else 1731 { 1732 throw new XmlPullParserException( I18n.err( I18n.ERR_03012 ), xpp, null ); 1733 } 1734 } 1735 }; 1736 1737 /** 1738 * GrammarAction that adds a Value to an Attr of a Search Result Entry 1739 */ 1740 private final GrammarAction searchResultEntryAddValue = new GrammarAction( 1741 "Add a Value to an Attr of a Search Result Entry" ) 1742 { 1743 public void action( Dsmlv2Container container ) throws XmlPullParserException 1744 { 1745 SearchResponse searchResponse = ( SearchResponse ) 1746 container.getBatchResponse().getCurrentResponse().getDecorated(); 1747 SearchResultEntryDsml searchResultEntry = ( SearchResultEntryDsml ) 1748 searchResponse.getCurrentSearchResultEntry(); 1749 1750 XmlPullParser xpp = container.getParser(); 1751 1752 try 1753 { 1754 // We have to catch the type Attribute Value before going to the next Text node 1755 String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp ); 1756 1757 // Getting the value 1758 String nextText = xpp.nextText(); 1759 1760 try 1761 { 1762 if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) ) 1763 { 1764 searchResultEntry.addAttributeValue( Base64.decode( nextText.toCharArray() ) ); 1765 } 1766 else 1767 { 1768 searchResultEntry.addAttributeValue( nextText ); 1769 } 1770 } 1771 catch ( LdapException le ) 1772 { 1773 throw new XmlPullParserException( le.getMessage() ); 1774 } 1775 } 1776 catch ( IOException e ) 1777 { 1778 throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null ); 1779 } 1780 } 1781 }; 1782 1783 /** 1784 * GrammarAction that adds a Ref to a Search Result Reference 1785 */ 1786 private final GrammarAction searchResultReferenceAddRef = new GrammarAction( 1787 "Add a Ref to a Search Result Reference" ) 1788 { 1789 public void action( Dsmlv2Container container ) throws XmlPullParserException 1790 { 1791 SearchResponse searchResponse = ( SearchResponse ) 1792 container.getBatchResponse().getCurrentResponse().getDecorated(); 1793 SearchResultReference searchResultReference = searchResponse.getCurrentSearchResultReference(); 1794 1795 XmlPullParser xpp = container.getParser(); 1796 1797 try 1798 { 1799 String nextText = xpp.nextText(); 1800 1801 if ( !nextText.equals( "" ) ) 1802 { 1803 LdapUrl ldapUrl = new LdapUrl( nextText ); 1804 1805 searchResultReference.getReferral().addLdapUrl( ldapUrl.toString() ); 1806 } 1807 } 1808 catch ( IOException e ) 1809 { 1810 throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null ); 1811 } 1812 catch ( LdapURLEncodingException e ) 1813 { 1814 throw new XmlPullParserException( e.getMessage(), xpp, null ); 1815 } 1816 } 1817 }; 1818 1819 /** 1820 * GrammarAction that adds Result Code to an Extended Response 1821 */ 1822 private final GrammarAction extendedResponseAddResultCode = ldapResultAddResultCode; 1823 1824 /** 1825 * GrammarAction that creates the Search Response 1826 */ 1827 private final GrammarAction extendedResponseAddErrorMessage = ldapResultAddErrorMessage; 1828 1829 /** 1830 * GrammarAction that adds a Referral to an Extended Response 1831 */ 1832 private final GrammarAction extendedResponseAddReferral = ldapResultAddReferral; 1833 1834 /** 1835 * GrammarAction that adds a Response Name to an Extended Response 1836 */ 1837 private final GrammarAction extendedResponseAddResponseName = new GrammarAction( 1838 "Add Response Name to Extended Response" ) 1839 { 1840 public void action( Dsmlv2Container container ) throws XmlPullParserException 1841 { 1842 ExtendedResponse extendedResponse = ( ExtendedResponse ) container.getBatchResponse().getCurrentResponse(); 1843 1844 XmlPullParser xpp = container.getParser(); 1845 1846 try 1847 { 1848 String nextText = xpp.nextText(); 1849 1850 if ( !nextText.equals( "" ) ) 1851 { 1852 extendedResponse.setResponseName( new Oid( nextText.trim() ).toString() ); 1853 } 1854 1855 } 1856 catch ( IOException e ) 1857 { 1858 throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null ); 1859 } 1860 catch ( DecoderException e ) 1861 { 1862 throw new XmlPullParserException( e.getMessage(), xpp, null ); 1863 } 1864 } 1865 }; 1866 1867 /** 1868 * GrammarAction that adds a Response to an Extended Response 1869 */ 1870 private final GrammarAction extendedResponseAddResponse = new GrammarAction( "Add Response to Extended Response" ) 1871 { 1872 public void action( Dsmlv2Container container ) throws XmlPullParserException 1873 { 1874 ExtendedResponseDsml extendedResponse = ( ExtendedResponseDsml ) container.getBatchResponse().getCurrentResponse(); 1875 1876 XmlPullParser xpp = container.getParser(); 1877 1878 try 1879 { 1880 // We have to catch the type Attribute Value before going to the next Text node 1881 String typeValue = ParserUtils.getXsiTypeAttributeValue( xpp ); 1882 1883 // Getting the value 1884 String nextText = xpp.nextText(); 1885 1886 if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) ) 1887 { 1888 extendedResponse.setResponseValue( Base64.decode( nextText.trim().toCharArray() ) ); 1889 } 1890 else 1891 { 1892 extendedResponse.setResponseValue( Strings.getBytesUtf8(nextText.trim()) ); 1893 } 1894 } 1895 catch ( IOException e ) 1896 { 1897 throw new XmlPullParserException( I18n.err( I18n.ERR_03008, e.getMessage() ), xpp, null ); 1898 } 1899 } 1900 }; 1901 1902 1903 /** 1904 * Get the instance of this grammar 1905 * 1906 * @return 1907 * an instance on this grammar 1908 */ 1909 public static Dsmlv2ResponseGrammar getInstance() 1910 { 1911 return instance; 1912 } 1913}