-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add opt-in to enable server hostname verification
Hostname verification isn't performed by default in the TLS handshake, this commit makes it easier to enable server hostname verification for both blocking and non-blocking IO modes. References #394
- Loading branch information
1 parent
149b6c7
commit fcc3dbb
Showing
15 changed files
with
610 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
src/main/java/com/rabbitmq/client/SocketChannelConfigurators.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
// Copyright (c) 2018 Pivotal Software, Inc. All rights reserved. | ||
// | ||
// This software, the RabbitMQ Java client library, is triple-licensed under the | ||
// Mozilla Public License 1.1 ("MPL"), the GNU General Public License version 2 | ||
// ("GPL") and the Apache License version 2 ("ASL"). For the MPL, please see | ||
// LICENSE-MPL-RabbitMQ. For the GPL, please see LICENSE-GPL2. For the ASL, | ||
// please see LICENSE-APACHE2. | ||
// | ||
// This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, | ||
// either express or implied. See the LICENSE file for specific language governing | ||
// rights and limitations of this software. | ||
// | ||
// If you have any questions regarding licensing, please contact us at | ||
// [email protected]. | ||
|
||
package com.rabbitmq.client; | ||
|
||
/** | ||
* Ready-to-use instances and builder for {@link SocketChannelConfigurator}. | ||
* <p> | ||
* Note {@link SocketChannelConfigurator}s can be combined with | ||
* {@link SocketChannelConfigurator#andThen(SocketChannelConfigurator)}. | ||
* | ||
* @since 5.5.0 | ||
*/ | ||
public abstract class SocketChannelConfigurators { | ||
|
||
/** | ||
* Disable Nagle's algorithm. | ||
*/ | ||
public static final SocketChannelConfigurator DISABLE_NAGLE_ALGORITHM = | ||
socketChannel -> SocketConfigurators.DISABLE_NAGLE_ALGORITHM.configure(socketChannel.socket()); | ||
|
||
/** | ||
* Default {@link SocketChannelConfigurator} that disables Nagle's algorithm. | ||
*/ | ||
public static final SocketChannelConfigurator DEFAULT = DISABLE_NAGLE_ALGORITHM; | ||
|
||
/** | ||
* The default {@link SocketChannelConfigurator} that disables Nagle's algorithm. | ||
* | ||
* @return | ||
*/ | ||
public static SocketChannelConfigurator defaultConfigurator() { | ||
return DEFAULT; | ||
} | ||
|
||
/** | ||
* {@link SocketChannelConfigurator} that disables Nagle's algorithm. | ||
* | ||
* @return | ||
*/ | ||
public static SocketChannelConfigurator disableNagleAlgorithm() { | ||
return DISABLE_NAGLE_ALGORITHM; | ||
} | ||
|
||
/** | ||
* Builder to configure and creates a {@link SocketChannelConfigurator} instance. | ||
* | ||
* @return | ||
*/ | ||
public static SocketChannelConfigurators.Builder builder() { | ||
return new SocketChannelConfigurators.Builder(); | ||
} | ||
|
||
public static class Builder { | ||
|
||
private SocketChannelConfigurator configurator = channel -> { | ||
}; | ||
|
||
/** | ||
* Set default configuration. | ||
* | ||
* @return | ||
*/ | ||
public Builder defaultConfigurator() { | ||
configurator = configurator.andThen(DEFAULT); | ||
return this; | ||
} | ||
|
||
/** | ||
* Disable Nagle's Algorithm. | ||
* | ||
* @return | ||
*/ | ||
public Builder disableNagleAlgorithm() { | ||
configurator = configurator.andThen(DISABLE_NAGLE_ALGORITHM); | ||
return this; | ||
} | ||
|
||
/** | ||
* Add an extra configuration step. | ||
* | ||
* @param extraConfiguration | ||
* @return | ||
*/ | ||
public Builder add(SocketChannelConfigurator extraConfiguration) { | ||
configurator = configurator.andThen(extraConfiguration); | ||
return this; | ||
} | ||
|
||
/** | ||
* Return the configured {@link SocketConfigurator}. | ||
* | ||
* @return | ||
*/ | ||
public SocketChannelConfigurator build() { | ||
return configurator; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.