Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,13 @@ ServerCnxnFactory getSecureCnxnFactory() {
return secureCnxnFactory;
}

// VisibleForTesting
public int getClientPort() {
if (cnxnFactory != null) {
return cnxnFactory.getLocalPort();
}
return 0;
}

// VisibleForTesting
public int getSecureClientPort() {
if (secureCnxnFactory != null) {
return secureCnxnFactory.getLocalPort();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* See the "Pluggable ZooKeeper authentication" section of the
* "Zookeeper Programmer's Guide" for general details of implementing an
* authentication plugin. e.g.
* http://zookeeper.apache.org/doc/trunk/zookeeperProgrammers.html#sc_ZooKeeperPluggableAuthentication
* http://zookeeper.apache.org/doc/current/zookeeperProgrammers.html#sc_ZooKeeperPluggableAuthentication
*
* This class looks for a numeric "key" under the /key node.
* Authorization is granted if the user passes in as authorization a number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public X509AuthenticationProvider() throws X509Exception {
boolean crlEnabled = config.getBoolean(x509Util.getSslCrlEnabledProperty(), Boolean.getBoolean("com.sun.net.ssl.checkRevocation"));
boolean ocspEnabled = config.getBoolean(x509Util.getSslOcspEnabledProperty(), Boolean.parseBoolean(Security.getProperty("ocsp.enable")));
boolean hostnameVerificationEnabled = Boolean.parseBoolean(config.getProperty(x509Util.getSslHostnameVerificationEnabledProperty()));
boolean clientHostnameVerificationEnabled = x509Util.isClientHostnameVerificationEnabled(config);

X509KeyManager km = null;
X509TrustManager tm = null;
Expand Down Expand Up @@ -120,7 +121,7 @@ public X509AuthenticationProvider() throws X509Exception {
crlEnabled,
ocspEnabled,
hostnameVerificationEnabled,
false,
clientHostnameVerificationEnabled,
fipsMode);
} catch (TrustManagerException e) {
LOG.error("Failed to create trust manager", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ static ZookKeeperServerEmbeddedBuilder builder() {
*/
void start(long startupTimeout) throws Exception;

/**
* Get client port for no secure connection.
*/
int getClientPort();

/**
* Get client port for secure connection.
*/
int getSecureClientPort();

/**
* Get a connection string useful for the client.
* @return the connection string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ protected QuorumPeer getQuorumPeer() throws SaslException {
@Override
public void start() {
super.start();
boundClientPort = getClientPort();
boundSecureClientPort = getSecureClientPort();
boundClientPort = super.getClientPort();
boundSecureClientPort = super.getSecureClientPort();
LOG.info("ZK Server {} started", this);
started.complete(null);
}
Expand Down Expand Up @@ -148,8 +148,8 @@ public void run() {
@Override
public void serverStarted() {
LOG.info("ZK Server started");
boundClientPort = getClientPort();
boundSecureClientPort = getSecureClientPort();
boundClientPort = super.getClientPort();
boundSecureClientPort = super.getSecureClientPort();
started.complete(null);
}
};
Expand Down Expand Up @@ -190,6 +190,16 @@ public void run() {
}
}

@Override
public int getClientPort() {
return boundClientPort;
}

@Override
public int getSecureClientPort() {
return boundSecureClientPort;
}

@Override
public String getConnectionString() {
return prettifyConnectionString(config.getClientPortAddress(), boundClientPort);
Expand Down
Loading