001/*
002 * Copyright 2002-2015 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.web.socket.config.annotation;
018
019import org.springframework.web.socket.WebSocketHandler;
020import org.springframework.web.socket.server.HandshakeHandler;
021import org.springframework.web.socket.server.HandshakeInterceptor;
022
023/**
024 * Provides methods for configuring a WebSocket handler.
025 *
026 * @author Rossen Stoyanchev
027 * @since 4.0
028 */
029public interface WebSocketHandlerRegistration {
030
031        /**
032         * Add more handlers that will share the same configuration (interceptors, SockJS
033         * config, etc)
034         */
035        WebSocketHandlerRegistration addHandler(WebSocketHandler handler, String... paths);
036
037        /**
038         * Configure the HandshakeHandler to use.
039         */
040        WebSocketHandlerRegistration setHandshakeHandler(HandshakeHandler handshakeHandler);
041
042        /**
043         * Configure interceptors for the handshake request.
044         */
045        WebSocketHandlerRegistration addInterceptors(HandshakeInterceptor... interceptors);
046
047        /**
048         * Configure allowed {@code Origin} header values. This check is mostly designed for
049         * browser clients. There is nothing preventing other types of client to modify the
050         * {@code Origin} header value.
051         *
052         * <p>When SockJS is enabled and origins are restricted, transport types that do not
053         * allow to check request origin (JSONP and Iframe based transports) are disabled.
054         * As a consequence, IE 6 to 9 are not supported when origins are restricted.
055         *
056         * <p>Each provided allowed origin must start by "http://", "https://" or be "*"
057         * (means that all origins are allowed). By default, only same origin requests are
058         * allowed (empty list).
059         *
060         * @since 4.1.2
061         * @see <a href="https://tools.ietf.org/html/rfc6454">RFC 6454: The Web Origin Concept</a>
062         * @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>
063         */
064        WebSocketHandlerRegistration setAllowedOrigins(String... origins);
065
066        /**
067         * Enable SockJS fallback options.
068         */
069        SockJsServiceRegistration withSockJS();
070
071
072
073}