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

Issue #163 #215

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
3f1c086
Updates for 2024 Release
gnongsie Aug 29, 2024
542b326
Removed build configurations for higher versions for SDK using jaxb
gnongsiej Aug 31, 2024
3b4a148
Upgrading dependencies to fix security vulnerabilities
gnongsie Sep 2, 2024
cf329ea
Merge branch 'future' of https://github.com/AuthorizeNet/sdk-java int…
gnongsie Sep 2, 2024
d6b7f85
Upgrading dependencies to fix security vulnerabilities
gnongsie Sep 2, 2024
b1ef536
Merge pull request #212 from AuthorizeNet/future
gnongsie Sep 18, 2024
a2cc5b9
[maven-release-plugin] prepare release anet-java-sdk-2.0.7
gnongsiej Sep 18, 2024
251f125
[maven-release-plugin] prepare for next development iteration
gnongsiej Sep 18, 2024
64b70ad
Merge branch 'master' of https://github.com/AuthorizeNet/sdk-java int…
gnongsie Sep 18, 2024
5fe5b87
Updated README file
gnongsie Sep 18, 2024
9d11480
Merge pull request #213 from AuthorizeNet/future-alternate
gnongsie Sep 18, 2024
dd8eb00
Update README.md
gnongsie Sep 18, 2024
11580db
[maven-release-plugin] prepare release anet-java-sdk-3.0.0
gnongsiej Sep 18, 2024
8b158b6
[maven-release-plugin] prepare for next development iteration
gnongsiej Sep 18, 2024
866bd82
Changed sample code branch to master
gnongsie Sep 19, 2024
c796604
sdk-java issue : "Environment not set. Set environment using setter o…
shalin-shaji Sep 23, 2024
5b2c0e5
sdk- java issue :"Defaulting to non-proxy environment" log warning #1…
shalin-shaji Sep 23, 2024
f8406aa
No changes in HttpClient.java
shalin-shaji Sep 23, 2024
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");
LogHelper.warn(logger, "Defaulting to non-proxy environment");

httpClient = HttpClientBuilder
.create()
Expand Down
Loading