Repository: mthizo247/spring-cloud-netflix-zuul-websocket
Branch: master
Commit: cc3fad4dba3b
Files: 34
Total size: 126.5 KB
Directory structure:
gitextract_fb8rm5ag/
├── .gitignore
├── LICENSE
├── README.md
├── eclipse-code-formatter.xml
├── pom.xml
└── src/
├── main/
│ └── java/
│ └── com/
│ └── github/
│ └── mthizo247/
│ └── cloud/
│ └── netflix/
│ └── zuul/
│ └── web/
│ ├── authentication/
│ │ ├── AbstractHeadersCallback.java
│ │ ├── BasicAuthPrincipalHeadersCallback.java
│ │ ├── CompositeHeadersCallback.java
│ │ ├── LoginCookieHeadersCallback.java
│ │ └── OAuth2BearerPrincipalHeadersCallback.java
│ ├── filter/
│ │ └── ProxyRedirectFilter.java
│ ├── proxytarget/
│ │ ├── AbstractProxyTargetResolver.java
│ │ ├── CompositeProxyTargetResolver.java
│ │ ├── EurekaProxyTargetResolver.java
│ │ ├── LoadBalancedProxyTargetResolver.java
│ │ ├── ProxyTargetResolver.java
│ │ └── UrlProxyTargetResolver.java
│ ├── socket/
│ │ ├── CompositeErrorHandler.java
│ │ ├── EnableZuulWebSocket.java
│ │ ├── ProxySessionException.java
│ │ ├── ProxyWebSocketConnectionManager.java
│ │ ├── ProxyWebSocketErrorHandler.java
│ │ ├── ProxyWebSocketHandler.java
│ │ ├── ReconnectErrorHandler.java
│ │ ├── WebSocketHttpHeadersCallback.java
│ │ ├── WebSocketMessageAccessor.java
│ │ ├── ZuulWebSocketConfiguration.java
│ │ └── ZuulWebSocketProperties.java
│ └── util/
│ ├── DefaultErrorAnalyzer.java
│ ├── ErrorAnalyzer.java
│ └── MapPropertyResolver.java
└── test/
└── java/
└── com/
└── github/
└── mthizo247/
└── cloud/
└── netflix/
└── zuul/
└── web/
└── socket/
├── ProxyWebSocketConnectionManagerTests.java
├── WebSocketMessageAccessorTests.java
└── ZuulWebSocketPropertiesTests.java
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
target/
*.log.gz
*.iml
.idea/
*.log
*.db
/target
target
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
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.
================================================
FILE: README.md
================================================
# spring-cloud-netflix-zuul-websocket
A simple library to enable Zuul reverse proxy web socket support in spring applications.
## USAGE
spring-cloud-netflix-zuul-websocket is available from **Maven Central**
```xml
<dependency>
<groupId>com.github.mthizo247</groupId>
<artifactId>spring-cloud-netflix-zuul-websocket</artifactId>
<version>1.0.0-RELEASE</version>
</dependency>
```
### Who is this for?
This is for anyone using **Spring Netflix Zuul** to proxy requests to back-ends which supports web sockets but the proxy layer does not.
**Netflix Zuul** does not natively support web sockets.
### How do I use this?
Enable it like so:
```java
@SpringBootApplication
@EnableZuulWebSocket
@EnableWebSocketMessageBroker
public class ProxyApplication {
public static void main(String[] args) {
SpringApplication.run(ProxyApplication.class, args);
}
}
```
Then in your spring application properties(e.g application.yml)
```
server:
port: 7078
zuul:
routes:
hello:
path: /**
url: http://localhost:7079
customSensitiveHeaders: true
ws:
brokerages:
hello:
end-points: /ws
brokers: /topic
destination-prefixes: /app
```
With this you should have web sockets to your back-end service working correctly.
**Checkout** this [demo](https://github.com/mthizo247/zuul-websocket-support-demo)
================================================
FILE: eclipse-code-formatter.xml
================================================
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="12">
<profile kind="CodeFormatterProfile" name="Spring Boot Java Conventions" version="12">
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="8"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="90"/>
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.compiler.source" value="1.8"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.8"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.8"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="tab"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="90"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
</profile>
</profiles>
================================================
FILE: pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.mthizo247</groupId>
<artifactId>spring-cloud-netflix-zuul-websocket</artifactId>
<packaging>jar</packaging>
<version>1.0.7.RELEASE</version>
<name>Spring Cloud Netflix Zuul Websocket</name>
<description>Spring Cloud Netflix Zuul Websocket</description>
<url>https://www.discovery.co.za</url>
<inceptionYear>2017</inceptionYear>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>mthizo247@gmail.com</id>
<name>Ronald Mthombeni</name>
<email>mthizo247@gmail.com</email>
<organization>Discovery inc.</organization>
<organizationUrl>http://www.discovery.co.za</organizationUrl>
</developer>
<developer>
<id>salmannoor74415</id>
<name>Salman Noor</name>
<email>salmannoor74415@gmail.com</email>
<organization>Discovery inc.</organization>
<organizationUrl>http://www.discovery.co.za</organizationUrl>
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/mthizo247/spring-cloud-netflix-zuul-websocket</connection>
<developerConnection>scm:git:git://github.com/mthizo247/spring-cloud-netflix-zuul-websocket
</developerConnection>
<url>https://github.com/mthizo247/spring-cloud-netflix-zuul-websocket.git</url>
</scm>
<issueManagement>
<url>https://github.com/mthizo247/spring-cloud-netflix-zuul-websocket/issues</url>
<system>GitHub Issues</system>
</issueManagement>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.7</java.version>
</properties>
<distributionManagement>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zuul</artifactId>
<version>1.1.5.RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.3</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<stagingProfileId>5820c8da7e998d</stagingProfileId>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/authentication/AbstractHeadersCallback.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.authentication;
import com.github.mthizo247.cloud.netflix.zuul.web.socket.WebSocketHttpHeadersCallback;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.socket.WebSocketHttpHeaders;
import org.springframework.web.socket.WebSocketSession;
/**
* @author Ronald Mthombeni
*/
public abstract class AbstractHeadersCallback implements WebSocketHttpHeadersCallback {
protected final Log logger = LogFactory.getLog(getClass());
@Override
public void applyHeaders(
WebSocketSession userAgentSession, WebSocketHttpHeaders headers) {
if (shouldApplyHeaders(userAgentSession, headers)) {
applyHeadersInternal(userAgentSession, headers);
}
}
protected abstract void applyHeadersInternal(WebSocketSession userAgentSession, WebSocketHttpHeaders headers);
protected abstract boolean shouldApplyHeaders(WebSocketSession userAgentSession, WebSocketHttpHeaders headers);
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/authentication/BasicAuthPrincipalHeadersCallback.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.authentication;
import org.springframework.http.HttpHeaders;
import org.springframework.security.core.Authentication;
import org.springframework.security.crypto.codec.Base64;
import org.springframework.web.socket.WebSocketHttpHeaders;
import org.springframework.web.socket.WebSocketSession;
import java.util.Collections;
/**
* @author Ronald Mthombeni
*/
public class BasicAuthPrincipalHeadersCallback extends AbstractHeadersCallback {
@Override
protected void applyHeadersInternal(WebSocketSession userAgentSession, WebSocketHttpHeaders headers) {
Authentication authentication = (Authentication) userAgentSession.getPrincipal();
String usernameColonPwd = authentication.getName() + ":"
+ authentication.getCredentials().toString();
String encodedCredentials = new String(
Base64.encode(usernameColonPwd.getBytes()));
headers.put(HttpHeaders.AUTHORIZATION,
Collections.singletonList("Basic " + encodedCredentials));
if (logger.isDebugEnabled()) {
logger.debug("Added basic authentication header for user " + authentication.getName() + " to web sockets http headers");
}
}
@Override
protected boolean shouldApplyHeaders(WebSocketSession userAgentSession, WebSocketHttpHeaders headers) {
return !headers.containsKey(HttpHeaders.AUTHORIZATION) && userAgentSession.getPrincipal() instanceof Authentication;
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/authentication/CompositeHeadersCallback.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.authentication;
import com.github.mthizo247.cloud.netflix.zuul.web.socket.WebSocketHttpHeadersCallback;
import org.springframework.web.socket.WebSocketHttpHeaders;
import org.springframework.web.socket.WebSocketSession;
import java.util.List;
/**
* Strategy to add different types of headers to web socket connections
*
* @author Ronald Mthombeni
* @author Salman Noor
*/
public class CompositeHeadersCallback implements WebSocketHttpHeadersCallback {
private List<WebSocketHttpHeadersCallback> headersCallbacks;
public CompositeHeadersCallback(final List<WebSocketHttpHeadersCallback> headersCallbacks) {
this.headersCallbacks = headersCallbacks;
}
@Override
public void applyHeaders(WebSocketSession userAgentSession, WebSocketHttpHeaders headers) {
for (WebSocketHttpHeadersCallback callback : headersCallbacks) {
callback.applyHeaders(userAgentSession, headers);
}
}
public List<WebSocketHttpHeadersCallback> getHeadersCallbacks() {
return headersCallbacks;
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/authentication/LoginCookieHeadersCallback.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.authentication;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.web.socket.WebSocketHttpHeaders;
import org.springframework.web.socket.WebSocketSession;
import java.util.List;
/**
* @author Ronald Mthombeni
*/
public class LoginCookieHeadersCallback extends AbstractHeadersCallback {
protected final Log logger = LogFactory.getLog(getClass());
@Override
protected void applyHeadersInternal(WebSocketSession userAgentSession, WebSocketHttpHeaders headers) {
List<String> sessionCookies = userAgentSession.getHandshakeHeaders().get(HttpHeaders.COOKIE);
headers.put(HttpHeaders.COOKIE, sessionCookies);
if (logger.isDebugEnabled()) {
logger.debug("Added cookie authentication header to web sockets http headers");
}
}
@Override
protected boolean shouldApplyHeaders(WebSocketSession userAgentSession, WebSocketHttpHeaders headers) {
return !headers.containsKey(HttpHeaders.COOKIE) && userAgentSession.getHandshakeHeaders().containsKey(HttpHeaders.COOKIE);
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/authentication/OAuth2BearerPrincipalHeadersCallback.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.authentication;
import org.springframework.http.HttpHeaders;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationDetails;
import org.springframework.web.socket.WebSocketHttpHeaders;
import org.springframework.web.socket.WebSocketSession;
import java.util.Collections;
/**
* @author Marcin Podlodowski
*/
public class OAuth2BearerPrincipalHeadersCallback extends AbstractHeadersCallback {
@Override
protected void applyHeadersInternal(WebSocketSession userAgentSession, WebSocketHttpHeaders headers) {
OAuth2Authentication oAuth2Authentication = (OAuth2Authentication) userAgentSession.getPrincipal();
OAuth2AuthenticationDetails details = (OAuth2AuthenticationDetails) oAuth2Authentication.getDetails();
String accessToken = details.getTokenValue();
headers.put(HttpHeaders.AUTHORIZATION, Collections.singletonList("Bearer " + accessToken));
if (logger.isDebugEnabled()) {
logger.debug("Added Oauth2 bearer token authentication header for user " +
oAuth2Authentication.getName() + " to web sockets http headers");
}
}
@Override
protected boolean shouldApplyHeaders(WebSocketSession userAgentSession, WebSocketHttpHeaders headers) {
return !headers.containsKey(HttpHeaders.AUTHORIZATION) && userAgentSession.getPrincipal() instanceof OAuth2Authentication;
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/filter/ProxyRedirectFilter.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.filter;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.cloud.netflix.zuul.filters.Route;
import org.springframework.cloud.netflix.zuul.filters.RouteLocator;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UrlPathHelper;
import com.netflix.util.Pair;
import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
/**
* @author Ronald Mthombeni
*/
public class ProxyRedirectFilter extends ZuulFilter {
private static String REDIRECT_TO_URL = "REDIRECT_TO_URL_"
+ ProxyRedirectFilter.class.getName();
RouteLocator routeLocator;
UrlPathHelper urlPathHelper;
public ProxyRedirectFilter(RouteLocator routeLocator) {
this(routeLocator, new UrlPathHelper());
}
public ProxyRedirectFilter(RouteLocator routeLocator, UrlPathHelper urlPathHelper) {
this.routeLocator = routeLocator;
this.urlPathHelper = urlPathHelper;
}
@Override
public String filterType() {
return "post";
}
@Override
public int filterOrder() {
return 1;
}
@Override
public boolean shouldFilter() {
RequestContext ctx = RequestContext.getCurrentContext();
boolean isRedirect = ctx.getResponseStatusCode() == 301 || ctx.getResponseStatusCode() == 302;
if (!isRedirect)
return false;
boolean hasCorrectLocation = false;
List<Pair<String, String>> zuulResponseHeaders = ctx.getZuulResponseHeaders();
for (Pair<String, String> zuulResponseHeader : zuulResponseHeaders) {
if ("Location".equalsIgnoreCase(zuulResponseHeader.first())) {
HttpServletRequest request = ctx.getRequest();
String path = urlPathHelper.getPathWithinApplication(request);
Route route = routeLocator.getMatchingRoute(path);
UriComponents redirectTo = ServletUriComponentsBuilder
.fromHttpUrl(zuulResponseHeader.second()).build();
UriComponents routeLocation = ServletUriComponentsBuilder
.fromHttpUrl(route.getLocation()).build();
if (redirectTo.getHost().equalsIgnoreCase(routeLocation.getHost())
&& redirectTo.getPort() == routeLocation.getPort()) {
String toLocation = ServletUriComponentsBuilder
.fromHttpUrl(zuulResponseHeader.second())
.host(request.getServerName())
.port(request.getServerPort())
.replacePath(
buildRoutePath(route, zuulResponseHeader.second()))
.build().toUriString();
ctx.put(REDIRECT_TO_URL, toLocation);
hasCorrectLocation = true;
break;
}
}
}
return hasCorrectLocation;
}
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
List<Pair<String, String>> zuulResponseHeaders = ctx.getZuulResponseHeaders();
for (Pair<String, String> zuulResponseHeader : zuulResponseHeaders) {
if ("Location".equalsIgnoreCase(zuulResponseHeader.first())) {
zuulResponseHeader.setSecond(ctx.get(REDIRECT_TO_URL).toString());
break;
}
}
return null;
}
private String buildRoutePath(Route route, String httpUrl) {
String path = ServletUriComponentsBuilder.fromHttpUrl(httpUrl).build().getPath();
return route.getPrefix() == null ? path : route.getPrefix() + path;
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/AbstractProxyTargetResolver.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.proxytarget;
import com.github.mthizo247.cloud.netflix.zuul.web.socket.ZuulWebSocketProperties;
import com.github.mthizo247.cloud.netflix.zuul.web.util.MapPropertyResolver;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.core.Ordered;
import org.springframework.util.Assert;
import org.springframework.web.util.UriComponentsBuilder;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
/**
* @author Ronald Mthombeni
* @author Salman Noor
*/
public abstract class AbstractProxyTargetResolver implements ProxyTargetResolver, Ordered {
protected ZuulProperties zuulProperties;
protected int order = 0;
public AbstractProxyTargetResolver(ZuulProperties zuulProperties) {
Assert.notNull(zuulProperties, "zuulProperties must not be null");
this.zuulProperties = zuulProperties;
}
protected ZuulProperties.ZuulRoute resolveRoute(ZuulWebSocketProperties.WsBrokerage wsBrokerage) {
ZuulProperties.ZuulRoute zuulRoute = zuulProperties.getRoutes().get(wsBrokerage.getRouteId());
zuulRoute = zuulRoute == null ? zuulProperties.getRoutes().get(wsBrokerage.getId()) : zuulRoute;
return zuulRoute;
}
protected URI resolveUri(ServiceInstance serviceInstance) {
Map<String, Object> metadata = new HashMap<>();
for (Map.Entry<String, String> entry : serviceInstance.getMetadata().entrySet()) {
metadata.put(entry.getKey(), entry.getValue());
}
UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromUri(serviceInstance.getUri());
RelaxedPropertyResolver propertyResolver = new RelaxedPropertyResolver(new MapPropertyResolver(metadata));
String configPath = propertyResolver.getProperty("configPath");
if (configPath != null) {
uriBuilder.path(configPath);
}
return uriBuilder.build().toUri();
}
@Override
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/CompositeProxyTargetResolver.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.proxytarget;
import com.github.mthizo247.cloud.netflix.zuul.web.socket.ZuulWebSocketProperties;
import java.net.URI;
import java.util.List;
/**
* Strategy to resolve zuul proxy target using delegation pattern
*
* @author Ronald Mthombeni
* @author Salman Noor
*/
public class CompositeProxyTargetResolver implements ProxyTargetResolver {
private List<ProxyTargetResolver> targetResolvers;
public CompositeProxyTargetResolver(final List<ProxyTargetResolver> targetResolvers) {
this.targetResolvers = targetResolvers;
}
@Override
public URI resolveTarget(ZuulWebSocketProperties.WsBrokerage wsBrokerage) {
URI target = null;
for (ProxyTargetResolver resolver : targetResolvers) {
target = resolver.resolveTarget(wsBrokerage);
if (target != null)
break;
}
return target;
}
public List<ProxyTargetResolver> getTargetResolvers() {
return targetResolvers;
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/EurekaProxyTargetResolver.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.proxytarget;
import com.github.mthizo247.cloud.netflix.zuul.web.socket.ZuulWebSocketProperties;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.net.URI;
import java.util.List;
/**
* Strategy to resolve zuul properties from route service is using eaureka service discovery
*
* @author Ronald Mthombeni
* @author Salman Noor
*/
public class EurekaProxyTargetResolver extends AbstractProxyTargetResolver {
public static final int DEFAULT_ORDER = LoadBalancedProxyTargetResolver.DEFAULT_ORDER + 10;
private DiscoveryClient discoveryClient;
public EurekaProxyTargetResolver(DiscoveryClient discoveryClient, ZuulProperties zuulProperties) {
super(zuulProperties);
Assert.notNull(discoveryClient, "discoveryClient can't be null");
this.discoveryClient = discoveryClient;
this.order = DEFAULT_ORDER;
}
@Override
public URI resolveTarget(ZuulWebSocketProperties.WsBrokerage wsBrokerage) {
ZuulProperties.ZuulRoute zuulRoute = resolveRoute(wsBrokerage);
if (zuulRoute == null || StringUtils.isEmpty(zuulRoute.getServiceId())) return null;
List<ServiceInstance> instances = discoveryClient.getInstances(zuulRoute.getServiceId());
ServiceInstance serviceInstance = CollectionUtils.isEmpty(instances) ? null : instances.get(0);
return serviceInstance != null ? resolveUri(serviceInstance) : null;
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/LoadBalancedProxyTargetResolver.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.proxytarget;
import com.github.mthizo247.cloud.netflix.zuul.web.socket.ZuulWebSocketProperties;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import java.net.URI;
/**
* Strategy to resolve zuul proxy target from a load balanced client
*
* @author Ronald Mthombeni
* @author Salman Noor
*/
public class LoadBalancedProxyTargetResolver extends AbstractProxyTargetResolver {
public static final int DEFAULT_ORDER = HIGHEST_PRECEDENCE + 10;
private LoadBalancerClient loadBalancerClient;
public LoadBalancedProxyTargetResolver(LoadBalancerClient loadBalancerClient, ZuulProperties zuulProperties) {
super(zuulProperties);
Assert.notNull(loadBalancerClient, "loadBalancerClient can't be null");
this.loadBalancerClient = loadBalancerClient;
this.order = DEFAULT_ORDER;
}
@Override
public URI resolveTarget(ZuulWebSocketProperties.WsBrokerage wsBrokerage) {
ZuulProperties.ZuulRoute zuulRoute = resolveRoute(wsBrokerage);
if (zuulRoute == null || StringUtils.isEmpty(zuulRoute.getServiceId())) return null;
ServiceInstance serviceInstance = loadBalancerClient.choose(zuulRoute.getServiceId());
return serviceInstance != null ? resolveUri(serviceInstance) : null;
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/ProxyTargetResolver.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.proxytarget;
import com.github.mthizo247.cloud.netflix.zuul.web.socket.ZuulWebSocketProperties;
import java.net.URI;
/**
* Strategy to resolve zuul proxy target
*
* @author Ronald Mthombeni
* @author Salman Noor
*/
public interface ProxyTargetResolver {
URI resolveTarget(ZuulWebSocketProperties.WsBrokerage wsBrokerage);
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/UrlProxyTargetResolver.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.proxytarget;
import com.github.mthizo247.cloud.netflix.zuul.web.socket.ZuulWebSocketProperties;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.util.StringUtils;
import java.net.URI;
import java.net.URISyntaxException;
/**
* Strategy to resolve zuul proxy target from a load balanced client
*
* @author Ronald Mthombeni
* @author Salman Noor
*/
public class UrlProxyTargetResolver extends AbstractProxyTargetResolver {
public static final int DEFAULT_ORDER = EurekaProxyTargetResolver.DEFAULT_ORDER + 10;
public UrlProxyTargetResolver(ZuulProperties zuulProperties) {
super(zuulProperties);
this.order = DEFAULT_ORDER;
}
@Override
public URI resolveTarget(ZuulWebSocketProperties.WsBrokerage wsBrokerage) {
ZuulProperties.ZuulRoute zuulRoute = resolveRoute(wsBrokerage);
if (zuulRoute == null || StringUtils.isEmpty(zuulRoute.getUrl())) return null;
try {
return new URI(zuulRoute.getUrl());
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/CompositeErrorHandler.java
================================================
package com.github.mthizo247.cloud.netflix.zuul.web.socket;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.List;
/**
* Created by ronald22 on 06/04/2017.
*/
public class CompositeErrorHandler implements ProxyWebSocketErrorHandler {
protected final Log logger = LogFactory.getLog(getClass());
private final List<ProxyWebSocketErrorHandler> errorHandlers;
public CompositeErrorHandler(final List<ProxyWebSocketErrorHandler> handlers) {
this.errorHandlers = handlers;
}
@Override
public void handleError(Throwable t) {
for (ProxyWebSocketErrorHandler handler : errorHandlers) {
callErrorHandler(handler, t);
}
}
private void callErrorHandler(ProxyWebSocketErrorHandler handler, Throwable t) {
try {
handler.handleError(t);
} catch (Throwable e) {
logger.error("Error executing error handler " + handler, e);
}
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/EnableZuulWebSocket.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.socket;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Import;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Sets up a Zuul web socket configuration so that it can bridge web socket communication
* to backend servers.
*
* @author Ronald Mthombeni
* @author Salman Noor
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@EnableZuulProxy
@EnableWebSocketMessageBroker
@Import(ZuulWebSocketConfiguration.class)
public @interface EnableZuulWebSocket {
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ProxySessionException.java
================================================
package com.github.mthizo247.cloud.netflix.zuul.web.socket;
import org.springframework.messaging.simp.stomp.StompSession;
/**
* Created by ronald22 on 06/04/2017.
*/
public class ProxySessionException extends Exception {
private final ProxyWebSocketConnectionManager connectionManager;
private final StompSession session;
public ProxySessionException(ProxyWebSocketConnectionManager connectionManager,
StompSession session, Throwable cause) {
super(cause);
this.connectionManager = connectionManager;
this.session = session;
}
public ProxyWebSocketConnectionManager getConnectionManager() {
return connectionManager;
}
public StompSession getSession() {
return session;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ProxySessionException that = (ProxySessionException) o;
if (connectionManager != null ? !connectionManager.equals(that.connectionManager) : that.connectionManager != null)
return false;
return session != null ? session.equals(that.session) : that.session == null;
}
@Override
public int hashCode() {
int result = connectionManager != null ? connectionManager.hashCode() : 0;
result = 31 * result + (session != null ? session.hashCode() : 0);
return result;
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ProxyWebSocketConnectionManager.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.socket;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.messaging.simp.stomp.StompCommand;
import org.springframework.messaging.simp.stomp.StompHeaders;
import org.springframework.messaging.simp.stomp.StompSession;
import org.springframework.messaging.simp.stomp.StompSessionHandler;
import org.springframework.util.ErrorHandler;
import org.springframework.web.socket.WebSocketHttpHeaders;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.client.ConnectionManagerSupport;
import org.springframework.web.socket.messaging.WebSocketStompClient;
import java.lang.reflect.Type;
import java.security.Principal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
* A web socket connection manager bridge between client and backend server via zuul
* reverse proxy
*
* @author Ronald Mthombeni
* @author Salman Noor
*/
public class ProxyWebSocketConnectionManager extends ConnectionManagerSupport
implements StompSessionHandler {
private final WebSocketStompClient stompClient;
private final WebSocketSession userAgentSession;
private final WebSocketHttpHeadersCallback httpHeadersCallback;
private StompSession serverSession;
private Map<String, StompSession.Subscription> subscriptions = new ConcurrentHashMap<>();
private ErrorHandler errorHandler;
private SimpMessagingTemplate messagingTemplate;
public ProxyWebSocketConnectionManager(SimpMessagingTemplate messagingTemplate,
WebSocketStompClient stompClient, WebSocketSession userAgentSession,
WebSocketHttpHeadersCallback httpHeadersCallback, String uri) {
super(uri);
this.messagingTemplate = messagingTemplate;
this.stompClient = stompClient;
this.userAgentSession = userAgentSession;
this.httpHeadersCallback = httpHeadersCallback;
}
public void errorHandler(ErrorHandler errorHandler) {
this.errorHandler = errorHandler;
}
private WebSocketHttpHeaders buildWebSocketHttpHeaders() {
WebSocketHttpHeaders wsHeaders = new WebSocketHttpHeaders();
if (httpHeadersCallback != null) {
httpHeadersCallback.applyHeaders(userAgentSession, wsHeaders);
}
return wsHeaders;
}
@Override
protected void openConnection() {
connect();
}
public void connect() {
try {
serverSession = stompClient
.connect(getUri().toString(), buildWebSocketHttpHeaders(), this)
.get();
} catch (Exception e) {
logger.error("Error connecting to web socket uri " + getUri(), e);
throw new RuntimeException(e);
}
}
public void reconnect(final long delay) {
if (delay > 0) {
logger.warn("Connection lost or refused, will attempt to reconnect after "
+ delay + " millis");
try {
Thread.sleep(delay);
} catch (InterruptedException e) {
//
}
}
Set<String> destinations = new HashSet<>(subscriptions.keySet());
connect();
for (String destination : destinations) {
try {
subscribe(destination);
} catch (Exception ignored) {
// nothing
}
}
}
@Override
protected void closeConnection() throws Exception {
if (isConnected()) {
this.serverSession.disconnect();
}
}
@Override
protected boolean isConnected() {
return (this.serverSession != null && this.serverSession.isConnected());
}
@Override
public void afterConnected(StompSession session, StompHeaders connectedHeaders) {
if (logger.isDebugEnabled()) {
logger.debug("Proxied target now connected " + session);
}
}
@Override
public void handleException(StompSession session, StompCommand command,
StompHeaders headers, byte[] payload, Throwable ex) {
if (errorHandler != null) {
errorHandler.handleError(new ProxySessionException(this, session, ex));
}
}
@Override
public void handleTransportError(StompSession session, Throwable ex) {
if (errorHandler != null) {
errorHandler.handleError(new ProxySessionException(this, session, ex));
}
}
@Override
public Type getPayloadType(StompHeaders headers) {
return Object.class;
}
public void sendMessage(final String destination, final Object msg) {
if (msg instanceof String) { // in case of a json string to avoid double
// converstion by the converters
serverSession.send(destination, ((String) msg).getBytes());
return;
}
serverSession.send(destination, msg);
}
@Override
public void handleFrame(StompHeaders headers, Object payload) {
if (headers.getDestination() != null) {
String destination = headers.getDestination();
if (logger.isDebugEnabled()) {
logger.debug("Received " + payload + ", To " + headers.getDestination());
}
Principal principal = userAgentSession.getPrincipal();
String userDestinationPrefix = messagingTemplate.getUserDestinationPrefix();
if (principal != null && destination.startsWith(userDestinationPrefix)) {
destination = destination.substring(userDestinationPrefix.length());
destination = destination.startsWith("/") ? destination
: "/" + destination;
messagingTemplate.convertAndSendToUser(principal.getName(), destination,
payload, copyHeaders(headers.toSingleValueMap()));
} else {
messagingTemplate.convertAndSend(destination, payload,
copyHeaders(headers.toSingleValueMap()));
}
}
}
private Map<String, Object> copyHeaders(Map<String, String> original) {
Map<String, Object> copy = new HashMap<>();
for (String key : original.keySet()) {
copy.put(key, original.get(key));
}
return copy;
}
private void connectIfNecessary() {
if (!isConnected()) {
connect();
}
}
public void subscribe(String destination) throws Exception {
connectIfNecessary();
StompSession.Subscription subscription = serverSession.subscribe(destination,
this);
subscriptions.put(destination, subscription);
}
public void unsubscribe(String destination) {
StompSession.Subscription subscription = subscriptions.remove(destination);
if (subscription != null) {
connectIfNecessary();
subscription.unsubscribe();
}
}
public boolean isConnectedToUserAgent() {
return (userAgentSession != null && userAgentSession.isOpen());
}
public void disconnect() {
try {
closeConnection();
} catch (Exception e) {
// nothing
}
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ProxyWebSocketErrorHandler.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.socket;
import org.springframework.util.ErrorHandler;
/**
* A simple tagging interface for pluggable web socket connection error handlers
*
* @author Ronald Mthombeni
* @author Salman Noor
*/
public interface ProxyWebSocketErrorHandler extends ErrorHandler {
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ProxyWebSocketHandler.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.socket;
import com.github.mthizo247.cloud.netflix.zuul.web.proxytarget.ProxyTargetResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.messaging.simp.stomp.StompCommand;
import org.springframework.util.Assert;
import org.springframework.util.ErrorHandler;
import org.springframework.util.PatternMatchUtils;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.WebSocketMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.WebSocketHandlerDecorator;
import org.springframework.web.socket.messaging.WebSocketStompClient;
import org.springframework.web.util.UriComponentsBuilder;
import java.net.URI;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* A {@link WebSocketHandlerDecorator} that adds web socket support to zuul reverse proxy.
*
* @author Ronald Mthombeni
* @author Salman Noor
*/
public class ProxyWebSocketHandler extends WebSocketHandlerDecorator {
private final Logger logger = LoggerFactory.getLogger(ProxyWebSocketHandler.class);
private final WebSocketHttpHeadersCallback headersCallback;
private final SimpMessagingTemplate messagingTemplate;
private final ProxyTargetResolver proxyTargetResolver;
private final ZuulWebSocketProperties zuulWebSocketProperties;
private final WebSocketStompClient stompClient;
private final Map<WebSocketSession, ProxyWebSocketConnectionManager> managers = new ConcurrentHashMap<>();
private ErrorHandler errorHandler;
public ProxyWebSocketHandler(WebSocketHandler delegate,
WebSocketStompClient stompClient,
WebSocketHttpHeadersCallback headersCallback,
SimpMessagingTemplate messagingTemplate,
ProxyTargetResolver proxyTargetResolver,
ZuulWebSocketProperties zuulWebSocketProperties) {
super(delegate);
this.stompClient = stompClient;
this.headersCallback = headersCallback;
this.messagingTemplate = messagingTemplate;
this.proxyTargetResolver = proxyTargetResolver;
this.zuulWebSocketProperties = zuulWebSocketProperties;
}
public void errorHandler(ErrorHandler errorHandler) {
this.errorHandler = errorHandler;
}
private String getWebSocketServerPath(ZuulWebSocketProperties.WsBrokerage wsBrokerage,
URI uri) {
String path = uri.toString();
if (path.contains(":")) {
path = UriComponentsBuilder.fromUriString(path).build().getPath();
}
for (String endPoint : wsBrokerage.getEndPoints()) {
if (PatternMatchUtils.simpleMatch(toPattern(endPoint), path + "/")) {
return endPoint;
}
}
return null;
}
private ZuulWebSocketProperties.WsBrokerage getWebSocketBrokarage(URI uri) {
String path = uri.toString();
if (path.contains(":")) {
path = UriComponentsBuilder.fromUriString(path).build().getPath();
}
for (Map.Entry<String, ZuulWebSocketProperties.WsBrokerage> entry : zuulWebSocketProperties
.getBrokerages().entrySet()) {
ZuulWebSocketProperties.WsBrokerage wsBrokerage = entry.getValue();
if (wsBrokerage.isEnabled()) {
for (String endPoint : wsBrokerage.getEndPoints()) {
if (PatternMatchUtils.simpleMatch(toPattern(endPoint), path + "/")) {
return wsBrokerage;
}
}
}
}
return null;
}
private String toPattern(String path) {
path = path.startsWith("/") ? "**" + path : "**/" + path;
return path.endsWith("/") ? path + "**" : path + "/**";
}
@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus)
throws Exception {
disconnectFromProxiedTarget(session);
super.afterConnectionClosed(session, closeStatus);
}
@Override
public void handleMessage(WebSocketSession session, WebSocketMessage<?> message)
throws Exception {
super.handleMessage(session, message);
handleMessageFromClient(session, message);
}
private void handleMessageFromClient(WebSocketSession session,
WebSocketMessage<?> message) throws Exception {
boolean handled = false;
WebSocketMessageAccessor accessor = WebSocketMessageAccessor.create(message);
if (StompCommand.SEND.toString().equalsIgnoreCase(accessor.getCommand())) {
handled = true;
sendMessageToProxiedTarget(session, accessor);
}
if (StompCommand.SUBSCRIBE.toString().equalsIgnoreCase(accessor.getCommand())) {
handled = true;
subscribeToProxiedTarget(session, accessor);
}
if (StompCommand.UNSUBSCRIBE.toString().equalsIgnoreCase(accessor.getCommand())) {
handled = true;
unsubscribeFromProxiedTarget(session, accessor);
}
if (StompCommand.CONNECT.toString().equalsIgnoreCase(accessor.getCommand())) {
handled = true;
connectToProxiedTarget(session);
}
if (!handled) {
if (logger.isDebugEnabled()) {
logger.debug("STOMP COMMAND " + accessor.getCommand()
+ " was not explicitly handled");
}
}
}
private void connectToProxiedTarget(WebSocketSession session) {
URI sessionUri = session.getUri();
ZuulWebSocketProperties.WsBrokerage wsBrokerage = getWebSocketBrokarage(
sessionUri);
Assert.notNull(wsBrokerage, "wsBrokerage must not be null");
String path = getWebSocketServerPath(wsBrokerage, sessionUri);
Assert.notNull(path, "Web socket uri path must be null");
URI routeTarget = proxyTargetResolver.resolveTarget(wsBrokerage);
Assert.notNull(routeTarget, "routeTarget must not be null");
String uri = ServletUriComponentsBuilder
.fromUri(routeTarget)
.path(path)
.replaceQuery(sessionUri.getQuery())
.toUriString();
ProxyWebSocketConnectionManager connectionManager = new ProxyWebSocketConnectionManager(
messagingTemplate, stompClient, session, headersCallback, uri);
connectionManager.errorHandler(this.errorHandler);
managers.put(session, connectionManager);
connectionManager.start();
}
private void disconnectFromProxiedTarget(WebSocketSession session) {
disconnectProxyManager(managers.remove(session));
}
private void disconnectProxyManager(ProxyWebSocketConnectionManager proxyManager) {
if (proxyManager != null) {
try {
proxyManager.disconnect();
} catch (Throwable ignored) {
// nothing
}
}
}
private void unsubscribeFromProxiedTarget(WebSocketSession session,
WebSocketMessageAccessor accessor) {
ProxyWebSocketConnectionManager manager = managers.get(session);
if (manager != null) {
manager.unsubscribe(accessor.getDestination());
}
}
private void sendMessageToProxiedTarget(WebSocketSession session,
WebSocketMessageAccessor accessor) {
ProxyWebSocketConnectionManager manager = managers.get(session);
manager.sendMessage(accessor.getDestination(), accessor.getPayload());
}
private void subscribeToProxiedTarget(WebSocketSession session,
WebSocketMessageAccessor accessor) throws Exception {
ProxyWebSocketConnectionManager manager = managers.get(session);
manager.subscribe(accessor.getDestination());
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ReconnectErrorHandler.java
================================================
package com.github.mthizo247.cloud.netflix.zuul.web.socket;
import com.github.mthizo247.cloud.netflix.zuul.web.util.ErrorAnalyzer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.messaging.simp.stomp.ConnectionLostException;
import java.io.IOException;
/**
* Created by ronald22 on 06/04/2017.
*/
public class ReconnectErrorHandler implements ProxyWebSocketErrorHandler {
private static final long CONNECTION_LOST_RECONNECT_INTERVAL = 10000;
private final Log logger = LogFactory
.getLog(ReconnectErrorHandler.class);
private ErrorAnalyzer errorAnalyzer;
public ReconnectErrorHandler(ErrorAnalyzer errorAnalyzer) {
this.errorAnalyzer = errorAnalyzer;
}
@Override
public void handleError(Throwable t) {
if (logger.isErrorEnabled()) {
logger.error("Proxy web socket error occurred.", t);
}
if (!(t instanceof ProxySessionException))
return;
ProxySessionException exception = (ProxySessionException) t;
if (shouldAttemptToReconnect(exception)) {
executeReconnectThread(exception.getConnectionManager());
}
}
private boolean shouldAttemptToReconnect(ProxySessionException proxyException) {
if (!isConnectionLost(proxyException))
return false;
if (!proxyException.getConnectionManager().isConnectedToUserAgent())
return false;
return true;
}
private boolean isConnectionLost(ProxySessionException proxyException) {
Throwable cause = proxyException.getCause();
Throwable[] causeChain = errorAnalyzer.determineCauseChain(cause);
Throwable throwable = errorAnalyzer
.getFirstThrowableOfType(ConnectionLostException.class, causeChain);
if (throwable != null)
return true;
throwable = errorAnalyzer.getFirstThrowableOfType(IOException.class,
causeChain);
return throwable != null
&& throwable.getMessage().toLowerCase().contains(" refused ");
}
private void executeReconnectThread(
final ProxyWebSocketConnectionManager clientConnectionManager) {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
clientConnectionManager.reconnect(CONNECTION_LOST_RECONNECT_INTERVAL);
}
});
t.setDaemon(true);
t.start();
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/WebSocketHttpHeadersCallback.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.socket;
import org.springframework.web.socket.WebSocketHttpHeaders;
import org.springframework.web.socket.WebSocketSession;
/**
* Callback strategy to supply web socket headers to handshake requests.
*
* @author Ronald Mthombeni
* @author Salman Noor
*/
public interface WebSocketHttpHeadersCallback {
void applyHeaders(WebSocketSession userAgentSession, WebSocketHttpHeaders headers);
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/WebSocketMessageAccessor.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.socket;
import org.springframework.util.StringUtils;
import org.springframework.web.socket.WebSocketMessage;
/**
* An accessor to acess web socket messages before discpatching them to the backend
* server.
*
* @author Ronald Mthombeni
* @author Salman Noor
*/
public final class WebSocketMessageAccessor {
private String[] messageComponents;
private WebSocketMessageAccessor() {
}
public static WebSocketMessageAccessor create(WebSocketMessage<?> message) {
String msgPayload = message.getPayload().toString();
return create(msgPayload);
}
public static WebSocketMessageAccessor create(String message) {
WebSocketMessageAccessor accessor = new WebSocketMessageAccessor();
accessor.messageComponents = StringUtils.tokenizeToStringArray(message, "\n");
return accessor;
}
public String getCommand() {
if (accessible())
return messageComponents[0];
return null;
}
private boolean accessible() {
return messageComponents != null && messageComponents.length > 0;
}
public String getDestination() {
return getHeader("destination");
}
public String getHeader(String header) {
if (!accessible())
return null;
header = header.endsWith(":") ? header : header + ":";
if (accessible()) {
for (String messageComponent : messageComponents) {
int indx = messageComponent.indexOf(header);
if (indx != -1) {
return messageComponent.substring(indx + header.length());
}
}
}
return null;
}
public String getPayload() {
if (!accessible())
return null;
return messageComponents[messageComponents.length - 1];
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ZuulWebSocketConfiguration.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.socket;
import com.github.mthizo247.cloud.netflix.zuul.web.authentication.BasicAuthPrincipalHeadersCallback;
import com.github.mthizo247.cloud.netflix.zuul.web.authentication.CompositeHeadersCallback;
import com.github.mthizo247.cloud.netflix.zuul.web.authentication.LoginCookieHeadersCallback;
import com.github.mthizo247.cloud.netflix.zuul.web.authentication.OAuth2BearerPrincipalHeadersCallback;
import com.github.mthizo247.cloud.netflix.zuul.web.filter.ProxyRedirectFilter;
import com.github.mthizo247.cloud.netflix.zuul.web.proxytarget.CompositeProxyTargetResolver;
import com.github.mthizo247.cloud.netflix.zuul.web.proxytarget.EurekaProxyTargetResolver;
import com.github.mthizo247.cloud.netflix.zuul.web.proxytarget.LoadBalancedProxyTargetResolver;
import com.github.mthizo247.cloud.netflix.zuul.web.proxytarget.ProxyTargetResolver;
import com.github.mthizo247.cloud.netflix.zuul.web.proxytarget.UrlProxyTargetResolver;
import com.github.mthizo247.cloud.netflix.zuul.web.util.DefaultErrorAnalyzer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.cloud.netflix.zuul.filters.RouteLocator;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.messaging.converter.MessageConverter;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.client.WebSocketClient;
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration;
import org.springframework.web.socket.config.annotation.SockJsServiceRegistration;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketTransportRegistration;
import org.springframework.web.socket.handler.WebSocketHandlerDecoratorFactory;
import org.springframework.web.socket.messaging.WebSocketStompClient;
import org.springframework.web.socket.sockjs.client.SockJsClient;
import org.springframework.web.socket.sockjs.client.Transport;
import org.springframework.web.socket.sockjs.client.WebSocketTransport;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* Zuul reverse proxy web socket configuration
*
* @author Ronald Mthombeni
* @author Salman Noor
*/
@Configuration
@ConditionalOnWebApplication
@ConditionalOnClass(WebSocketHandler.class)
@ConditionalOnProperty(prefix = "zuul.ws", name = "enabled", havingValue = "true", matchIfMissing = true)
@EnableConfigurationProperties(ZuulWebSocketProperties.class)
@AutoConfigureAfter(DelegatingWebSocketMessageBrokerConfiguration.class)
public class ZuulWebSocketConfiguration extends AbstractWebSocketMessageBrokerConfigurer
implements ApplicationListener<ContextRefreshedEvent> {
@Autowired
ZuulWebSocketProperties zuulWebSocketProperties;
@Autowired
SimpMessagingTemplate messagingTemplate;
@Autowired
ZuulProperties zuulProperties;
@Autowired
@Qualifier("compositeProxyTargetResolver")
ProxyTargetResolver proxyTargetResolver;
@Autowired
ProxyWebSocketErrorHandler proxyWebSocketErrorHandler;
@Autowired
WebSocketStompClient stompClient;
@Autowired
@Qualifier("compositeHeadersCallback")
WebSocketHttpHeadersCallback webSocketHttpHeadersCallback;
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
boolean wsEnabled = false;
for (Map.Entry<String, ZuulWebSocketProperties.WsBrokerage> entry : zuulWebSocketProperties
.getBrokerages().entrySet()) {
ZuulWebSocketProperties.WsBrokerage wsBrokerage = entry.getValue();
if (wsBrokerage.isEnabled()) {
this.addStompEndpoint(registry, wsBrokerage.getEndPoints());
wsEnabled = true;
}
}
if (!wsEnabled)
this.addStompEndpoint(registry, UUID.randomUUID().toString());
}
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
// prefix for subscribe
for (Map.Entry<String, ZuulWebSocketProperties.WsBrokerage> entry : zuulWebSocketProperties
.getBrokerages().entrySet()) {
ZuulWebSocketProperties.WsBrokerage wsBrokerage = entry.getValue();
if (wsBrokerage.isEnabled()) {
config.enableSimpleBroker(
mergeBrokersWithApplicationDestinationPrefixes(wsBrokerage));
// prefix for send
config.setApplicationDestinationPrefixes(
wsBrokerage.getDestinationPrefixes());
}
}
}
private SockJsServiceRegistration addStompEndpoint(StompEndpointRegistry registry, String... endpoint) {
return registry.addEndpoint(endpoint)
// bypasses spring web security
.setAllowedOrigins("*").withSockJS();
}
private String[] mergeBrokersWithApplicationDestinationPrefixes(
ZuulWebSocketProperties.WsBrokerage wsBrokerage) {
List<String> brokers = new ArrayList<>(Arrays.asList(wsBrokerage.getBrokers()));
for (String adp : wsBrokerage.getDestinationPrefixes()) {
if (!brokers.contains(adp)) {
brokers.add(adp);
}
}
return brokers.toArray(new String[brokers.size()]);
}
@Override
public void configureWebSocketTransport(WebSocketTransportRegistration registration) {
registration.addDecoratorFactory(new WebSocketHandlerDecoratorFactory() {
@Override
public WebSocketHandler decorate(WebSocketHandler handler) {
ProxyWebSocketHandler proxyWebSocketHandler = new ProxyWebSocketHandler(
handler, stompClient, webSocketHttpHeadersCallback,
messagingTemplate,
proxyTargetResolver,
zuulWebSocketProperties);
proxyWebSocketHandler.errorHandler(proxyWebSocketErrorHandler);
return proxyWebSocketHandler;
}
});
}
@Bean
@Primary
public WebSocketHttpHeadersCallback compositeHeadersCallback(final List<WebSocketHttpHeadersCallback> headersCallbacks) {
return new CompositeHeadersCallback(headersCallbacks);
}
@Bean
@ConditionalOnClass(name = "org.springframework.security.core.Authentication")
public WebSocketHttpHeadersCallback basicAuthPrincipalHeadersCallback() {
return new BasicAuthPrincipalHeadersCallback();
}
@Bean
@ConditionalOnClass(name = "org.springframework.security.core.OAuth2Authentication")
public WebSocketHttpHeadersCallback oauth2BearerPrincipalHeadersCallback() {
return new OAuth2BearerPrincipalHeadersCallback();
}
@Bean
public WebSocketHttpHeadersCallback loginCookieHeadersCallback() {
return new LoginCookieHeadersCallback();
}
@Bean
public ProxyTargetResolver urlProxyTargetResolver(
final ZuulProperties zuulProperties) {
return new UrlProxyTargetResolver(zuulProperties);
}
@Bean
public ProxyTargetResolver discoveryProxyTargetResolver(
final ZuulProperties zuulProperties, final DiscoveryClient discoveryClient) {
return new EurekaProxyTargetResolver(discoveryClient, zuulProperties);
}
@Bean
public ProxyTargetResolver loadBalancedProxyTargetResolver(
final ZuulProperties zuulProperties, final LoadBalancerClient loadBalancerClient) {
return new LoadBalancedProxyTargetResolver(loadBalancerClient, zuulProperties);
}
@Bean
@Primary
public ProxyTargetResolver compositeProxyTargetResolver(final List<ProxyTargetResolver> resolvers) {
return new CompositeProxyTargetResolver(resolvers);
}
@Bean
@ConditionalOnMissingBean(WebSocketStompClient.class)
public WebSocketStompClient stompClient(WebSocketClient webSocketClient, MessageConverter messageConverter,
@Qualifier("proxyStompClientTaskScheduler") TaskScheduler taskScheduler) {
int bufferSizeLimit = 1024 * 1024 * 8;
WebSocketStompClient client = new WebSocketStompClient(webSocketClient);
client.setInboundMessageSizeLimit(bufferSizeLimit);
client.setMessageConverter(messageConverter);
client.setTaskScheduler(taskScheduler);
client.setDefaultHeartbeat(new long[]{0, 0});
return client;
}
@Bean
@ConditionalOnMissingBean(WebSocketClient.class)
public WebSocketClient webSocketClient() {
StandardWebSocketClient webSocketClient = new StandardWebSocketClient();
List<Transport> transports = new ArrayList<>();
transports.add(new WebSocketTransport(webSocketClient));
return new SockJsClient(transports);
}
@Bean
@Qualifier("proxyStompClientTaskScheduler")
public TaskScheduler stompClientTaskScheduler() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setThreadNamePrefix("ProxyStompClient-");
scheduler.setPoolSize(Runtime.getRuntime().availableProcessors());
return scheduler;
}
@Bean
public ProxyWebSocketErrorHandler reconnectErrorHandler() {
return new ReconnectErrorHandler(new DefaultErrorAnalyzer());
}
@Bean
@Primary
public ProxyWebSocketErrorHandler compositeErrorHandler(final List<ProxyWebSocketErrorHandler> errorHandlers) {
return new CompositeErrorHandler(errorHandlers);
}
@Bean
public ProxyRedirectFilter proxyRedirectFilter(RouteLocator routeLocator) {
return new ProxyRedirectFilter(routeLocator);
}
@PostConstruct
public void init() {
ignorePattern("**/websocket");
ignorePattern("**/info");
}
private void ignorePattern(String ignoredPattern) {
for (String pattern : zuulProperties.getIgnoredPatterns()) {
if (pattern.toLowerCase().contains(ignoredPattern))
return;
}
zuulProperties.getIgnoredPatterns().add(ignoredPattern);
}
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
init();
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ZuulWebSocketProperties.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.socket;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.PostConstruct;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.StringUtils;
/**
* @author Ronald Mthombeni
* @author Salman Noor
*/
@ConfigurationProperties("zuul.ws")
public class ZuulWebSocketProperties {
private boolean enabled = true;
private Map<String, WsBrokerage> brokerages = new HashMap<>();
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public Map<String, WsBrokerage> getBrokerages() {
return brokerages;
}
public void setBrokerages(Map<String, WsBrokerage> brokerages) {
this.brokerages = brokerages;
}
@PostConstruct
public void init() {
for (Map.Entry<String, WsBrokerage> entry : this.brokerages.entrySet()) {
WsBrokerage wsBrokerage = entry.getValue();
if (!StringUtils.hasText(wsBrokerage.getId())) {
wsBrokerage.id = entry.getKey();
}
}
}
public static class WsBrokerage {
private boolean enabled = true;
private String id;
private String routeId;
private String[] endPoints;
private String[] brokers;
private String[] destinationPrefixes;
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getRouteId() {
return routeId;
}
public void setRouteId(String routeId) {
this.routeId = routeId;
}
public String[] getEndPoints() {
return endPoints;
}
public void setEndPoints(String[] endPoints) {
this.endPoints = endPoints;
}
public String[] getBrokers() {
return brokers;
}
public void setBrokers(String[] brokers) {
this.brokers = brokers;
}
public String[] getDestinationPrefixes() {
return destinationPrefixes;
}
public void setDestinationPrefixes(String[] destinationPrefixes) {
this.destinationPrefixes = destinationPrefixes;
}
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/util/DefaultErrorAnalyzer.java
================================================
package com.github.mthizo247.cloud.netflix.zuul.web.util;
import java.util.ArrayList;
import java.util.List;
/**
* Created by ronald22 on 13/02/2018.
*/
public class DefaultErrorAnalyzer implements ErrorAnalyzer {
@Override
public Throwable[] determineCauseChain(Throwable throwable) {
List<Throwable> chain = new ArrayList<>();
Throwable currentThrowable = throwable;
while (currentThrowable != null) {
chain.add(currentThrowable);
currentThrowable = currentThrowable.getCause();
}
return chain.toArray(new Throwable[chain.size()]);
}
@Override
public Throwable getFirstThrowableOfType(Class<? extends Throwable> throwableType, Throwable[] chain) {
if (chain != null) {
for (Throwable t : chain) {
if ((t != null) && throwableType.isInstance(t)) {
return t;
}
}
}
return null;
}
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/util/ErrorAnalyzer.java
================================================
package com.github.mthizo247.cloud.netflix.zuul.web.util;
/**
* Created by ronald22 on 13/02/2018.
*/
public interface ErrorAnalyzer {
Throwable[] determineCauseChain(Throwable throwable);
Throwable getFirstThrowableOfType(Class<? extends Throwable> throwableType, Throwable[] chain);
}
================================================
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/util/MapPropertyResolver.java
================================================
package com.github.mthizo247.cloud.netflix.zuul.web.util;
import org.springframework.core.env.AbstractPropertyResolver;
import java.util.Map;
/**
* @author Ronald Mthombeni
*/
public class MapPropertyResolver extends AbstractPropertyResolver {
private Map<String, Object> map;
public MapPropertyResolver(Map<String, Object> map) {
this.map = map;
}
@Override
protected String getPropertyAsRawString(String key) {
Object v = map.get(key);
return v != null ? v.toString() : null;
}
@Override
public <T> T getProperty(String key, Class<T> targetType) {
Object v = map.get(key);
if (v != null) {
return targetType.cast(v);
}
return null;
}
}
================================================
FILE: src/test/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ProxyWebSocketConnectionManagerTests.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.socket;
import org.junit.Before;
import org.junit.Test;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.messaging.simp.stomp.StompCommand;
import org.springframework.messaging.simp.stomp.StompHeaders;
import org.springframework.messaging.simp.stomp.StompSession;
import org.springframework.util.ErrorHandler;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.socket.WebSocketHttpHeaders;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.messaging.WebSocketStompClient;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* @author Ronald Mthombeni
* @author Salman Noor
*/
public class ProxyWebSocketConnectionManagerTests {
private ProxyWebSocketConnectionManager proxyConnectionManager;
private SimpMessagingTemplate messagingTemplate = mock(SimpMessagingTemplate.class);
private WebSocketStompClient stompClient = mock(WebSocketStompClient.class);
private WebSocketSession wsSession = mock(WebSocketSession.class);
private WebSocketHttpHeadersCallback headersCallback = mock(
WebSocketHttpHeadersCallback.class);
private StompSession serverSession = mock(StompSession.class);
private ListenableFuture<StompSession> listenableFuture = (ListenableFuture<StompSession>) mock(
ListenableFuture.class);
private ErrorHandler errHandler = mock(ErrorHandler.class);
@Before
public void init() throws Exception {
String uri = "http://example.com";
proxyConnectionManager = new ProxyWebSocketConnectionManager(messagingTemplate,
stompClient, wsSession, headersCallback, uri);
proxyConnectionManager.errorHandler(errHandler);
when(listenableFuture.get()).thenReturn(serverSession);
when(stompClient.connect(uri, new WebSocketHttpHeaders(),
proxyConnectionManager)).thenReturn(listenableFuture);
}
@Test
public void sendStringMessageAsBytes() throws Exception {
String destination = "/app/messages";
String message = "hello";
proxyConnectionManager.start();
proxyConnectionManager.sendMessage(destination, message);
verify(serverSession).send(destination, message.getBytes());
}
@Test
public void handlesExcpetionUsingErrorHandler() throws Exception {
StompHeaders headers = new StompHeaders();
byte[] payload = new byte[0];
Throwable exception = new Exception("E");
proxyConnectionManager.handleException(serverSession, StompCommand.MESSAGE,
headers, payload, exception);
verify(errHandler).handleError(new ProxySessionException(proxyConnectionManager, serverSession, exception));
}
@Test
public void handlesTransportErrorUsingErrorHandler() throws Exception {
Throwable exception = new Exception("E");
proxyConnectionManager.handleTransportError(serverSession, exception);
verify(errHandler).handleError(new ProxySessionException(proxyConnectionManager, serverSession, exception));
}
}
================================================
FILE: src/test/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/WebSocketMessageAccessorTests.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.socket;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import org.junit.Test;
/**
* @author Ronald Mthombeni
* @author Salman Noor
*/
public class WebSocketMessageAccessorTests {
private WebSocketMessageAccessor accessor;
@Test
public void connect() throws Exception {
accessor = WebSocketMessageAccessor.create("CONNECT\n"
+ "accept-version:1.1,1.0\n" + "heart-beat:10000,10000\n" + "\n");
assertThat(accessor.getCommand(), is("CONNECT"));
}
@Test
public void subscribe() throws Exception {
accessor = WebSocketMessageAccessor.create(
"SUBSCRIBE\n" + "id:sub-0\n" + "destination:/topic/greetings\n" + "\n");
assertThat(accessor.getCommand(), is("SUBSCRIBE"));
assertThat(accessor.getDestination(), is("/topic/greetings"));
}
@Test
public void send() throws Exception {
accessor = WebSocketMessageAccessor.create("SEND\n" + "destination:/app/hello\n"
+ "content-length:16\n" + "\n" + "{\"name\":\"hell9\"}");
assertThat(accessor.getCommand(), is("SEND"));
assertThat(accessor.getDestination(), is("/app/hello"));
assertThat(accessor.getPayload(), is("{\"name\":\"hell9\"}"));
}
}
================================================
FILE: src/test/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ZuulWebSocketPropertiesTests.java
================================================
/*
* Copyright 2002-2017 the original author or authors.
*
* 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 com.github.mthizo247.cloud.netflix.zuul.web.socket;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
/**
* @author Ronald Mthombeni
* @author Salman Noor
*/
public class ZuulWebSocketPropertiesTests {
private ZuulWebSocketProperties properties;
@Before
public void setUp() throws Exception {
properties = new ZuulWebSocketProperties();
}
@Test
public void brokerageIdSet() throws Exception {
ZuulWebSocketProperties.WsBrokerage brokerage = new ZuulWebSocketProperties.WsBrokerage();
brokerage.setId("bar");
Map<String, ZuulWebSocketProperties.WsBrokerage> brokerages = new HashMap<>();
brokerages.put("foo", brokerage);
properties.setBrokerages(brokerages);
properties.init();
assertThat(brokerage.getId(), is("bar"));
}
@Test
public void brokerageIdNotSet() throws Exception {
ZuulWebSocketProperties.WsBrokerage brokerage = new ZuulWebSocketProperties.WsBrokerage();
Map<String, ZuulWebSocketProperties.WsBrokerage> brokerages = new HashMap<>();
brokerages.put("foo", brokerage);
properties.setBrokerages(brokerages);
properties.init();
assertThat(brokerage.getId(), is("foo"));
}
}
gitextract_fb8rm5ag/
├── .gitignore
├── LICENSE
├── README.md
├── eclipse-code-formatter.xml
├── pom.xml
└── src/
├── main/
│ └── java/
│ └── com/
│ └── github/
│ └── mthizo247/
│ └── cloud/
│ └── netflix/
│ └── zuul/
│ └── web/
│ ├── authentication/
│ │ ├── AbstractHeadersCallback.java
│ │ ├── BasicAuthPrincipalHeadersCallback.java
│ │ ├── CompositeHeadersCallback.java
│ │ ├── LoginCookieHeadersCallback.java
│ │ └── OAuth2BearerPrincipalHeadersCallback.java
│ ├── filter/
│ │ └── ProxyRedirectFilter.java
│ ├── proxytarget/
│ │ ├── AbstractProxyTargetResolver.java
│ │ ├── CompositeProxyTargetResolver.java
│ │ ├── EurekaProxyTargetResolver.java
│ │ ├── LoadBalancedProxyTargetResolver.java
│ │ ├── ProxyTargetResolver.java
│ │ └── UrlProxyTargetResolver.java
│ ├── socket/
│ │ ├── CompositeErrorHandler.java
│ │ ├── EnableZuulWebSocket.java
│ │ ├── ProxySessionException.java
│ │ ├── ProxyWebSocketConnectionManager.java
│ │ ├── ProxyWebSocketErrorHandler.java
│ │ ├── ProxyWebSocketHandler.java
│ │ ├── ReconnectErrorHandler.java
│ │ ├── WebSocketHttpHeadersCallback.java
│ │ ├── WebSocketMessageAccessor.java
│ │ ├── ZuulWebSocketConfiguration.java
│ │ └── ZuulWebSocketProperties.java
│ └── util/
│ ├── DefaultErrorAnalyzer.java
│ ├── ErrorAnalyzer.java
│ └── MapPropertyResolver.java
└── test/
└── java/
└── com/
└── github/
└── mthizo247/
└── cloud/
└── netflix/
└── zuul/
└── web/
└── socket/
├── ProxyWebSocketConnectionManagerTests.java
├── WebSocketMessageAccessorTests.java
└── ZuulWebSocketPropertiesTests.java
SYMBOL INDEX (175 symbols across 28 files)
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/authentication/AbstractHeadersCallback.java
class AbstractHeadersCallback (line 28) | public abstract class AbstractHeadersCallback implements WebSocketHttpHe...
method applyHeaders (line 31) | @Override
method applyHeadersInternal (line 39) | protected abstract void applyHeadersInternal(WebSocketSession userAgen...
method shouldApplyHeaders (line 41) | protected abstract boolean shouldApplyHeaders(WebSocketSession userAge...
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/authentication/BasicAuthPrincipalHeadersCallback.java
class BasicAuthPrincipalHeadersCallback (line 30) | public class BasicAuthPrincipalHeadersCallback extends AbstractHeadersCa...
method applyHeadersInternal (line 31) | @Override
method shouldApplyHeaders (line 45) | @Override
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/authentication/CompositeHeadersCallback.java
class CompositeHeadersCallback (line 31) | public class CompositeHeadersCallback implements WebSocketHttpHeadersCal...
method CompositeHeadersCallback (line 34) | public CompositeHeadersCallback(final List<WebSocketHttpHeadersCallbac...
method applyHeaders (line 39) | @Override
method getHeadersCallbacks (line 46) | public List<WebSocketHttpHeadersCallback> getHeadersCallbacks() {
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/authentication/LoginCookieHeadersCallback.java
class LoginCookieHeadersCallback (line 30) | public class LoginCookieHeadersCallback extends AbstractHeadersCallback {
method applyHeadersInternal (line 33) | @Override
method shouldApplyHeaders (line 42) | @Override
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/authentication/OAuth2BearerPrincipalHeadersCallback.java
class OAuth2BearerPrincipalHeadersCallback (line 30) | public class OAuth2BearerPrincipalHeadersCallback extends AbstractHeader...
method applyHeadersInternal (line 32) | @Override
method shouldApplyHeaders (line 44) | @Override
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/filter/ProxyRedirectFilter.java
class ProxyRedirectFilter (line 36) | public class ProxyRedirectFilter extends ZuulFilter {
method ProxyRedirectFilter (line 43) | public ProxyRedirectFilter(RouteLocator routeLocator) {
method ProxyRedirectFilter (line 47) | public ProxyRedirectFilter(RouteLocator routeLocator, UrlPathHelper ur...
method filterType (line 52) | @Override
method filterOrder (line 57) | @Override
method shouldFilter (line 62) | @Override
method run (line 102) | @Override
method buildRoutePath (line 115) | private String buildRoutePath(Route route, String httpUrl) {
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/AbstractProxyTargetResolver.java
class AbstractProxyTargetResolver (line 36) | public abstract class AbstractProxyTargetResolver implements ProxyTarget...
method AbstractProxyTargetResolver (line 40) | public AbstractProxyTargetResolver(ZuulProperties zuulProperties) {
method resolveRoute (line 45) | protected ZuulProperties.ZuulRoute resolveRoute(ZuulWebSocketPropertie...
method resolveUri (line 52) | protected URI resolveUri(ServiceInstance serviceInstance) {
method getOrder (line 68) | @Override
method setOrder (line 73) | public void setOrder(int order) {
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/CompositeProxyTargetResolver.java
class CompositeProxyTargetResolver (line 30) | public class CompositeProxyTargetResolver implements ProxyTargetResolver {
method CompositeProxyTargetResolver (line 33) | public CompositeProxyTargetResolver(final List<ProxyTargetResolver> ta...
method resolveTarget (line 37) | @Override
method getTargetResolvers (line 49) | public List<ProxyTargetResolver> getTargetResolvers() {
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/EurekaProxyTargetResolver.java
class EurekaProxyTargetResolver (line 36) | public class EurekaProxyTargetResolver extends AbstractProxyTargetResolv...
method EurekaProxyTargetResolver (line 40) | public EurekaProxyTargetResolver(DiscoveryClient discoveryClient, Zuul...
method resolveTarget (line 48) | @Override
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/LoadBalancedProxyTargetResolver.java
class LoadBalancedProxyTargetResolver (line 34) | public class LoadBalancedProxyTargetResolver extends AbstractProxyTarget...
method LoadBalancedProxyTargetResolver (line 39) | public LoadBalancedProxyTargetResolver(LoadBalancerClient loadBalancer...
method resolveTarget (line 46) | @Override
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/ProxyTargetResolver.java
type ProxyTargetResolver (line 29) | public interface ProxyTargetResolver {
method resolveTarget (line 30) | URI resolveTarget(ZuulWebSocketProperties.WsBrokerage wsBrokerage);
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/UrlProxyTargetResolver.java
class UrlProxyTargetResolver (line 32) | public class UrlProxyTargetResolver extends AbstractProxyTargetResolver {
method UrlProxyTargetResolver (line 35) | public UrlProxyTargetResolver(ZuulProperties zuulProperties) {
method resolveTarget (line 40) | @Override
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/CompositeErrorHandler.java
class CompositeErrorHandler (line 11) | public class CompositeErrorHandler implements ProxyWebSocketErrorHandler {
method CompositeErrorHandler (line 15) | public CompositeErrorHandler(final List<ProxyWebSocketErrorHandler> ha...
method handleError (line 19) | @Override
method callErrorHandler (line 27) | private void callErrorHandler(ProxyWebSocketErrorHandler handler, Thro...
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ProxySessionException.java
class ProxySessionException (line 8) | public class ProxySessionException extends Exception {
method ProxySessionException (line 12) | public ProxySessionException(ProxyWebSocketConnectionManager connectio...
method getConnectionManager (line 19) | public ProxyWebSocketConnectionManager getConnectionManager() {
method getSession (line 23) | public StompSession getSession() {
method equals (line 27) | @Override
method hashCode (line 39) | @Override
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ProxyWebSocketConnectionManager.java
class ProxyWebSocketConnectionManager (line 45) | public class ProxyWebSocketConnectionManager extends ConnectionManagerSu...
method ProxyWebSocketConnectionManager (line 55) | public ProxyWebSocketConnectionManager(SimpMessagingTemplate messaging...
method errorHandler (line 65) | public void errorHandler(ErrorHandler errorHandler) {
method buildWebSocketHttpHeaders (line 69) | private WebSocketHttpHeaders buildWebSocketHttpHeaders() {
method openConnection (line 77) | @Override
method connect (line 82) | public void connect() {
method reconnect (line 93) | public void reconnect(final long delay) {
method closeConnection (line 117) | @Override
method isConnected (line 124) | @Override
method afterConnected (line 129) | @Override
method handleException (line 136) | @Override
method handleTransportError (line 144) | @Override
method getPayloadType (line 151) | @Override
method sendMessage (line 156) | public void sendMessage(final String destination, final Object msg) {
method handleFrame (line 166) | @Override
method copyHeaders (line 191) | private Map<String, Object> copyHeaders(Map<String, String> original) {
method connectIfNecessary (line 200) | private void connectIfNecessary() {
method subscribe (line 206) | public void subscribe(String destination) throws Exception {
method unsubscribe (line 213) | public void unsubscribe(String destination) {
method isConnectedToUserAgent (line 221) | public boolean isConnectedToUserAgent() {
method disconnect (line 225) | public void disconnect() {
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ProxyWebSocketErrorHandler.java
type ProxyWebSocketErrorHandler (line 27) | public interface ProxyWebSocketErrorHandler extends ErrorHandler {
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ProxyWebSocketHandler.java
class ProxyWebSocketHandler (line 46) | public class ProxyWebSocketHandler extends WebSocketHandlerDecorator {
method ProxyWebSocketHandler (line 56) | public ProxyWebSocketHandler(WebSocketHandler delegate,
method errorHandler (line 70) | public void errorHandler(ErrorHandler errorHandler) {
method getWebSocketServerPath (line 74) | private String getWebSocketServerPath(ZuulWebSocketProperties.WsBroker...
method getWebSocketBrokarage (line 90) | private ZuulWebSocketProperties.WsBrokerage getWebSocketBrokarage(URI ...
method toPattern (line 111) | private String toPattern(String path) {
method afterConnectionClosed (line 116) | @Override
method handleMessage (line 123) | @Override
method handleMessageFromClient (line 130) | private void handleMessageFromClient(WebSocketSession session,
method connectToProxiedTarget (line 162) | private void connectToProxiedTarget(WebSocketSession session) {
method disconnectFromProxiedTarget (line 189) | private void disconnectFromProxiedTarget(WebSocketSession session) {
method disconnectProxyManager (line 193) | private void disconnectProxyManager(ProxyWebSocketConnectionManager pr...
method unsubscribeFromProxiedTarget (line 203) | private void unsubscribeFromProxiedTarget(WebSocketSession session,
method sendMessageToProxiedTarget (line 211) | private void sendMessageToProxiedTarget(WebSocketSession session,
method subscribeToProxiedTarget (line 217) | private void subscribeToProxiedTarget(WebSocketSession session,
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ReconnectErrorHandler.java
class ReconnectErrorHandler (line 13) | public class ReconnectErrorHandler implements ProxyWebSocketErrorHandler {
method ReconnectErrorHandler (line 19) | public ReconnectErrorHandler(ErrorAnalyzer errorAnalyzer) {
method handleError (line 23) | @Override
method shouldAttemptToReconnect (line 39) | private boolean shouldAttemptToReconnect(ProxySessionException proxyEx...
method isConnectionLost (line 49) | private boolean isConnectionLost(ProxySessionException proxyException) {
method executeReconnectThread (line 65) | private void executeReconnectThread(
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/WebSocketHttpHeadersCallback.java
type WebSocketHttpHeadersCallback (line 28) | public interface WebSocketHttpHeadersCallback {
method applyHeaders (line 29) | void applyHeaders(WebSocketSession userAgentSession, WebSocketHttpHead...
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/WebSocketMessageAccessor.java
class WebSocketMessageAccessor (line 29) | public final class WebSocketMessageAccessor {
method WebSocketMessageAccessor (line 32) | private WebSocketMessageAccessor() {
method create (line 35) | public static WebSocketMessageAccessor create(WebSocketMessage<?> mess...
method create (line 40) | public static WebSocketMessageAccessor create(String message) {
method getCommand (line 46) | public String getCommand() {
method accessible (line 53) | private boolean accessible() {
method getDestination (line 57) | public String getDestination() {
method getHeader (line 61) | public String getHeader(String header) {
method getPayload (line 78) | public String getPayload() {
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ZuulWebSocketConfiguration.java
class ZuulWebSocketConfiguration (line 79) | @Configuration
method registerStompEndpoints (line 104) | @Override
method configureMessageBroker (line 120) | @Override
method addStompEndpoint (line 136) | private SockJsServiceRegistration addStompEndpoint(StompEndpointRegist...
method mergeBrokersWithApplicationDestinationPrefixes (line 142) | private String[] mergeBrokersWithApplicationDestinationPrefixes(
method configureWebSocketTransport (line 155) | @Override
method compositeHeadersCallback (line 171) | @Bean
method basicAuthPrincipalHeadersCallback (line 177) | @Bean
method oauth2BearerPrincipalHeadersCallback (line 183) | @Bean
method loginCookieHeadersCallback (line 189) | @Bean
method urlProxyTargetResolver (line 194) | @Bean
method discoveryProxyTargetResolver (line 200) | @Bean
method loadBalancedProxyTargetResolver (line 206) | @Bean
method compositeProxyTargetResolver (line 212) | @Bean
method stompClient (line 218) | @Bean
method webSocketClient (line 232) | @Bean
method stompClientTaskScheduler (line 241) | @Bean
method reconnectErrorHandler (line 250) | @Bean
method compositeErrorHandler (line 255) | @Bean
method proxyRedirectFilter (line 261) | @Bean
method init (line 266) | @PostConstruct
method ignorePattern (line 272) | private void ignorePattern(String ignoredPattern) {
method onApplicationEvent (line 281) | @Override
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ZuulWebSocketProperties.java
class ZuulWebSocketProperties (line 31) | @ConfigurationProperties("zuul.ws")
method isEnabled (line 36) | public boolean isEnabled() {
method setEnabled (line 40) | public void setEnabled(boolean enabled) {
method getBrokerages (line 44) | public Map<String, WsBrokerage> getBrokerages() {
method setBrokerages (line 48) | public void setBrokerages(Map<String, WsBrokerage> brokerages) {
method init (line 52) | @PostConstruct
class WsBrokerage (line 62) | public static class WsBrokerage {
method isEnabled (line 70) | public boolean isEnabled() {
method setEnabled (line 74) | public void setEnabled(boolean enabled) {
method getId (line 78) | public String getId() {
method setId (line 82) | public void setId(String id) {
method getRouteId (line 86) | public String getRouteId() {
method setRouteId (line 90) | public void setRouteId(String routeId) {
method getEndPoints (line 94) | public String[] getEndPoints() {
method setEndPoints (line 98) | public void setEndPoints(String[] endPoints) {
method getBrokers (line 102) | public String[] getBrokers() {
method setBrokers (line 106) | public void setBrokers(String[] brokers) {
method getDestinationPrefixes (line 110) | public String[] getDestinationPrefixes() {
method setDestinationPrefixes (line 114) | public void setDestinationPrefixes(String[] destinationPrefixes) {
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/util/DefaultErrorAnalyzer.java
class DefaultErrorAnalyzer (line 9) | public class DefaultErrorAnalyzer implements ErrorAnalyzer {
method determineCauseChain (line 11) | @Override
method getFirstThrowableOfType (line 24) | @Override
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/util/ErrorAnalyzer.java
type ErrorAnalyzer (line 6) | public interface ErrorAnalyzer {
method determineCauseChain (line 7) | Throwable[] determineCauseChain(Throwable throwable);
method getFirstThrowableOfType (line 9) | Throwable getFirstThrowableOfType(Class<? extends Throwable> throwable...
FILE: src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/util/MapPropertyResolver.java
class MapPropertyResolver (line 10) | public class MapPropertyResolver extends AbstractPropertyResolver {
method MapPropertyResolver (line 14) | public MapPropertyResolver(Map<String, Object> map) {
method getPropertyAsRawString (line 18) | @Override
method getProperty (line 24) | @Override
FILE: src/test/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ProxyWebSocketConnectionManagerTests.java
class ProxyWebSocketConnectionManagerTests (line 39) | public class ProxyWebSocketConnectionManagerTests {
method init (line 53) | @Before
method sendStringMessageAsBytes (line 66) | @Test
method handlesExcpetionUsingErrorHandler (line 78) | @Test
method handlesTransportErrorUsingErrorHandler (line 89) | @Test
FILE: src/test/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/WebSocketMessageAccessorTests.java
class WebSocketMessageAccessorTests (line 28) | public class WebSocketMessageAccessorTests {
method connect (line 31) | @Test
method subscribe (line 39) | @Test
method send (line 48) | @Test
FILE: src/test/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ZuulWebSocketPropertiesTests.java
class ZuulWebSocketPropertiesTests (line 32) | public class ZuulWebSocketPropertiesTests {
method setUp (line 35) | @Before
method brokerageIdSet (line 40) | @Test
method brokerageIdNotSet (line 54) | @Test
Condensed preview — 34 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (138K chars).
[
{
"path": ".gitignore",
"chars": 245,
"preview": "target/\n*.log.gz\n*.iml\n.idea/\n*.log\n*.db\n/target\ntarget\n\n*.class\n\n# Mobile Tools for Java (J2ME)\n.mtj.tmp/\n\n# Package Fi"
},
{
"path": "LICENSE",
"chars": 11357,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 1375,
"preview": "# spring-cloud-netflix-zuul-websocket\nA simple library to enable Zuul reverse proxy web socket support in spring applica"
},
{
"path": "eclipse-code-formatter.xml",
"chars": 31267,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<profiles version=\"12\">\n<profile kind=\"CodeFormatterProfile\" name"
},
{
"path": "pom.xml",
"chars": 7525,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/authentication/AbstractHeadersCallback.java",
"chars": 1666,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/authentication/BasicAuthPrincipalHeadersCallback.java",
"chars": 2128,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/authentication/CompositeHeadersCallback.java",
"chars": 1728,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/authentication/LoginCookieHeadersCallback.java",
"chars": 1826,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/authentication/OAuth2BearerPrincipalHeadersCallback.java",
"chars": 2161,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/filter/ProxyRedirectFilter.java",
"chars": 3914,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/AbstractProxyTargetResolver.java",
"chars": 2866,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/CompositeProxyTargetResolver.java",
"chars": 1660,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/EurekaProxyTargetResolver.java",
"chars": 2366,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/LoadBalancedProxyTargetResolver.java",
"chars": 2180,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/ProxyTargetResolver.java",
"chars": 1010,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/proxytarget/UrlProxyTargetResolver.java",
"chars": 1800,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/CompositeErrorHandler.java",
"chars": 995,
"preview": "package com.github.mthizo247.cloud.netflix.zuul.web.socket;\n\nimport org.apache.commons.logging.Log;\nimport org.apache.co"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/EnableZuulWebSocket.java",
"chars": 1469,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ProxySessionException.java",
"chars": 1322,
"preview": "package com.github.mthizo247.cloud.netflix.zuul.web.socket;\n\nimport org.springframework.messaging.simp.stomp.StompSessio"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ProxyWebSocketConnectionManager.java",
"chars": 8050,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ProxyWebSocketErrorHandler.java",
"chars": 942,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ProxyWebSocketHandler.java",
"chars": 8985,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ReconnectErrorHandler.java",
"chars": 2511,
"preview": "package com.github.mthizo247.cloud.netflix.zuul.web.socket;\n\nimport com.github.mthizo247.cloud.netflix.zuul.web.util.Err"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/WebSocketHttpHeadersCallback.java",
"chars": 1070,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/WebSocketMessageAccessor.java",
"chars": 2267,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ZuulWebSocketConfiguration.java",
"chars": 12406,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ZuulWebSocketProperties.java",
"chars": 2758,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/util/DefaultErrorAnalyzer.java",
"chars": 979,
"preview": "package com.github.mthizo247.cloud.netflix.zuul.web.util;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\n/**\n * Cr"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/util/ErrorAnalyzer.java",
"chars": 299,
"preview": "package com.github.mthizo247.cloud.netflix.zuul.web.util;\n\n/**\n * Created by ronald22 on 13/02/2018.\n */\npublic interfac"
},
{
"path": "src/main/java/com/github/mthizo247/cloud/netflix/zuul/web/util/MapPropertyResolver.java",
"chars": 751,
"preview": "package com.github.mthizo247.cloud.netflix.zuul.web.util;\n\nimport org.springframework.core.env.AbstractPropertyResolver;"
},
{
"path": "src/test/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ProxyWebSocketConnectionManagerTests.java",
"chars": 3872,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/test/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/WebSocketMessageAccessorTests.java",
"chars": 1840,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
},
{
"path": "src/test/java/com/github/mthizo247/cloud/netflix/zuul/web/socket/ZuulWebSocketPropertiesTests.java",
"chars": 1897,
"preview": "/*\n * Copyright 2002-2017 the original author or authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lic"
}
]
About this extraction
This page contains the full source code of the mthizo247/spring-cloud-netflix-zuul-websocket GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 34 files (126.5 KB), approximately 29.0k tokens, and a symbol index with 175 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.