Skip to content

support separate logger for sensitive information #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
10 changes: 7 additions & 3 deletions src/main/java/net/authorize/util/HttpUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
*/
public final class HttpUtility {

private static Log logger = LogFactory.getLog(HttpUtility.class);
private static class Sensitive {}

private static Log loggerSensitive = LogFactory.getLog(Sensitive.class);

private static Log logger = LogFactory.getLog(HttpUtility.class);

static int httpConnectionTimeout = Environment.getIntProperty(Constants.HTTP_CONNECTION_TIME_OUT);
static int httpReadTimeout = Environment.getIntProperty(Constants.HTTP_READ_TIME_OUT);
Expand Down Expand Up @@ -68,7 +72,7 @@ static HttpPost createPostRequest(Environment env, ANetApiRequest request) throw

if(null != request) {
postUrl = new URI(env.getXmlBaseUrl() + "/xml/v1/request.api");
logger.debug(String.format("MerchantInfo->LoginId/TransactionKey: '%s':'%s'", request.getMerchantAuthentication().getName(), request.getMerchantAuthentication().getTransactionKey() ));
loggerSensitive.debug(String.format("MerchantInfo->LoginId/TransactionKey: '%s':'%s'", request.getMerchantAuthentication().getName(), request.getMerchantAuthentication().getTransactionKey() ));
logger.debug(String.format("Posting request to Url: '%s'", postUrl));
httpPost = new HttpPost(postUrl);
httpPost.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
Expand All @@ -81,7 +85,7 @@ static HttpPost createPostRequest(Environment env, ANetApiRequest request) throw
httpPost.setHeader("Content-Type", "text/xml; charset=utf-8");

String xmlRequest = XmlUtility.getXml(request);
logger.debug(String.format("Request: '%s%s%s'", LogHelper.LineSeparator, xmlRequest, LogHelper.LineSeparator));
loggerSensitive.debug(String.format("Request: '%s%s%s'", LogHelper.LineSeparator, xmlRequest, LogHelper.LineSeparator));
httpPost.setEntity(new StringEntity(xmlRequest, HTTP.UTF_8));
}

Expand Down