|
@@ -1,15 +1,17 @@
|
|
|
package com.psi.gabontel.mobileapp.thirdparty.helper;
|
|
package com.psi.gabontel.mobileapp.thirdparty.helper;
|
|
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
+import java.util.Properties;
|
|
|
|
|
|
|
|
-import javax.ejb.ApplicationException;
|
|
|
|
|
|
|
+import javax.ejb.EJBTransactionRolledbackException;
|
|
|
import javax.ejb.Remote;
|
|
import javax.ejb.Remote;
|
|
|
import javax.ejb.Stateless;
|
|
import javax.ejb.Stateless;
|
|
|
|
|
|
|
|
import org.jboss.logging.Logger;
|
|
import org.jboss.logging.Logger;
|
|
|
-import org.json.JSONArray;
|
|
|
|
|
-import org.json.JSONObject;
|
|
|
|
|
|
|
+import org.wildfly.security.auth.client.AuthenticationContext;
|
|
|
|
|
+import org.wildfly.security.auth.client.MatchRule;
|
|
|
|
|
|
|
|
import com.psi.applicationmanager.AppManagerFunction;
|
|
import com.psi.applicationmanager.AppManagerFunction;
|
|
|
import com.psi.applicationmanager.AppMessage;
|
|
import com.psi.applicationmanager.AppMessage;
|
|
@@ -19,13 +21,12 @@ import com.psi.common.transactions.MessageId;
|
|
|
import com.psi.common.transactions.Messanger;
|
|
import com.psi.common.transactions.Messanger;
|
|
|
import com.psi.common.transactions.TransactionHelper;
|
|
import com.psi.common.transactions.TransactionHelper;
|
|
|
import com.psi.common.util.StringUtil;
|
|
import com.psi.common.util.StringUtil;
|
|
|
-import com.psi.common.util.SystemUtil;
|
|
|
|
|
|
|
|
|
|
@Stateless
|
|
@Stateless
|
|
|
@Remote(AppManagerFunction.class)
|
|
@Remote(AppManagerFunction.class)
|
|
|
public class MobileAppThirdPartyHelper implements AppManagerFunction {
|
|
public class MobileAppThirdPartyHelper implements AppManagerFunction {
|
|
|
private static final Logger log = Logger.getLogger(MobileAppThirdPartyHelper.class);
|
|
private static final Logger log = Logger.getLogger(MobileAppThirdPartyHelper.class);
|
|
|
-
|
|
|
|
|
|
|
+ private int code = 0;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public String processTransaction(String refid, String msisdn, String message, Map<String, String> syntax) {
|
|
public String processTransaction(String refid, String msisdn, String message, Map<String, String> syntax) {
|
|
@@ -43,9 +44,11 @@ public class MobileAppThirdPartyHelper implements AppManagerFunction {
|
|
|
McomSubscriber originator = null;
|
|
McomSubscriber originator = null;
|
|
|
boolean isfinal = false;
|
|
boolean isfinal = false;
|
|
|
String finalmessage = "System Busy.";
|
|
String finalmessage = "System Busy.";
|
|
|
|
|
+
|
|
|
if(!StringUtil.isNullOrEmpty(password)) {
|
|
if(!StringUtil.isNullOrEmpty(password)) {
|
|
|
isfinal = true;
|
|
isfinal = true;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
Message msg = Messanger.getMessage(MessageId.SYSTEM_BUSY, msisdn, "<refid>", refid);
|
|
Message msg = Messanger.getMessage(MessageId.SYSTEM_BUSY, msisdn, "<refid>", refid);
|
|
|
try {
|
|
try {
|
|
|
if(isfinal) {
|
|
if(isfinal) {
|
|
@@ -56,24 +59,24 @@ public class MobileAppThirdPartyHelper implements AppManagerFunction {
|
|
|
return new Message(99,0,msg.getMessage().toString());
|
|
return new Message(99,0,msg.getMessage().toString());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if(InitializerBean.containsKey(method)) {
|
|
|
|
|
|
|
+ if(containsKey(method)) {
|
|
|
String appmanresponse = "";
|
|
String appmanresponse = "";
|
|
|
String[] paramarr = mparam.split("\\|");
|
|
String[] paramarr = mparam.split("\\|");
|
|
|
|
|
|
|
|
if(method.equals("canalvalidcard")) {
|
|
if(method.equals("canalvalidcard")) {
|
|
|
- String canalcheckcard = InitializerBean.callUssd("canalcheckcard", paramarr).toString();
|
|
|
|
|
- String canalvalidcard = InitializerBean.callUssd("canalvalidcard", canalcheckcard).toString();
|
|
|
|
|
|
|
+ String canalcheckcard = callUssd("canalcheckcard", paramarr).toString();
|
|
|
|
|
+ String canalvalidcard = callUssd("canalvalidcard", canalcheckcard).toString();
|
|
|
appmanresponse = canalvalidcard;
|
|
appmanresponse = canalvalidcard;
|
|
|
}else if(method.equals("canalsetcard")) {
|
|
}else if(method.equals("canalsetcard")) {
|
|
|
String[] csetcardarr = mparam.replaceAll("_", " ").split("\\|");
|
|
String[] csetcardarr = mparam.replaceAll("_", " ").split("\\|");
|
|
|
- appmanresponse = InitializerBean.callUssd(method, csetcardarr).toString();
|
|
|
|
|
|
|
+ appmanresponse = callUssd(method, csetcardarr).toString();
|
|
|
}else if(method.equals("canalrenewamount")){
|
|
}else if(method.equals("canalrenewamount")){
|
|
|
String canalrenewamount = "";
|
|
String canalrenewamount = "";
|
|
|
- String canalcheckcard = InitializerBean.callUssd("canalcheckcard", paramarr).toString();
|
|
|
|
|
- String canalvalidcard = InitializerBean.callUssd("canalvalidcard", canalcheckcard).toString();
|
|
|
|
|
|
|
+ String canalcheckcard = callUssd("canalcheckcard", paramarr).toString();
|
|
|
|
|
+ String canalvalidcard = callUssd("canalvalidcard", canalcheckcard).toString();
|
|
|
appmanresponse = canalvalidcard;
|
|
appmanresponse = canalvalidcard;
|
|
|
if(canalvalidcard.equals("")) {
|
|
if(canalvalidcard.equals("")) {
|
|
|
- canalrenewamount = InitializerBean.callUssd("canalrenewamount", canalcheckcard).toString();
|
|
|
|
|
|
|
+ canalrenewamount = callUssd("canalrenewamount", canalcheckcard).toString();
|
|
|
appmanresponse = canalrenewamount;
|
|
appmanresponse = canalrenewamount;
|
|
|
}
|
|
}
|
|
|
}else if(method.equals("canalappman")) {
|
|
}else if(method.equals("canalappman")) {
|
|
@@ -81,61 +84,79 @@ public class MobileAppThirdPartyHelper implements AppManagerFunction {
|
|
|
String[] canalappman = mparam.split("\\|");
|
|
String[] canalappman = mparam.split("\\|");
|
|
|
if(canalappman[0].equals("renew")) {
|
|
if(canalappman[0].equals("renew")) {
|
|
|
String[] canalcheckcardparam = (canalappman[1] + "|1").split("\\|");
|
|
String[] canalcheckcardparam = (canalappman[1] + "|1").split("\\|");
|
|
|
- String canalcheckcard = InitializerBean.callUssd("canalcheckcard", canalcheckcardparam).toString();
|
|
|
|
|
|
|
+ String canalcheckcard = callUssd("canalcheckcard", canalcheckcardparam).toString();
|
|
|
String[] canalappmanparam = (canalappman[0] + "|" + canalappman[1] +"|"+ canalcheckcard).split("\\|");
|
|
String[] canalappmanparam = (canalappman[0] + "|" + canalappman[1] +"|"+ canalcheckcard).split("\\|");
|
|
|
- canalappmanglobal = InitializerBean.callUssd("canalappman", canalappmanparam).toString();
|
|
|
|
|
|
|
+ canalappmanglobal = callUssd("canalappman", canalappmanparam).toString();
|
|
|
}
|
|
}
|
|
|
appmanresponse = canalappmanglobal;
|
|
appmanresponse = canalappmanglobal;
|
|
|
}else if(method.equals("seegregisteradd")) {
|
|
}else if(method.equals("seegregisteradd")) {
|
|
|
String[] seegregisteraddparam = (mparam.toString() + "|" + "L' enregistrement de votre compteur a ete fait avec succes" ).split("\\|");
|
|
String[] seegregisteraddparam = (mparam.toString() + "|" + "L' enregistrement de votre compteur a ete fait avec succes" ).split("\\|");
|
|
|
- appmanresponse = InitializerBean.callUssd("seegregisteradd", seegregisteraddparam).toString();
|
|
|
|
|
|
|
+ appmanresponse = callUssd("seegregisteradd", seegregisteraddparam).toString();
|
|
|
}else if(method.equals("seeggetdisplay")) {
|
|
}else if(method.equals("seeggetdisplay")) {
|
|
|
String[] seeggetdisplaydata = mparam.split("\\|");
|
|
String[] seeggetdisplaydata = mparam.split("\\|");
|
|
|
String[] seeggetdisplayparam = (new String(StringUtil.base64Decode(seeggetdisplaydata[0]), StandardCharsets.UTF_8)).split("\\~");
|
|
String[] seeggetdisplayparam = (new String(StringUtil.base64Decode(seeggetdisplaydata[0]), StandardCharsets.UTF_8)).split("\\~");
|
|
|
- appmanresponse = InitializerBean.callUssd("seeggetdisplay", seeggetdisplayparam).toString();
|
|
|
|
|
|
|
+ appmanresponse = callUssd("seeggetdisplay", seeggetdisplayparam).toString();
|
|
|
}else if(method.equals("seegregisteredit")) {
|
|
}else if(method.equals("seegregisteredit")) {
|
|
|
String[] seegregistereditdata = mparam.split("\\|");
|
|
String[] seegregistereditdata = mparam.split("\\|");
|
|
|
String[] seegregistereditparam = (new String(StringUtil.base64Decode(seegregistereditdata[0]), StandardCharsets.UTF_8) + "~" + seegregistereditdata[1] + "~" + seegregistereditdata[2]+ "~" + seegregistereditdata[3] + "~" + seegregistereditdata[4] + "~" + seegregistereditdata[5] + "~" + seegregistereditdata[6] + "~" + "Numero de compteur modifie").split("\\~");
|
|
String[] seegregistereditparam = (new String(StringUtil.base64Decode(seegregistereditdata[0]), StandardCharsets.UTF_8) + "~" + seegregistereditdata[1] + "~" + seegregistereditdata[2]+ "~" + seegregistereditdata[3] + "~" + seegregistereditdata[4] + "~" + seegregistereditdata[5] + "~" + seegregistereditdata[6] + "~" + "Numero de compteur modifie").split("\\~");
|
|
|
- appmanresponse = InitializerBean.callUssd("seegregisteredit", seegregistereditparam).toString();
|
|
|
|
|
|
|
+ appmanresponse = callUssd("seegregisteredit", seegregistereditparam).toString();
|
|
|
}else if(method.equals("seegregisterdelete")) {
|
|
}else if(method.equals("seegregisterdelete")) {
|
|
|
String[] seegregisterdeletedata = mparam.split("\\|");
|
|
String[] seegregisterdeletedata = mparam.split("\\|");
|
|
|
String[] seegregisterdeleteparam = (new String(StringUtil.base64Decode(seegregisterdeletedata[0]), StandardCharsets.UTF_8) + "~" + seegregisterdeletedata[1] + "~" + seegregisterdeletedata[2]+ "~" + seegregisterdeletedata[3] + "~" + "Le compteur " + seegregisterdeletedata[4] + " a ete efface").split("\\~");
|
|
String[] seegregisterdeleteparam = (new String(StringUtil.base64Decode(seegregisterdeletedata[0]), StandardCharsets.UTF_8) + "~" + seegregisterdeletedata[1] + "~" + seegregisterdeletedata[2]+ "~" + seegregisterdeletedata[3] + "~" + "Le compteur " + seegregisterdeletedata[4] + " a ete efface").split("\\~");
|
|
|
- appmanresponse = InitializerBean.callUssd("seegregisterdelete", seegregisterdeleteparam).toString();
|
|
|
|
|
|
|
+ appmanresponse = callUssd("seegregisterdelete", seegregisterdeleteparam).toString();
|
|
|
}else if(method.equals("seeginvoicesdisplay")) {
|
|
}else if(method.equals("seeginvoicesdisplay")) {
|
|
|
String[] seeginvoices = mparam.split("\\|");
|
|
String[] seeginvoices = mparam.split("\\|");
|
|
|
- String seeginvoicesdata = InitializerBean.callUssd("seeginvoices", seeginvoices).toString();
|
|
|
|
|
|
|
+ String seeginvoicesdata = callUssd("seeginvoices", seeginvoices).toString();
|
|
|
if(seeginvoicesdata.startsWith("Vous n'avez pas de facture a payer a la SEEG")) {
|
|
if(seeginvoicesdata.startsWith("Vous n'avez pas de facture a payer a la SEEG")) {
|
|
|
appmanresponse = seeginvoicesdata;
|
|
appmanresponse = seeginvoicesdata;
|
|
|
}else {
|
|
}else {
|
|
|
- appmanresponse = InitializerBean.callUssd("seeginvoicesdisplay", seeginvoicesdata).toString();
|
|
|
|
|
|
|
+ appmanresponse = callUssd("seeginvoicesdisplay", seeginvoicesdata).toString();
|
|
|
}
|
|
}
|
|
|
}else if(method.equals("displayinvoices")) {
|
|
}else if(method.equals("displayinvoices")) {
|
|
|
String[] postpaidinvoices = mparam.split("\\|");
|
|
String[] postpaidinvoices = mparam.split("\\|");
|
|
|
- String postpaidinvoicesdata = InitializerBean.callUssd("postpaidinvoices", postpaidinvoices).toString();
|
|
|
|
|
|
|
+ String postpaidinvoicesdata = callUssd("postpaidinvoices", postpaidinvoices).toString();
|
|
|
if(postpaidinvoicesdata.startsWith("-1")) {
|
|
if(postpaidinvoicesdata.startsWith("-1")) {
|
|
|
appmanresponse = postpaidinvoicesdata;
|
|
appmanresponse = postpaidinvoicesdata;
|
|
|
}else {
|
|
}else {
|
|
|
- appmanresponse = InitializerBean.callUssd("displayinvoices", postpaidinvoicesdata).toString();
|
|
|
|
|
|
|
+ appmanresponse = callUssd("displayinvoices", postpaidinvoicesdata).toString();
|
|
|
}
|
|
}
|
|
|
}else if(method.equals("ebillingobj")) {
|
|
}else if(method.equals("ebillingobj")) {
|
|
|
String[] ebillingparam = (mparam + "|" + refid).split("\\|");
|
|
String[] ebillingparam = (mparam + "|" + refid).split("\\|");
|
|
|
- appmanresponse = InitializerBean.callUssd("ebillingobj", ebillingparam).toString();
|
|
|
|
|
|
|
+ appmanresponse = callUssd("ebillingobj", ebillingparam).toString();
|
|
|
if(!appmanresponse.startsWith("-1")) {
|
|
if(!appmanresponse.startsWith("-1")) {
|
|
|
- String payee = InitializerBean.callUssd("ebillingpayee", appmanresponse).toString();
|
|
|
|
|
- String amount = InitializerBean.callUssd("ebillingamount", appmanresponse).toString();
|
|
|
|
|
- String description = InitializerBean.callUssd("ebillingdesc", appmanresponse).toString();
|
|
|
|
|
|
|
+ String payee = callUssd("ebillingpayee", appmanresponse).toString();
|
|
|
|
|
+ String amount = callUssd("ebillingamount", appmanresponse).toString();
|
|
|
|
|
+ String description = callUssd("ebillingdesc", appmanresponse).toString();
|
|
|
appmanresponse = payee.toUpperCase() + "~" + amount + "~" + description.replaceAll("~", " ");
|
|
appmanresponse = payee.toUpperCase() + "~" + amount + "~" + description.replaceAll("~", " ");
|
|
|
}
|
|
}
|
|
|
- }else if(method.equals("ussd")) {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ //newly added for total
|
|
|
|
|
+ else if(method.equals("sambagetdisplay")) {
|
|
|
|
|
+ String[] sambagetdisplaydata = mparam.split("\\|");
|
|
|
|
|
+ String[] sambagetdisplayparam = (new String(StringUtil.base64Decode(sambagetdisplaydata[0]), StandardCharsets.UTF_8)).split("\\~");
|
|
|
|
|
+ appmanresponse = callUssd("sambagetdisplay", sambagetdisplayparam).toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ //newly added for Ecobank
|
|
|
|
|
+ else if(method.equals("ecobankgetaccount")) {
|
|
|
|
|
+ String[] ecobankgetaccountdata = mparam.split("\\|");
|
|
|
|
|
+ appmanresponse = callUssd("ecobankgetaccount", ecobankgetaccountdata).toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ //newly added for UBA
|
|
|
|
|
+ else if(method.equals("ubagetaccount")) {
|
|
|
|
|
+ String[] ubagetaccountdata = mparam.split("\\|");
|
|
|
|
|
+ appmanresponse = callUssd("ubagetaccount", ubagetaccountdata).toString();
|
|
|
|
|
+ log.info("APPMANRESPONSE: "+appmanresponse);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(method.equals("ussd")) {
|
|
|
if(isfinal) {
|
|
if(isfinal) {
|
|
|
mparam = mparam + "*" + password + "#";
|
|
mparam = mparam + "*" + password + "#";
|
|
|
}
|
|
}
|
|
|
- appmanresponse = InitializerBean.callUssd(method, "mobicash", msisdn, mparam).toString();
|
|
|
|
|
|
|
+ appmanresponse = callUssd(method, "mobicash", msisdn, mparam).toString();
|
|
|
}else {
|
|
}else {
|
|
|
- appmanresponse = InitializerBean.callUssd(method, paramarr).toString();
|
|
|
|
|
|
|
+ appmanresponse = callUssd(method, paramarr).toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- response = StringUtil.base64Encode(new JsonResponse(0,appmanresponse).toString().getBytes());
|
|
|
|
|
|
|
+ response = StringUtil.base64Encode(new JsonResponse(code,appmanresponse).toString().getBytes());
|
|
|
finalmessage = respmessage + response;
|
|
finalmessage = respmessage + response;
|
|
|
if(isfinal) {
|
|
if(isfinal) {
|
|
|
finalmessage = appmanresponse;
|
|
finalmessage = appmanresponse;
|
|
@@ -151,4 +172,37 @@ public class MobileAppThirdPartyHelper implements AppManagerFunction {
|
|
|
}
|
|
}
|
|
|
return new Message(99,0,finalmessage);
|
|
return new Message(99,0,finalmessage);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private static boolean containsKey(String key) {
|
|
|
|
|
+ return InitializerBean.getUssdgwmenuejb().containsKey(key);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String callUssd(final String key, final String ... params) {
|
|
|
|
|
+ String response = "";
|
|
|
|
|
+ try {
|
|
|
|
|
+ final Properties prop = InitializerBean.getJndiproperties();
|
|
|
|
|
+ final String jndi = InitializerBean.getUssdgwmenuejb().get(key);
|
|
|
|
|
+ final AuthenticationContext auth = AuthenticationContext.empty().with(MatchRule.ALL, InitializerBean.getUserconfig());
|
|
|
|
|
+ response = auth.runCallable(new BeanCaller(prop,jndi,Arrays.asList(params)));
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (EJBTransactionRolledbackException ej) {
|
|
|
|
|
+ log.info("CATCHED EJBTransactionRolledbackException");
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception e) {
|
|
|
|
|
+ log.error(key,e);
|
|
|
|
|
+ response = "System busy. Please try again later.";
|
|
|
|
|
+ Throwable cause = e.getCause();
|
|
|
|
|
+ if(cause instanceof IllegalArgumentException) {
|
|
|
|
|
+ if(cause.getMessage().contains("|")) {
|
|
|
|
|
+ String ex[] = cause.getMessage().split("\\|");
|
|
|
|
|
+ code = Integer.valueOf(ex[0]);
|
|
|
|
|
+ response = ex[1];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ response = cause.getMessage();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return response;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|