WebSocketHandlerRegistration.java 2.6 KB
Newer Older
1
/*
S
Sebastien Deleuze 已提交
2
 * Copyright 2002-2015 the original author or authors.
3 4 5 6 7
 *
 * 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
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9 10 11 12 13 14 15 16
 *
 * 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.
 */

17
package org.springframework.web.socket.config.annotation;
18 19 20 21 22 23

import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.server.HandshakeHandler;
import org.springframework.web.socket.server.HandshakeInterceptor;

/**
24
 * Provides methods for configuring a WebSocket handler.
25 26 27 28
 *
 * @author Rossen Stoyanchev
 * @since 4.0
 */
29 30 31 32 33 34 35 36 37
public interface WebSocketHandlerRegistration {

	/**
	 * Add more handlers that will share the same configuration (interceptors, SockJS
	 * config, etc)
	 */
	WebSocketHandlerRegistration addHandler(WebSocketHandler handler, String... paths);

	/**
R
Rossen Stoyanchev 已提交
38
	 * Configure the HandshakeHandler to use.
39
	 */
R
Rossen Stoyanchev 已提交
40
	WebSocketHandlerRegistration setHandshakeHandler(HandshakeHandler handshakeHandler);
41 42

	/**
R
Rossen Stoyanchev 已提交
43
	 * Configure interceptors for the handshake request.
44
	 */
R
Rossen Stoyanchev 已提交
45
	WebSocketHandlerRegistration addInterceptors(HandshakeInterceptor... interceptors);
46

47
	/**
S
Sebastien Deleuze 已提交
48 49 50
	 * Configure allowed {@code Origin} header values. This check is mostly designed for
	 * browser clients. There is nothing preventing other types of client to modify the
	 * {@code Origin} header value.
51
	 *
S
Sebastien Deleuze 已提交
52 53 54
	 * <p>When SockJS is enabled and origins are restricted, transport types that do not
	 * allow to check request origin (JSONP and Iframe based transports) are disabled.
	 * As a consequence, IE 6 to 9 are not supported when origins are restricted.
55
	 *
S
Sebastien Deleuze 已提交
56
	 * <p>Each provided allowed origin must start by "http://", "https://" or be "*"
57 58
	 * (means that all origins are allowed). By default, only same origin requests are
	 * allowed (empty list).
59 60
	 *
	 * @since 4.1.2
S
Sebastien Deleuze 已提交
61
	 * @see <a href="https://tools.ietf.org/html/rfc6454">RFC 6454: The Web Origin Concept</a>
62 63 64 65
	 * @see <a href="https://github.com/sockjs/sockjs-client#supported-transports-by-browser-html-served-from-http-or-https">SockJS supported transports by browser</a>
	 */
	WebSocketHandlerRegistration setAllowedOrigins(String... origins);

66 67 68 69 70
	/**
	 * Enable SockJS fallback options.
	 */
	SockJsServiceRegistration withSockJS();

71 72


73
}