Skip to content

Commit

Permalink
Remove google analytics system property for secure hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
tharikaGitHub committed Jul 8, 2024
1 parent f858a2b commit 3a6c76c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ public class APIMgtGatewayConstants {
public static final String VALIDATED_X509_CERT = "ValidatedX509Cert";
public static final String RESOURCE_SPAN = "API:Resource";

public static final String GOOGLE_ANALYTICS_SECURE_HASHING = "googleAnalyticsSecureHashingEnabled";

/**
* Web-sub related properties
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ public class APIMgtGoogleAnalyticsTrackingHandler extends AbstractHandler {

protected GoogleAnalyticsConfig config = null;

private static final String googleAnalyticsSecureHashingEnabled = System.getProperty(APIMgtGatewayConstants
.GOOGLE_ANALYTICS_SECURE_HASHING);

@MethodStats
@Override
public boolean handleRequest(MessageContext msgCtx) {
Expand Down Expand Up @@ -349,11 +346,7 @@ private static String getVisitorId(String account, String userAgent, MessageCont
message = ANONYMOUS_USER_ID;
}

String hashingAlgorithm = "MD5";
if (JavaUtils.isTrueExplicitly(googleAnalyticsSecureHashingEnabled)) {
hashingAlgorithm = "SHA-256";
}
MessageDigest m = MessageDigest.getInstance(hashingAlgorithm);
MessageDigest m = MessageDigest.getInstance("SHA-256");
m.update(message.getBytes("UTF-8"), 0, message.length());
byte[] sum = m.digest();
BigInteger messageAsNumber = new BigInteger(1, sum);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ public class APIMgtGoogleAnalyticsUtils {
private static final Log log = LogFactory.getLog(APIMgtGoogleAnalyticsUtils.class);
private static final String ANONYMOUS_USER_ID = "anonymous";
private static final String GOOGLE_ANALYTICS_TRACKER_VERSION = "1";
private static final String googleAnalyticsSecureHashingEnabled = System.getProperty(APIMgtGatewayConstants
.GOOGLE_ANALYTICS_SECURE_HASHING);
private String configKey = null;
private GoogleAnalyticsConfig gaConfig = null;

Expand Down Expand Up @@ -136,11 +134,7 @@ private String getVisitorId(String authHeader) throws NoSuchAlgorithmException,
message = ANONYMOUS_USER_ID;
}

String hashingAlgorithm = "MD5";
if (JavaUtils.isTrueExplicitly(googleAnalyticsSecureHashingEnabled)) {
hashingAlgorithm = "SHA-256";
}
MessageDigest m = MessageDigest.getInstance(hashingAlgorithm);
MessageDigest m = MessageDigest.getInstance("SHA-256");
m.update(message.getBytes("UTF-8"), 0, message.length());
byte[] sum = m.digest();
BigInteger messageAsNumber = new BigInteger(1, sum);
Expand Down

0 comments on commit 3a6c76c

Please sign in to comment.