Skip to content

Commit

Permalink
Check if request is HTTPs before redirecting to TLS URL (apache#1454)
Browse files Browse the repository at this point in the history
* Check if request is HTTPs before redirecting to TLS URL

* Handled Matteo's PR Comments
  • Loading branch information
Jai Asher authored and merlimat committed Mar 27, 2018
1 parent 86b9546 commit 527731c
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriBuilder;

import org.apache.commons.lang3.StringUtils;
import org.apache.pulsar.broker.PulsarServerException;
import org.apache.pulsar.broker.ServiceConfiguration;
import org.apache.pulsar.broker.admin.AdminResource;
Expand Down Expand Up @@ -145,9 +146,9 @@ protected void internalDeleteNamespace(boolean authoritative) {
.orElseThrow(() -> new RestException(Status.NOT_FOUND,
"Cluster " + replCluster + " does not exist"));
URL replClusterUrl;
if (!config().isTlsEnabled()) {
if (!config().isTlsEnabled() || !isRequestHttps()) {
replClusterUrl = new URL(replClusterData.getServiceUrl());
} else if (!replClusterData.getServiceUrlTls().isEmpty()) {
} else if (StringUtils.isNotBlank(replClusterData.getServiceUrlTls())) {
replClusterUrl = new URL(replClusterData.getServiceUrlTls());
} else {
throw new RestException(Status.PRECONDITION_FAILED,
Expand Down Expand Up @@ -246,9 +247,9 @@ protected void internalDeleteNamespaceBundle(String bundleRange, boolean authori
.orElseThrow(() -> new RestException(Status.NOT_FOUND,
"Cluser " + replCluster + " does not exist"));
URL replClusterUrl;
if (!config().isTlsEnabled()) {
if (!config().isTlsEnabled() || !isRequestHttps()) {
replClusterUrl = new URL(replClusterData.getServiceUrl());
} else if (!replClusterData.getServiceUrlTls().isEmpty()) {
} else if (StringUtils.isNotBlank(replClusterData.getServiceUrlTls())) {
replClusterUrl = new URL(replClusterData.getServiceUrlTls());
} else {
throw new RestException(Status.PRECONDITION_FAILED,
Expand Down

0 comments on commit 527731c

Please sign in to comment.