Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

Commit

Permalink
Merge pull request #121 from blackrock-engineering/develop
Browse files Browse the repository at this point in the history
BlackRock changes
  • Loading branch information
blackrock-engineering authored Oct 16, 2018
2 parents 8b59ce7 + 5b2cd53 commit d91f16d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static interface UserCredsStep
public static interface BuildStep
{
BuildStep withReceiverEmail(String receiverEmail);
BuildStep withGetAllUsersTimeout(String getAllUsersTimeout);
BuildStep withServices(boolean enabled);
BuildStep withJMXHealthcheck(boolean enabled);
SymphonyClientConfig build();
Expand All @@ -105,6 +106,7 @@ private static class Steps
private String userCertFilename = null;
private char[] userCertPassword = null;
private String receiverEmail = null;
private String getAllUsersTimeout = null;
private boolean servicesEnabled = true;
private boolean jmxHealthCheckEnabled = true;

Expand Down Expand Up @@ -160,6 +162,13 @@ public BuildStep withReceiverEmail(String receiverEmail)
return (this);
}

@Override
public BuildStep withGetAllUsersTimeout(String getAllUsersTimeout)
{
this.getAllUsersTimeout = getAllUsersTimeout;
return (this);
}

@Override
public BuildStep withServices(boolean enabled)
{
Expand All @@ -179,16 +188,17 @@ public SymphonyClientConfig build()
{
SymphonyClientConfig result = new SymphonyClientConfig();

if (this.sessionAuthUrl != null) result.set(SymphonyClientConfigID.SESSIONAUTH_URL, this.sessionAuthUrl);
if (this.keyAuthUrl != null) result.set(SymphonyClientConfigID.KEYAUTH_URL, this.keyAuthUrl);
if (this.podUrl != null) result.set(SymphonyClientConfigID.POD_URL, this.podUrl);
if (this.agentUrl != null) result.set(SymphonyClientConfigID.AGENT_URL, this.agentUrl);
if (this.trustStoreFilename != null) result.set(SymphonyClientConfigID.TRUSTSTORE_FILE, this.trustStoreFilename);
if (this.trustStorePassword != null) result.set(SymphonyClientConfigID.TRUSTSTORE_PASSWORD, new String(this.trustStorePassword)); // SECURITY HOLE DUE TO STRING INTERNING
if (this.userEmail != null) result.set(SymphonyClientConfigID.USER_EMAIL, this.userEmail);
if (this.userCertFilename != null) result.set(SymphonyClientConfigID.USER_CERT_FILE, this.userCertFilename);
if (this.userCertPassword != null) result.set(SymphonyClientConfigID.USER_CERT_PASSWORD, new String(this.userCertPassword)); // SECURITY HOLE DUE TO STRING INTERNING
if (this.receiverEmail != null) result.set(SymphonyClientConfigID.RECEIVER_EMAIL, this.receiverEmail);
if (this.sessionAuthUrl != null) result.set(SymphonyClientConfigID.SESSIONAUTH_URL, this.sessionAuthUrl);
if (this.keyAuthUrl != null) result.set(SymphonyClientConfigID.KEYAUTH_URL, this.keyAuthUrl);
if (this.podUrl != null) result.set(SymphonyClientConfigID.POD_URL, this.podUrl);
if (this.agentUrl != null) result.set(SymphonyClientConfigID.AGENT_URL, this.agentUrl);
if (this.trustStoreFilename != null) result.set(SymphonyClientConfigID.TRUSTSTORE_FILE, this.trustStoreFilename);
if (this.trustStorePassword != null) result.set(SymphonyClientConfigID.TRUSTSTORE_PASSWORD, new String(this.trustStorePassword)); // SECURITY HOLE DUE TO STRING INTERNING
if (this.userEmail != null) result.set(SymphonyClientConfigID.USER_EMAIL, this.userEmail);
if (this.userCertFilename != null) result.set(SymphonyClientConfigID.USER_CERT_FILE, this.userCertFilename);
if (this.userCertPassword != null) result.set(SymphonyClientConfigID.USER_CERT_PASSWORD, new String(this.userCertPassword)); // SECURITY HOLE DUE TO STRING INTERNING
if (this.receiverEmail != null) result.set(SymphonyClientConfigID.RECEIVER_EMAIL, this.receiverEmail);
if (this.getAllUsersTimeout != null) result.set(SymphonyClientConfigID.GET_ALL_USERS_TIMEOUT, this.getAllUsersTimeout);

result.set(SymphonyClientConfigID.DISABLE_SERVICES, String.valueOf(!this.servicesEnabled));
result.set(SymphonyClientConfigID.HEALTHCHECK_JMX_ENABLED, String.valueOf(this.jmxHealthCheckEnabled));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public enum SymphonyClientConfigID {
USER_CERT_PASSWORD("javax.net.ssl.keyStorePassword"),
USER_EMAIL,
RECEIVER_EMAIL(false),
GET_ALL_USERS_TIMEOUT(false),
DISABLE_SERVICES(false),
HEALTHCHECK_JMX_ENABLED(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
package org.symphonyoss.symphony.clients.impl;

import com.google.common.base.Strings;

import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.symphonyoss.client.SymphonyClientConfig;
Expand Down Expand Up @@ -58,6 +60,7 @@
public class UsersClientImpl implements org.symphonyoss.symphony.clients.UsersClient {
private final SymAuth symAuth;
private final ApiClient apiClient;
private final long getAllUsersTimeout;

private final Logger logger = LoggerFactory.getLogger(UsersClientImpl.class);

Expand All @@ -68,10 +71,7 @@ public class UsersClientImpl implements org.symphonyoss.symphony.clients.UsersCl
* @param config Symphony Client config
*/
public UsersClientImpl(SymAuth symAuth, SymphonyClientConfig config) {

this(symAuth, config, null);


}

/**
Expand All @@ -93,7 +93,7 @@ public UsersClientImpl(SymAuth symAuth, SymphonyClientConfig config, Client http

apiClient.setBasePath(config.get(SymphonyClientConfigID.POD_URL));


getAllUsersTimeout = NumberUtils.toLong(config.get(SymphonyClientConfigID.GET_ALL_USERS_TIMEOUT), 5);
}


Expand Down Expand Up @@ -294,11 +294,12 @@ public Set<SymUser> getAllUsers() throws UsersClientException {
executor.shutdown();


executor.awaitTermination(5, TimeUnit.SECONDS);


logger.debug("Finished all threads. Total time retrieving users: {} sec", (System.currentTimeMillis() - startTime) / 1000);

final boolean processCompleted = executor.awaitTermination(getAllUsersTimeout, TimeUnit.SECONDS);
if (processCompleted) {
logger.debug("Finished all threads. Total time retrieving users: {} sec", (System.currentTimeMillis() - startTime) / 1000);
} else {
logger.warn("Process timed-out waiting to getAllUsers(). Total time retrieving users: {} sec", (System.currentTimeMillis() - startTime) / 1000);
}

} catch (ApiException e) {
throw new UsersClientException("API Error communicating with POD, while retrieving all user details",
Expand Down Expand Up @@ -334,11 +335,16 @@ public Set<SymUser> getAllUsersWithDetails() throws UsersClientException {
symUser.setFeatures(featureList);
userDetail = userApi.v1AdminUserUidGet(sessionToken, uid);
symUser.setRoles(new HashSet<>(userDetail.getRoles()));
if (userDetail.getUserSystemInfo().getLastLoginDate() != null)
symUser.setLastLoginDate(new Date(userDetail.getUserSystemInfo().getLastLoginDate()));

if (userDetail.getUserSystemInfo().getCreatedDate() != null)
symUser.setCreatedDate(new Date(userDetail.getUserSystemInfo().getCreatedDate()));
if (userDetail.getUserSystemInfo() != null) {
symUser.setActive(UserSystemInfo.StatusEnum.ENABLED == userDetail.getUserSystemInfo().getStatus());
if (userDetail.getUserSystemInfo().getLastLoginDate() != null) {
symUser.setLastLoginDate(new Date(userDetail.getUserSystemInfo().getLastLoginDate()));
}
if (userDetail.getUserSystemInfo().getCreatedDate() != null) {
symUser.setCreatedDate(new Date(userDetail.getUserSystemInfo().getCreatedDate()));
}
}

}
} catch (ApiException e) {
Expand Down

0 comments on commit d91f16d

Please sign in to comment.