3434import java .io .FileInputStream ;
3535import java .io .IOException ;
3636import java .io .StringReader ;
37+ import java .lang .reflect .InvocationTargetException ;
3738import java .security .KeyStore ;
3839import java .security .cert .PKIXParameters ;
3940import java .security .cert .TrustAnchor ;
@@ -90,14 +91,16 @@ public static Map runTransaction(Map<String,String> request, Properties props)
9091 * @throws FaultException if a fault occurs.
9192 * @throws ClientException if any other exception occurs.
9293 */
93- public static Map runTransaction (
94+ @ SuppressWarnings ("unchecked" )
95+ public static Map runTransaction (
9496 Map <String , String > request , Properties props ,
9597 Logger _logger , boolean prepare , boolean logTranStart )
9698 throws FaultException , ClientException {
9799 MerchantConfig mc ;
98100 LoggerWrapper logger = null ;
99101 Connection con = null ;
100102
103+
101104 try {
102105 setVersionInformation (request );
103106
@@ -122,8 +125,39 @@ public static Map runTransaction(
122125// FileWriter writer = new FileWriter(new File("signedDoc.xml"));
123126// writer.write(XMLUtils.PrettyDocumentToString(signedDoc));
124127// writer.close();
125-
126- con = Connection .getInstance (mc , builder , logger );
128+ if (mc .isCustomHttpClassEnabled ()){
129+ Class <Connection > customConnectionClass ;
130+ try {
131+ customConnectionClass = (Class <Connection >) Class .forName (mc .getcustomHttpClass ());
132+ Class [] constructor_Args = new Class [] {com .cybersource .ws .client .MerchantConfig .class , javax .xml .parsers .DocumentBuilder .class , com .cybersource .ws .client .LoggerWrapper .class };
133+ con =customConnectionClass .getDeclaredConstructor (constructor_Args ).newInstance (mc , builder , logger );
134+
135+ } catch (InstantiationException e ) {
136+ logger .log (Logger .LT_INFO , "Failed to Instantiate the class " +e );
137+ throw new ClientException (e , false , null );
138+ } catch (IllegalAccessException e ) {
139+ logger .log (Logger .LT_INFO , "Could not Access the method invoked " +e );
140+ throw new ClientException (e , false , null );
141+ } catch (ClassNotFoundException e ) {
142+ logger .log (Logger .LT_INFO , "Could not load the custom HTTP class " );
143+ throw new ClientException (e , false , null );
144+ } catch (IllegalArgumentException e ) {
145+ logger .log (Logger .LT_INFO , "Method invoked with Illegal Argument list " +e );
146+ throw new ClientException (e , false , null );
147+ } catch (SecurityException e ) {
148+ logger .log (Logger .LT_INFO , "Security Exception " +e );
149+ throw new ClientException (e , false , null );
150+ } catch (InvocationTargetException e ) {
151+ logger .log (Logger .LT_INFO , "Exception occured while calling the method " +e );
152+ throw new ClientException (e , false , null );
153+ } catch (NoSuchMethodException e ) {
154+ logger .log (Logger .LT_INFO , "Method not found " );
155+ throw new ClientException (e , false , null );
156+ }
157+ }
158+ else {
159+ con = Connection .getInstance (mc , builder , logger );
160+ }
127161 Document wrappedReply = con .post (signedDoc );
128162 Map <String , String > replyMap = soapUnwrap (wrappedReply , mc , logger );
129163 logger .log (Logger .LT_INFO , "Client, End of runTransaction Call " ,false );
0 commit comments