Skip to content

Commit b87ff5d

Browse files
Deprecated code removal
1 parent fca1f93 commit b87ff5d

File tree

3 files changed

+2
-274
lines changed

3 files changed

+2
-274
lines changed

src/main/java/net/authorize/util/HttpClient.java

Lines changed: 2 additions & 217 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,28 @@
44
import java.io.IOException;
55
import java.io.InputStream;
66
import java.io.InputStreamReader;
7-
import java.io.UnsupportedEncodingException;
8-
import java.net.URI;
9-
import java.net.URLDecoder;
107
import java.security.KeyStore;
11-
import java.util.Arrays;
12-
import java.util.HashMap;
13-
import java.util.Map;
148

159
import javax.net.ssl.SSLContext;
1610
import javax.net.ssl.TrustManagerFactory;
1711

1812
import org.apache.commons.logging.Log;
1913
import org.apache.commons.logging.LogFactory;
20-
import org.apache.http.HttpEntity;
2114
import org.apache.http.HttpHost;
22-
import org.apache.http.HttpResponse;
2315
import org.apache.http.auth.AuthScope;
2416
import org.apache.http.auth.Credentials;
2517
import org.apache.http.auth.UsernamePasswordCredentials;
2618
import org.apache.http.client.CredentialsProvider;
2719
import org.apache.http.client.config.RequestConfig;
28-
import org.apache.http.client.methods.HttpPost;
29-
import org.apache.http.conn.params.ConnRoutePNames;
3020
import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
3121
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
32-
import org.apache.http.entity.StringEntity;
3322
import org.apache.http.impl.client.BasicCredentialsProvider;
3423
import org.apache.http.impl.client.CloseableHttpClient;
35-
import org.apache.http.impl.client.DefaultHttpClient;
3624
import org.apache.http.impl.client.HttpClientBuilder;
3725
import org.apache.http.impl.client.HttpClients;
3826
import org.apache.http.impl.client.LaxRedirectStrategy;
39-
import org.apache.http.impl.conn.DefaultProxyRoutePlanner;
40-
import org.apache.http.params.CoreProtocolPNames;
41-
import org.apache.http.params.HttpConnectionParams;
42-
import org.apache.http.protocol.HTTP;
4327

4428
import net.authorize.Environment;
45-
import net.authorize.ResponseField;
46-
import net.authorize.Transaction;
4729

4830
/**
4931
* Transportation object used to facilitate the communication with the
@@ -73,141 +55,8 @@ public class HttpClient {
7355
httpReadTimeout = (httpReadTimeout == 0 ? Constants.HTTP_READ_TIME_OUT_DEFAULT_VALUE : httpReadTimeout);
7456
}
7557

76-
/**
77-
* Creates the http post object for an environment and transaction container.
78-
*
79-
* @param env
80-
* @param transaction
81-
* @return HttpPost object
82-
*
83-
* @throws Exception
84-
*/
85-
@Deprecated
86-
private static HttpPost createHttpPost(Environment env, Transaction transaction) throws Exception {
87-
URI postUrl;
88-
HttpPost httpPost = null;
89-
90-
/*
91-
* if(transaction instanceof net.authorize.aim.Transaction || transaction
92-
* instanceof net.authorize.sim.Transaction) {
93-
*
94-
* if(transaction instanceof net.authorize.aim.Transaction &&
95-
* ((net.authorize.aim.Transaction)transaction).isCardPresent()) {
96-
*/
97-
98-
postUrl = new URI(env.getCardPresentUrl() + "/gateway/transact.dll");
99-
/* } else { */
100-
postUrl = new URI(env.getBaseUrl() + "/gateway/transact.dll");
101-
/* } */
102-
103-
httpPost = new HttpPost(postUrl);
104-
105-
httpPost.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
106-
107-
// set the tcp connection timeout
108-
httpPost.getParams().setIntParameter(HttpConnectionParams.CONNECTION_TIMEOUT, httpConnectionTimeout);
109-
// set the time out on read-data request
110-
httpPost.getParams().setIntParameter(HttpConnectionParams.SO_TIMEOUT, httpReadTimeout);
111-
112-
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
113-
httpPost.setEntity(new StringEntity(transaction.toNVPString(), HTTP.UTF_8));
114-
/*
115-
* } else if (transaction instanceof net.authorize.arb.Transaction ||
116-
* transaction instanceof net.authorize.cim.Transaction || transaction
117-
* instanceof net.authorize.reporting.Transaction) {
118-
*/
119-
120-
postUrl = new URI(env.getXmlBaseUrl() + "/xml/v1/request.api");
121-
httpPost = new HttpPost(postUrl);
122-
httpPost.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
123-
124-
// set the TCP connection timeout
125-
httpPost.getParams().setIntParameter(HttpConnectionParams.CONNECTION_TIMEOUT, httpConnectionTimeout);
126-
// set the time out on read-data request
127-
httpPost.getParams().setIntParameter(HttpConnectionParams.SO_TIMEOUT, httpReadTimeout);
128-
129-
httpPost.setHeader("Content-Type", "text/xml; charset=utf-8");
130-
httpPost.setEntity(new StringEntity(transaction.toXMLString(), HTTP.UTF_8));
131-
/* } */
13258

133-
return httpPost;
134-
}
135-
136-
/**
137-
* Creates a response map for a given response string and transaction container.
138-
*
139-
* @param transaction
140-
* @param responseString
141-
* @return container map containing semi-processed data after request was posted
142-
* @throws UnsupportedEncodingException
143-
*/
144-
/* @Deprecated */
145-
/*
146-
* private static Map<ResponseField, String> createResponseMap(Transaction
147-
* transaction, String responseString) throws UnsupportedEncodingException {
148-
*
149-
* Map<ResponseField, String> responseMap = null;
150-
*
151-
* // aim/sim if(transaction instanceof net.authorize.aim.Transaction ||
152-
* transaction instanceof net.authorize.sim.Transaction) {
153-
*
154-
* String decodedResponseData = URLDecoder.decode(responseString, HTTP.UTF_8);
155-
*
156-
*
157-
* responseMap = ResponseParser.parseResponseString(decodedResponseData); }
158-
*
159-
* return responseMap; }
160-
*/
161-
162-
/**
163-
* Executes a Transaction against a given Environment.
164-
*
165-
* @param environment
166-
* @param transaction
167-
* @return container map containing semi-processed data after request was posted
168-
*/
169-
/* @Deprecated */
170-
/*
171-
* public static Map<ResponseField, String> execute(Environment environment,
172-
* Transaction transaction) { Map<ResponseField, String> responseMap = new
173-
* HashMap<ResponseField, String>();
174-
*
175-
* if(environment != null && transaction != null) { try { CloseableHttpClient
176-
* httpClient = getHttpsClient();
177-
*
178-
* // create the HTTP POST object HttpPost httpPost =
179-
* createHttpPost(environment, transaction);
180-
*
181-
* // execute the request HttpResponse httpResponse =
182-
* httpClient.execute(httpPost); String rawResponseString; if(httpResponse !=
183-
* null && httpResponse.getStatusLine().getStatusCode() == 200) { HttpEntity
184-
* entity = httpResponse.getEntity();
185-
*
186-
* // get the raw data being received InputStream instream =
187-
* entity.getContent(); rawResponseString = convertStreamToString(instream); }
188-
* // handle HTTP errors else { StringBuilder responseBuilder = new
189-
* StringBuilder();
190-
* responseBuilder.append(3).append(net.authorize.aim.Transaction.
191-
* TRANSACTION_FIELD_DELIMITER);
192-
* responseBuilder.append(3).append(net.authorize.aim.Transaction.
193-
* TRANSACTION_FIELD_DELIMITER);
194-
* responseBuilder.append(22).append(net.authorize.aim.Transaction.
195-
* TRANSACTION_FIELD_DELIMITER); responseBuilder.append(httpResponse != null ?
196-
* httpResponse.getStatusLine().getReasonPhrase() : " "); rawResponseString =
197-
* responseBuilder.toString(); }
198-
*
199-
* httpClient.getConnectionManager().shutdown();
200-
*
201-
* String cleanResponseString =
202-
* XmlUtility.descapeStringForXml(rawResponseString);
203-
*
204-
* responseMap = HttpClient.createResponseMap(transaction, cleanResponseString);
205-
* } catch (Exception e) { LogHelper.warn(logger,
206-
* "Exception getting response: '%s': '%s', '%s'", e.getMessage(), e.getCause(),
207-
* Arrays.toString(e.getStackTrace())); } }
208-
*
209-
* return responseMap; }
210-
*/
59+
21160

21261
/**
21362
* Converts a response inputstream into a string.
@@ -247,71 +96,7 @@ public static String convertStreamToString(InputStream is) {
24796
return sb.toString();
24897
}
24998

250-
/**
251-
* Executes a Transaction against a given Environment.
252-
*
253-
* @param environment
254-
* @param transaction
255-
* @return BasicXmlDocument containing semi-processed data after request was
256-
* posted
257-
*/
258-
/*
259-
* @Deprecated public static BasicXmlDocument executeXML(Environment
260-
* environment, Transaction transaction) { BasicXmlDocument response = new
261-
* BasicXmlDocument();
262-
*
263-
* if(environment != null && transaction != null) { try { CloseableHttpClient
264-
* httpClient = getHttpsClient();
265-
*
266-
* // create the HTTP POST object HttpPost httpPost =
267-
* createHttpPost(environment, transaction);
268-
*
269-
* // execute the request HttpResponse httpResponse =
270-
* httpClient.execute(httpPost); String rawResponseString; if(httpResponse !=
271-
* null && httpResponse.getStatusLine().getStatusCode() == 200) { HttpEntity
272-
* entity = httpResponse.getEntity();
273-
*
274-
* // get the raw data being received InputStream instream =
275-
* entity.getContent(); rawResponseString = convertStreamToString(instream); }
276-
* else { StringBuilder responseBuilder = new StringBuilder(); if(transaction
277-
* instanceof net.authorize.arb.Transaction || transaction instanceof
278-
* net.authorize.cim.Transaction || transaction instanceof
279-
* net.authorize.reporting.Transaction) {
280-
*
281-
* responseBuilder.append("<?xml version=\"1.0\" ?>");
282-
* responseBuilder.append("<messages><resultCode>Error</resultCode>");
283-
* responseBuilder.append("<message><code>E00001</code>");
284-
* responseBuilder.append("<text>"); responseBuilder.append(httpResponse !=
285-
* null?httpResponse.getStatusLine().getReasonPhrase():"");
286-
* responseBuilder.append("</text></message></messages>"); } else {
287-
* responseBuilder.append("<?xml version=\"1.0\" ?>");
288-
* responseBuilder.append("<response>");
289-
* responseBuilder.append("<ResponseCode>3</ResponseCode>");
290-
* responseBuilder.append(
291-
* "<Errors><Error><ErrorCode>22</ErrorCode><ErrorText><![CDATA[");
292-
* responseBuilder.append(httpResponse !=
293-
* null?httpResponse.getStatusLine().getReasonPhrase():"");
294-
* responseBuilder.append("]]></ErrorText></Error></Errors></response>"); }
295-
*
296-
* rawResponseString = responseBuilder.toString(); }
297-
*
298-
*
299-
* httpClient.getConnectionManager().shutdown();
300-
*
301-
* if(rawResponseString == null) return null;
302-
*
303-
*
304-
* int mark = rawResponseString.indexOf("<?xml"); if(mark == -1){ return null; }
305-
*
306-
* response.parseString(rawResponseString.substring(mark,rawResponseString.
307-
* length())); if(response.IsAccessible() == false){ return null; } } catch
308-
* (Exception e) { LogHelper.warn(logger,
309-
* "Exception getting response: '%s': '%s', '%s'", e.getMessage(), e.getCause(),
310-
* Arrays.toString(e.getStackTrace())); } }
311-
*
312-
* return response; }
313-
*/
314-
99+
315100
/**
316101
* @return returns an SSL context with TLSv1.2 protocol instance to be used in
317102
* the call

src/test/java/net/authorize/api/controller/test/ApiCoreTestBase.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ public void setUp() throws Exception {
179179
counterStr = getRandomString("");
180180

181181
now = Calendar.getInstance().getTime();
182-
// nowString = DateUtil.getFormattedDate(now, ReportingDetails.DATE_FORMAT);
183182

184183
datatypeFactory = DatatypeFactory.newInstance();
185184
// TODO add / subtract relative

src/test/java/net/authorize/util/LuhnTest.java

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)