(JabberDataBlock error, String ns)
| 220 | } |
| 221 | |
| 222 | private static XmppError decodeError(JabberDataBlock error, String ns) { |
| 223 | int errCond=NONE; |
| 224 | String text=error.getText(); |
| 225 | if (text.length()==0) text=null; |
| 226 | Vector errChilds=error.getChildBlocks(); |
| 227 | if (errChilds!=null) for (Enumeration e=errChilds.elements(); e.hasMoreElements();) { |
| 228 | JabberDataBlock child=(JabberDataBlock) e.nextElement(); |
| 229 | String xmlns=child.getAttribute("xmlns"); |
| 230 | if (xmlns!=null) if (!xmlns.equals(ns)) continue; |
| 231 | |
| 232 | String tag=child.getTagName(); |
| 233 | if (tag.equals("text")) text=child.getText(); |
| 234 | if (tag.equals("bad-request")) errCond=BAD_REQUEST; |
| 235 | if (tag.equals("conflict")) errCond=CONFLICT; |
| 236 | if (tag.equals("feature-not-implemented")) errCond=FEATURE_NOT_IMPLEMENTED; |
| 237 | if (tag.equals("forbidden")) errCond=FORBIDDEN; |
| 238 | if (tag.equals("gone")) errCond=GONE; |
| 239 | if (tag.equals("internal-server-error")) errCond=INTERNAL_SERVER_ERROR; |
| 240 | if (tag.equals("item-not-found")) errCond=ITEM_NOT_FOUND; |
| 241 | if (tag.equals("jid-malformed")) errCond=JID_MALFORMED; |
| 242 | if (tag.equals("not-acceptable")) errCond=NOT_ACCEPTABLE; |
| 243 | if (tag.equals("not-allowed")) errCond=NOT_ALLOWED; |
| 244 | if (tag.equals("not-authorized")) errCond=NOT_AUTHORIZED; |
| 245 | if (tag.equals("payment-required")) errCond=PAYMENT_REQUIRED; |
| 246 | if (tag.equals("recipient-unavailable")) errCond=RECIPIENT_UNAVAILEBLE; |
| 247 | if (tag.equals("redirect")) errCond=REDIRECT; |
| 248 | if (tag.equals("registration-required")) errCond=REGISTRATION_REQUIRED; |
| 249 | if (tag.equals("remote-server-not-found")) errCond=REMOTE_SERVER_NOT_FOUND; |
| 250 | if (tag.equals("remote-server-timeout")) errCond=REMOTE_SERVER_TIMEOUT; |
| 251 | if (tag.equals("resource-constraint")) errCond=RESOURCE_CONSTRAINT; |
| 252 | if (tag.equals("service-unavailable")) errCond=SERVICE_UNAVAILABLE; |
| 253 | if (tag.equals("subscription-required")) errCond=SUBSCRIPTION_REQUIRED; |
| 254 | if (tag.equals("undefined-condition")) errCond=UNDEFINED_CONDITION; |
| 255 | if (tag.equals("unexpected-request")) errCond=UNEXPECTED_REQUEST; |
| 256 | |
| 257 | //SASL conditions |
| 258 | if (tag.equals("aborted")) errCond=ABORTED; |
| 259 | if (tag.equals("incorrect-encoding")) errCond=INCORRECT_ENCODING; |
| 260 | if (tag.equals("invalid-authzid")) errCond=INVALID_AUTHZID; |
| 261 | if (tag.equals("invalid-mechanism")) errCond=INVALID_MECHANISM; |
| 262 | if (tag.equals("mechanism-too-weak")) errCond=MECHANISM_TOO_WEAK; |
| 263 | // already defined |
| 264 | //if (tag.equals("not-authorized")) errCond=NOT_AUTHORIZED; |
| 265 | if (tag.equals("temporary-auth-failure")) errCond=TEMPORARY_AUTH_FAILURE; |
| 266 | |
| 267 | } |
| 268 | |
| 269 | if (errCond==NONE) { |
| 270 | try { |
| 271 | int code=Integer.parseInt(error.getAttribute("code")); |
| 272 | switch (code) { |
| 273 | case 302: errCond=REDIRECT; break; |
| 274 | case 400: errCond=BAD_REQUEST; break; |
| 275 | case 401: errCond=NOT_AUTHORIZED; break; |
| 276 | case 402: errCond=PAYMENT_REQUIRED; break; |
| 277 | case 403: errCond=FORBIDDEN; break; |
| 278 | case 404: errCond=ITEM_NOT_FOUND; break; |
| 279 | case 405: errCond=NOT_ALLOWED; break; |
no test coverage detected