1/** 2 * $Revision: 2408 $ 3 * $Date: 2004-11-02 20:53:30 -0300 (Tue, 02 Nov 2004) $ 4 * 5 * Copyright 2003-2005 Jive Software. 6 * 7 * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20package org.jivesoftware.smack.packet; 21 22/** 23 * Represents a stream error packet. Stream errors are unrecoverable errors where the server 24 * will close the unrelying TCP connection after the stream error was sent to the client. 25 * These is the list of stream errors as defined in the XMPP spec:<p> 26 * 27 * <table border=1> 28 * <tr><td><b>Code</b></td><td><b>Description</b></td></tr> 29 * <tr><td> bad-format </td><td> the entity has sent XML that cannot be processed </td></tr> 30 * <tr><td> unsupported-encoding </td><td> the entity has sent a namespace prefix that is 31 * unsupported </td></tr> 32 * <tr><td> bad-namespace-prefix </td><td> Remote Server Timeout </td></tr> 33 * <tr><td> conflict </td><td> the server is closing the active stream for this entity 34 * because a new stream has been initiated that conflicts with the existing 35 * stream. </td></tr> 36 * <tr><td> connection-timeout </td><td> the entity has not generated any traffic over 37 * the stream for some period of time. </td></tr> 38 * <tr><td> host-gone </td><td> the value of the 'to' attribute provided by the initiating 39 * entity in the stream header corresponds to a hostname that is no longer hosted by 40 * the server. </td></tr> 41 * <tr><td> host-unknown </td><td> the value of the 'to' attribute provided by the 42 * initiating entity in the stream header does not correspond to a hostname that is 43 * hosted by the server. </td></tr> 44 * <tr><td> improper-addressing </td><td> a stanza sent between two servers lacks a 'to' 45 * or 'from' attribute </td></tr> 46 * <tr><td> internal-server-error </td><td> the server has experienced a 47 * misconfiguration. </td></tr> 48 * <tr><td> invalid-from </td><td> the JID or hostname provided in a 'from' address does 49 * not match an authorized JID. </td></tr> 50 * <tr><td> invalid-id </td><td> the stream ID or dialback ID is invalid or does not match 51 * an ID previously provided. </td></tr> 52 * <tr><td> invalid-namespace </td><td> the streams namespace name is invalid. </td></tr> 53 * <tr><td> invalid-xml </td><td> the entity has sent invalid XML over the stream. </td></tr> 54 * <tr><td> not-authorized </td><td> the entity has attempted to send data before the 55 * stream has been authenticated </td></tr> 56 * <tr><td> policy-violation </td><td> the entity has violated some local service 57 * policy. </td></tr> 58 * <tr><td> remote-connection-failed </td><td> Rthe server is unable to properly connect 59 * to a remote entity. </td></tr> 60 * <tr><td> resource-constraint </td><td> Rthe server lacks the system resources necessary 61 * to service the stream. </td></tr> 62 * <tr><td> restricted-xml </td><td> the entity has attempted to send restricted XML 63 * features. </td></tr> 64 * <tr><td> see-other-host </td><td> the server will not provide service to the initiating 65 * entity but is redirecting traffic to another host. </td></tr> 66 * <tr><td> system-shutdown </td><td> the server is being shut down and all active streams 67 * are being closed. </td></tr> 68 * <tr><td> undefined-condition </td><td> the error condition is not one of those defined 69 * by the other conditions in this list. </td></tr> 70 * <tr><td> unsupported-encoding </td><td> the initiating entity has encoded the stream in 71 * an encoding that is not supported. </td></tr> 72 * <tr><td> unsupported-stanza-type </td><td> the initiating entity has sent a first-level 73 * child of the stream that is not supported. </td></tr> 74 * <tr><td> unsupported-version </td><td> the value of the 'version' attribute provided by 75 * the initiating entity in the stream header specifies a version of XMPP that is not 76 * supported. </td></tr> 77 * <tr><td> xml-not-well-formed </td><td> the initiating entity has sent XML that is 78 * not well-formed. </td></tr> 79 * </table> 80 * 81 * @author Gaston Dombiak 82 */ 83public class StreamError { 84 85 private String code; 86 87 public StreamError(String code) { 88 super(); 89 this.code = code; 90 } 91 92 /** 93 * Returns the error code. 94 * 95 * @return the error code. 96 */ 97 public String getCode() { 98 return code; 99 } 100 101 public String toString() { 102 StringBuilder txt = new StringBuilder(); 103 txt.append("stream:error (").append(code).append(")"); 104 return txt.toString(); 105 } 106} 107