1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/**
* $RCSfile$
* $Revision: 3144 $
* $Date: 2005-12-01 14:20:11 -0300 (Thu, 01 Dec 2005) $
*
* Copyright (C) 2004-2008 Jive Software. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.openfire.http;
import javax.servlet.http.HttpServletResponse;
/**
* An enum defining all errors which can happen during a BOSH session.
*/
public enum BoshBindingError {
/**
* The format of an HTTP header or binding element received from the client is unacceptable
* (e.g., syntax error), or Script Syntax is not supported.
*/
badRequest(Type.terminate, "bad-request", HttpServletResponse.SC_BAD_REQUEST),
/**
* The target domain specified in the 'to' attribute or the target host or port specified in the
* 'route' attribute is no longer serviced by the connection manager.
*/
hostGone(Type.terminate, "host-gone"),
/**
* The target domain specified in the 'to' attribute or the target host or port specified in the
* 'route' attribute is unknown to the connection manager.
*/
hostUnknown(Type.terminate, "host-unknown"),
/**
* The initialization element lacks a 'to' or 'route' attribute (or the attribute has no value)
* but the connection manager requires one.
*/
improperAddressing(Type.terminate, "improper-addressing"),
/**
* The connection manager has experienced an internal error that prevents it from servicing the
* request.
*/
internalServerError(Type.terminate, "internal-server-error"),
/**
* (1) 'sid' is not valid, (2) 'stream' is not valid, (3) 'rid' is larger than the upper limit
* of the expected window, (4) connection manager is unable to resend response, (5) 'key'
* sequence is invalid (6) script syntax is not enabled
*/
itemNotFound(Type.terminate, "item-not-found", HttpServletResponse.SC_NOT_FOUND),
/**
* Another request being processed at the same time as this request caused the session to
* terminate.
*/
otherRequest(Type.terminate, "other-request"),
/**
* The client has broken the session rules (polling too frequently, requesting too frequently,
* too many simultaneous requests).
*/
policyViolation(Type.terminate, "policy-violation",
HttpServletResponse.SC_FORBIDDEN),
/**
* The connection manager was unable to connect to, or unable to connect securely to, or has
* lost its connection to, the server.
*/
remoteConnectionFailed(Type.terminate, "remote-connection-failed"),
/**
* Encapsulates an error in the protocol being transported.
*/
remoteStreamError(Type.terminate, "remote-stream-error"),
/**
* The connection manager does not operate at this URI (e.g., the connection manager accepts
* only SSL or TLS connections at some https: URI rather than the http: URI requested by the
* client). The client may try POSTing to the URI in the content of the <uri/> child
* element.
*/
seeOtherUri(Type.terminate, "see-other-uri"),
/**
* The connection manager is being shut down. All active HTTP sessions are being terminated. No
* new sessions can be created.
*/
systemShutdown(Type.terminate, "system-shutdown"),
/**
* The error is not one of those defined herein; the connection manager SHOULD include
* application-specific information in the content of the <body> wrapper.
*/
undefinedCondition(Type.terminate, "undefined-condition");
private Type errorType;
private String condition;
private int legacyErrorCode = HttpServletResponse.SC_BAD_REQUEST;
BoshBindingError(Type errorType, String condition, int legacyErrorCode) {
this(errorType, condition);
this.legacyErrorCode = legacyErrorCode;
}
BoshBindingError(Type errorType, String condition) {
this.errorType = errorType;
this.condition = condition;
}
public Type getErrorType() {
return errorType;
}
/**
* Returns the condition that caused the binding error. This should be returned to the client
* so that the client can take appropriate action.
*
* @return the condition that caused the binding error.
*/
public String getCondition() {
return condition;
}
/**
* Returns the legacy HTTP error code which is related to the binding error. With the 1.6
* version of BOSH the use of HTTP errors was deprecated in favor of using errors inside of the
* response to the client so that they could be more easily processed on the client side.
*
* @return the legacy HTTP error code which is related to the binding error.
*/
public int getLegacyErrorCode() {
return legacyErrorCode;
}
public enum Type {
/**
* The terminate error condition prevents the client from making any further requests until a
* new session is established.
*/
terminate(null),
/**
* In the case of a recoverable binding error the client MUST repeat the HTTP request and
* all the preceding HTTP requests that have not received responses. The content of these
* requests MUST be identical to the <body> elements of the original requests. This
* allows the connection manager to recover a session after the previous request was lost
* due to a communication failure.
*/
recoverable("error");
private String type;
Type(String type) {
this.type = type;
}
/**
* Returns the type that will be displayed to the client.
*
* @return the type that will be displayed to the client.
*/
public String getType() {
if (type == null) {
return name();
}
else {
return type;
}
}
}
}