Skip to content
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

sdk- java issues #172 and #163 #216

Open
wants to merge 17 commits into
base: future-tcs
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion .github/workflows/java-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: 'authorizenet/sample-code-java'
ref: 'future-alternate'
ref: 'master'
path: ${{env.sample_code_java}}
- name: Setup Java 17 to build the SDK
uses: actions/setup-java@v2
Expand Down
88 changes: 49 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,49 @@
# Authorize.Net Java SDK

[![Travis CI Status](https://travis-ci.org/AuthorizeNet/sdk-java.svg?branch=master)](https://travis-ci.org/AuthorizeNet/sdk-java)
[![Code Climate](https://codeclimate.com/github/AuthorizeNet/sdk-java/badges/gpa.svg)](https://codeclimate.com/github/AuthorizeNet/sdk-java)
[![Authorize.net Java CI](https://github.com/AuthorizeNet/sdk-java/actions/workflows/java-workflow.yml/badge.svg?branch=master)](https://github.com/AuthorizeNet/sdk-java/actions/workflows/java-workflow.yml)
[![Maven Central](https://img.shields.io/maven-central/v/net.authorize/anet-java-sdk.svg?style=flat)](http://mvnrepository.com/artifact/net.authorize/anet-java-sdk)


## IMPORTANT NOTE

### Support for Java 1.8

**A new version that supports Java 1.8 is `v2.0.7`. This is the _LAST_ release with support for Java 1.8.**

### Support for Java 9 and higher

**A new version of the SDK has been released that supports Java 9 and higher. This new version is `v3.0.0`.**

## Requirements
* JDK 1.5.0 to JDK 1.8.0
* JDK 9 and higher
* Ant 1.6.2 or higher (build SDK only)
* Maven 2.2.0 or higher (build SDK only)
* An Authorize.Net account (see _Registration & Configuration_ section below)

_Note 1: Support for building the SDK with either Ant or Maven has been made. Please see the respective build processes below. All initial jars and docs were built with Ant, however._

_Note 2: Support for higher versions of JDK (>= 1.9.0) has not been made available._

### Dependencies
* commons-logging-1.1.1.jar : logging
* log4j-2.17.1.jar : logging
* httpclient-4.0.1.jar : http communication with the payment gateway
* httpcore-4.0.1.jar : http communication with the payment gateway
* junit-4.8.2.jar : unit testing
* hamcrest-core-1.3.jar : unit testing
* hamcrest-library-1.3.jar : unit testing
* jmock-2.6.0.jar : unit testing
* commons-logging-1.3.3
* log4j-2.23.1
* log4j-jcl-2.23.1
* log4j-api-2.23.1
* log4j-core-2.23.1
* log4j-1.2-api-2.23.1
* httpclient5-5.3.1
* httpcore5-5.2.5
* gson-2.11.0
* jakarta.xml.bind-api-4.0.2
* jaxb-runtime-4.0.5
* jackson-module-jakarta-xmlbind-annotations-2.17.2
* junit-4.13.1
* hamcrest-core-1.3
* hamcrest-library-1.3
* jmock-2.6.0

### Migrating from older versions
Since August 2018, the Authorize.Net API has been reorganized to be more merchant focused. Authorize.Net AIM, ARB, CIM, Transaction Reporting, and SIM classes have been deprecated in favor of `net\authorize\api`. To see the full list of mapping of new features corresponding to the deprecated features, see [MIGRATING.md](MIGRATING.md).
Since August 2018, the Authorize.Net API has been reorganized to be more merchant focused. Authorize.Net AIM, ARB, CIM, Transaction Reporting, and SIM classes have been deprecated in favor of `net\authorize\api`. To see the full list of mapping of new features corresponding to the deprecated features, see [MIGRATING.md](MIGRATING.md).

### Contribution
- If you need information or clarification about Authorize.Net features, create an issue with your question. You can also search the [Authorize.Net developer community](https://community.developer.authorize.net/) for discussions related to your question.
- If you need information or clarification about Authorize.Net features, create an issue with your question. You can also search the [Authorize.Net developer community](https://community.developer.authorize.net/) for discussions related to your question.
- Before creating pull requests, read [the contributors guide](CONTRIBUTING.md).

### TLS 1.2
Expand Down Expand Up @@ -68,7 +83,7 @@ Authorize.Net maintains a complete sandbox environment for testing and developme
ApiOperationBase.setEnvironment(Environment.PRODUCTION);
```

API credentials are different for each environment, so be sure to switch to the appropriate credentials when switching environments.
API credentials are different for each environment, so be sure to switch to the appropriate credentials when switching environments.

## SDK Usage Examples and Sample Code
When using this SDK, downloading the Authorize.Net sample code repository is recommended.
Expand Down Expand Up @@ -127,27 +142,22 @@ To create the javadocs:
### Testing Guide
For additional help in testing your own code, Authorize.Net maintains a [comprehensive testing guide](http://developer.authorize.net/hello_world/testing_guide/) that includes test credit card numbers to use and special triggers to generate certain responses from the sandbox environment.

## Logging Sensitive Data

The Authorize.Net Java SDK uses Log4J framework for logging purposes. Enable the logger by keeping a configuration file `Log4j.properties` in the resources folder of the application. A sample [Log4.properties](https://github.com/AuthorizeNet/sdk-java/blob/master/resources/log4j.properties) file has been provided as a reference.

The possible log levels are `DEBUG, INFO, WARN, ERROR` and `FATAL`. There is a new pattern layout introduced to mask sensitive data while logging and can be used with the application by providing the following configurations in the `Log4j.properties` file:

```
// Default configuration which logs the entries in clear text

log4j.appender.S.layout = org.apache.log4j.PatternLayout
log4j.appender.R.layout = org.apache.log4j.PatternLayout

// Configuration which masks the sensitive data in the log entries

log4j.appender.S.layout = net.authorize.util.SensitiveFilterLayout
log4j.appender.R.layout = net.authorize.util.SensitiveFilterLayout

```

By default the logger comes with two appenders, **console** and **file transport**.

## Logging Sensitive Data

The Authorize.Net Java SDK uses Log4J2 framework for logging purposes. Enable the logger by keeping a configuration file `log4j2.xml` in the resources folder of the application. A sample [log4j2.xml](https://github.com/AuthorizeNet/sdk-java/blob/master/resources/log4j2.xml) file has been provided as a reference.

The possible log levels are `DEBUG, INFO, WARN, ERROR` and `FATAL`. There is a new pattern layout introduced to mask sensitive data while logging and can be used with the application by making the following configurations in the `log4j2.xml` file:

1. Create your own appender under `<Appenders></Appenders>` and insert the `<PatternLayout><pattern></pattern></PatternLayout>` section. (Example is present in the `log4j2.xml` file)
* To enable masking of sensitive data, replace `%m` with `%maskedMessage`.
* To disable masking, replace `%maskedMessage` with `%m`.
2. Create a logger under `<Loggers></Loggers>`
3. The `name` field in the `<Logger>` should contain the namespace from where log messages needs to be written to file.
4. Attach an `<AppenderRef>` section where the `ref` field uses one of the Appenders that have been created under the `<Appenders>` section.
5. Do **NOT** modify the logger with `<Root>`.

By default the logger comes with two appenders, **LogToConsole** and **RollingFile**.

The sensitive fields that are masked during logging are:
* Card Number
* Card Code
Expand All @@ -156,7 +166,7 @@ The sensitive fields that are masked during logging are:
* Account Number
* Name on Account

There is also a list of regular expressions which the sensitive logger uses to mask credit card numbers while logging.
There is also a list of regular expressions which the sensitive logger uses to mask credit card numbers while logging.

More information on the regular expressions used during sensitive data logging [can be found here](https://github.com/AuthorizeNet/sdk-java/blob/master/resources/AuthorizedNetSensitiveTagsConfig.json).

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<groupId>net.authorize</groupId>
<artifactId>anet-java-sdk</artifactId>
<packaging>jar</packaging>
<version>2.0.7-SNAPSHOT</version>
<version>3.0.1-SNAPSHOT</version>
<name>Authorize.Net Java SDK</name>
<description>Authorize.Net SDK includes standard payments, recurring billing, and customer profiles.</description>
<url>http://developer.authorize.net</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,11 @@ public S executeWithApiResponse(Environment environment) {
return this.getApiResponse();
}

final String nullEnvironmentErrorMessage = "Environment not set. Set environment using setter or use overloaded method to pass appropriate environment";

public void execute() {
if ( null == ApiOperationBase.getEnvironment())
{
throw new InvalidParameterException(nullEnvironmentErrorMessage);
throw new InvalidParameterException(Constants.NULL_ENVIRONMENT_ERROR_MESSAGE);
}
else
{
Expand All @@ -139,7 +138,7 @@ public void execute(Environment environment) {

logger.debug(String.format("Executing Request:'%s'", this.getApiRequest()));

if ( null == environment) throw new InvalidParameterException(nullEnvironmentErrorMessage);
if ( null == environment) throw new InvalidParameterException(Constants.NULL_ENVIRONMENT_ERROR_MESSAGE);

ANetApiResponse httpApiResponse = HttpUtility.postData(environment, this.getApiRequest(), this.responseClass);
if ( null != httpApiResponse)
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/authorize/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ public final class Constants {
public static final int HTTP_READ_TIME_OUT_DEFAULT_VALUE = 30000;

public static final String CLIENT_ID = "sdk-java-2.0.3";
public static final String NULL_ENVIRONMENT_ERROR_MESSAGE = "Environment not set. Set environment using setter or use overloaded method to pass appropriate environment";
}
2 changes: 1 addition & 1 deletion src/main/java/net/authorize/util/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static CloseableHttpClient getHttpsClient() throws Exception {

proxySet = true;
} else {
LogHelper.warn(logger, "Defaulting to non-proxy environment");
if( UseProxy ) { LogHelper.warn(logger, "Defaulting to non-proxy environment");}

httpClient = HttpClientBuilder
.create()
Expand Down
Loading