diff --git a/com.wso2telco.dep.common.capp/pom.xml b/com.wso2telco.dep.common.capp/pom.xml index dcda64e..4853cfe 100644 --- a/com.wso2telco.dep.common.capp/pom.xml +++ b/com.wso2telco.dep.common.capp/pom.xml @@ -29,6 +29,7 @@ capp/EnterpriseServiceBus capp/EnterpriseServiceBus capp/EnterpriseServiceBus + capp/EnterpriseServiceBus capp/EnterpriseServiceBus capp/EnterpriseServiceBus capp/EnterpriseServiceBus @@ -251,6 +252,12 @@ 2.1.4-SNAPSHOT xml + + com.wso2telco.dep.common.template + com.wso2telco.dep.common.anonymizeUserData.Template + 2.1.4-SNAPSHOT + xml + com.wso2telco.dep.common.sequence com.wso2telco.dep.common.main.response.Sequence diff --git a/com.wso2telco.dep.common.mediation/pom.xml b/com.wso2telco.dep.common.mediation/pom.xml index 6d2b801..2237f1d 100644 --- a/com.wso2telco.dep.common.mediation/pom.xml +++ b/com.wso2telco.dep.common.mediation/pom.xml @@ -86,6 +86,11 @@ org.apache.axis2.wso2 axis2 + + com.wso2telco.dep + user-masking + 2.4.4 + @@ -202,6 +207,14 @@ - + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + diff --git a/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/MSISDNBlacklistMediator.java b/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/MSISDNBlacklistMediator.java index c95bf51..43b13bf 100644 --- a/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/MSISDNBlacklistMediator.java +++ b/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/MSISDNBlacklistMediator.java @@ -1,6 +1,7 @@ package com.wso2telco.dep.common.mediation; import com.wso2telco.dep.common.mediation.service.APIService; +import com.wso2telco.dep.common.mediation.util.MSISDNConstants; import org.apache.synapse.MessageContext; import org.apache.synapse.SynapseConstants; import org.apache.synapse.mediators.AbstractMediator; @@ -25,9 +26,15 @@ public boolean mediate(MessageContext messageContext) { String msisdn = (String) messageContext.getProperty("paramValue"); String paramArray = (String) messageContext.getProperty("paramArray"); + String maskedMsidsn = (String) messageContext.getProperty("MASKED_MSISDN"); + String maskedMsisdnSuffix = (String) messageContext.getProperty("MASKED_MSISDN_SUFFIX"); + String maskedMsidsnArray = (String) messageContext.getProperty("MASKED_MSISDN_LIST"); String apiName = (String) messageContext.getProperty("API_NAME"); String apiVersion = (String) messageContext.getProperty("VERSION"); String apiPublisher = (String) messageContext.getProperty("API_PUBLISHER"); + String secretKey = (String)messageContext.getProperty(MSISDNConstants.USER_MASKING_SECRET_KEY); + + String loggingMsisdn = msisdn; String apiID; APIService apiService = new APIService(); @@ -43,25 +50,25 @@ public boolean mediate(MessageContext messageContext) { formattedPhoneNumber = matcher.group(Integer.parseInt(regexGroupNumber)); } + if(Boolean.parseBoolean((String)messageContext.getProperty("USER_ANONYMIZATION"))) { + loggingMsisdn = maskedMsidsn; + formattedPhoneNumber = maskedMsisdnSuffix; + } + try { apiID = apiService.getAPIId(apiPublisher, apiName, apiVersion); - if (apiService.isBlackListedNumber(apiID, formattedPhoneNumber)) { - log.info(msisdn + " is BlackListed number for " + apiName + " API" + apiVersion + " version"); + if (apiService.isBlackListedNumber(apiID, formattedPhoneNumber, secretKey)) { + log.info(loggingMsisdn + " is BlackListed number for " + apiName + " API" + apiVersion + " version"); messageContext.setProperty(SynapseConstants.ERROR_CODE, "POL0001:"); messageContext.setProperty(SynapseConstants.ERROR_MESSAGE, "Internal Server Error. Blacklisted " + "Number"); messageContext.setProperty("BLACKLISTED_MSISDN", "true"); - String errorVariable = msisdn; - - if(paramArray != null){ - errorVariable = paramArray; - } setErrorInContext( messageContext, "SVC0004", " blacklisted number. %1", - errorVariable, + msisdn, "400", "POLICY_EXCEPTION"); } else { messageContext.setProperty("BLACKLISTED_MSISDN", "false"); @@ -71,10 +78,13 @@ public boolean mediate(MessageContext messageContext) { log.error("error in MSISDNBlacklistMediator mediate : " + e.getMessage()); - String errorVariable = msisdn; + String errorVariable = loggingMsisdn; if(paramArray != null){ errorVariable = paramArray; + if(Boolean.valueOf((String)messageContext.getProperty("USER_ANONYMIZATION")).booleanValue()) { + errorVariable = maskedMsidsnArray; + } } setErrorInContext( messageContext, diff --git a/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/MSISDNWhitelistMediator.java b/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/MSISDNWhitelistMediator.java index 77bc4ad..0f469d4 100644 --- a/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/MSISDNWhitelistMediator.java +++ b/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/MSISDNWhitelistMediator.java @@ -14,6 +14,9 @@ public boolean mediate(MessageContext messageContext) { String msisdn = (String) messageContext.getProperty("paramValue"); String paramArray = (String) messageContext.getProperty("paramArray"); + String maskedMsidsn = (String) messageContext.getProperty("MASKED_MSISDN"); + String maskedMsisdnSuffix = (String) messageContext.getProperty("MASKED_MSISDN_SUFFIX"); + String maskedMsidsnArray = (String) messageContext.getProperty("MASKED_MSISDN_LIST"); String apiName = (String) messageContext.getProperty("API_NAME"); String apiVersion = (String) messageContext.getProperty("VERSION"); String apiPublisher = (String) messageContext.getProperty("API_PUBLISHER"); @@ -21,6 +24,8 @@ public boolean mediate(MessageContext messageContext) { String regexPattern = (String) messageContext.getProperty("msisdnRegex"); String regexGroupNumber = (String) messageContext.getProperty("msisdnRegexGroup"); + String loggingMsisdn = msisdn; + Pattern pattern = Pattern.compile(regexPattern); Matcher matcher = pattern.matcher(msisdn); @@ -29,6 +34,11 @@ public boolean mediate(MessageContext messageContext) { formattedPhoneNumber = matcher.group(Integer.parseInt(regexGroupNumber)); } + if(Boolean.parseBoolean((String)messageContext.getProperty("USER_ANONYMIZATION"))) { + loggingMsisdn = maskedMsidsn; + formattedPhoneNumber = maskedMsisdnSuffix; + } + try { APIService apiService = new APIService(); String apiID = apiService.getAPIId(apiPublisher, apiName, apiVersion); @@ -46,16 +56,11 @@ public boolean mediate(MessageContext messageContext) { " Number"); messageContext.setProperty("WHITELISTED_MSISDN", "false"); - String errorVariable = msisdn; - - if(paramArray != null){ - errorVariable = paramArray; - } setErrorInContext( messageContext, "SVC0004", " Not a whitelisted number. %1", - errorVariable, + msisdn, "400", "POLICY_EXCEPTION"); } @@ -64,10 +69,13 @@ public boolean mediate(MessageContext messageContext) { log.error("error in MSISDNWhitelistMediator mediate : " + e.getMessage()); - String errorVariable = msisdn; + String errorVariable = loggingMsisdn; if(paramArray != null){ errorVariable = paramArray; + if(Boolean.valueOf((String)messageContext.getProperty("USER_ANONYMIZATION")).booleanValue()) { + errorVariable = maskedMsidsnArray; + } } setErrorInContext( messageContext, diff --git a/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/UserMaskingMediator.java b/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/UserMaskingMediator.java new file mode 100644 index 0000000..8e94c2f --- /dev/null +++ b/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/UserMaskingMediator.java @@ -0,0 +1,224 @@ +package com.wso2telco.dep.common.mediation; + +import com.wso2telco.dep.common.mediation.util.MSISDNConstants; +import com.wso2telco.dep.common.mediation.util.MSISDNUtils; +import org.apache.synapse.MessageContext; +import org.apache.synapse.commons.json.JsonUtil; +import org.apache.synapse.core.axis2.Axis2MessageContext; +import org.apache.synapse.mediators.AbstractMediator; +import org.json.JSONArray; +import org.json.JSONObject; + +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Map; + +public class UserMaskingMediator extends AbstractMediator { + + public boolean mediate(MessageContext messageContext) { + try { + // Getting the json payload to string + String jsonString = JsonUtil.jsonPayloadToString(((Axis2MessageContext) messageContext).getAxis2MessageContext()); + JSONObject jsonBody = new JSONObject(jsonString); + // Getting API handler + String handler = (String) messageContext.getProperty("handler"); + if (handler != null) { + if (handler.equals("SendSMSHandler")) { + + Object headers = ((Axis2MessageContext) messageContext).getAxis2MessageContext() + .getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); + Map headersMap = null; + if (headers != null && headers instanceof Map) { + headersMap = (Map) headers; + } + + if (!jsonBody.isNull(MSISDNConstants.OUTBOUND_SMS_MESSAGE_REQUEST)) { + JSONObject outboundSMSMessageRequest = jsonBody.getJSONObject(MSISDNConstants.OUTBOUND_SMS_MESSAGE_REQUEST); + if (!outboundSMSMessageRequest.isNull(MSISDNConstants.ADDRESS)) { + String[] addressList = null; + if (Boolean.valueOf((String)messageContext.getProperty(MSISDNConstants.ANONYMIZE))) { + addressList = ((String)messageContext.getProperty("MASKED_MSISDN_LIST")).split(","); + JSONObject deliveryInfoList = outboundSMSMessageRequest.getJSONObject(MSISDNConstants.DELIVERY_INFO_LIST); + if (!deliveryInfoList.isNull("deliveryInfo")) { + if(!validateSMSOperatorResponse(messageContext, + (new ArrayList(Arrays.asList( + ((String)messageContext.getProperty("MSISDN_SUFFIX_LIST")).split(",")))), outboundSMSMessageRequest)) { + return true; + } + } + headersMap.put("RESOURCE", (String)messageContext.getProperty("SMS_RESOURCE")); + + } else { + addressList = ((String)messageContext.getProperty("MSISDN_LIST")).split(","); + messageContext.setProperty("SMS_RESOURCE", (String)headersMap.get("RESOURCE")); + } + JSONArray addresses = new JSONArray(); + + for (String address : addressList) { + addresses.put(address); + } + outboundSMSMessageRequest.put(MSISDNConstants.ADDRESS, addresses); + } + if (!outboundSMSMessageRequest.isNull(MSISDNConstants.DELIVERY_INFO_LIST)) { + JSONObject deliveryInfoList = outboundSMSMessageRequest.getJSONObject(MSISDNConstants.DELIVERY_INFO_LIST); + if (!deliveryInfoList.isNull("deliveryInfo")) { + Map maskedMsisdnMap = (Map) messageContext.getProperty("MASKED_MSISDN_SUFFIX_MAP"); + JSONArray deliveryInfoArray = deliveryInfoList.getJSONArray("deliveryInfo"); + JSONArray newDeliveryInfoArray = new JSONArray(); + for (int i = 0; i < deliveryInfoArray.length(); i++) { + JSONObject deliveryInfo = (JSONObject) deliveryInfoArray.get(i); + JSONObject newDeliveryInfo = new JSONObject(); + newDeliveryInfo.put("deliveryStatus", (String)deliveryInfo.get("deliveryStatus")); + if (Boolean.valueOf((String)messageContext.getProperty(MSISDNConstants.ANONYMIZE))) { + // Replace with masked user ID + newDeliveryInfo.put(MSISDNConstants.ADDRESS, getKeyFromValue( + maskedMsisdnMap, (String) deliveryInfo.get(MSISDNConstants.ADDRESS))); + } else { + // Replace with user ID + newDeliveryInfo.put(MSISDNConstants.ADDRESS, maskedMsisdnMap.get((String) deliveryInfo.get(MSISDNConstants.ADDRESS))); + } + newDeliveryInfoArray.put(i, newDeliveryInfo); + } + deliveryInfoList.put("deliveryInfo", newDeliveryInfoArray); + } + outboundSMSMessageRequest.put(MSISDNConstants.DELIVERY_INFO_LIST, deliveryInfoList); + } + + jsonBody.put(MSISDNConstants.OUTBOUND_SMS_MESSAGE_REQUEST, outboundSMSMessageRequest); + } + + } else if (handler.equals("AmountChargeHandler")) { + if (!jsonBody.isNull("amountTransaction")) { + JSONObject amountTransaction = jsonBody.getJSONObject("amountTransaction"); + Object headers = ((Axis2MessageContext) messageContext).getAxis2MessageContext() + .getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); + + Map headersMap = null; + if (headers != null && headers instanceof Map) { + headersMap = (Map) headers; + } + + String userId = null; + String maskedMSISDNSuffix = (String)messageContext.getProperty("MASKED_MSISDN_SUFFIX"); + String msisdnSuffix = (String)messageContext.getProperty("MSISDN_SUFFIX"); + String payloadMSISDN = amountTransaction.getString("endUserId"); + + if (Boolean.valueOf((String)messageContext.getProperty(MSISDNConstants.ANONYMIZE))) { + if (!msisdnSuffix.equals(MSISDNUtils.getMSISDNSuffix(payloadMSISDN))) { + log.error("Operator returned incorrect msisdn."); + setErrorInContext( + messageContext, + MSISDNConstants.SVC0001, + "A service error occurred. Error code is %1", + "operator_msisdn_mismatched", "500", "SERVICE_EXCEPTION"); + messageContext.setProperty("INTERNAL_ERROR", "true"); + return true; + } + userId = (String) messageContext.getProperty("MASKED_MSISDN"); + headersMap.put("RESOURCE", (String)messageContext.getProperty("MASKED_RESOURCE")); + String resourceURL = (String) amountTransaction.get("resourceURL"); + resourceURL = resourceURL.replace(msisdnSuffix, maskedMSISDNSuffix); + amountTransaction.put("resourceURL", resourceURL); + } else { + userId = (String) messageContext.getProperty("MSISDN"); + headersMap.put("RESOURCE", "/" + URLEncoder.encode(userId, "UTF-8") + "/transactions/amount"); + } + amountTransaction.put("endUserId", userId); + jsonBody.put("amountTransaction", amountTransaction); + } + } + + JsonUtil.newJsonPayload(((Axis2MessageContext) messageContext).getAxis2MessageContext(), jsonBody.toString(), + true, true); + } + } catch (Exception e) { + + log.error("error in UserMaskingMediator mediate : " + + e.getMessage()); + setErrorInContext( + messageContext, + "SVC0001", + "A service error occurred. Error code is %1", + null, "500", "SERVICE_EXCEPTION"); + messageContext.setProperty("INTERNAL_ERROR", "true"); + } + return true; + } + + private void setErrorInContext(MessageContext synContext, String messageId, + String errorText, String errorVariable, String httpStatusCode, + String exceptionType) { + + synContext.setProperty("messageId", messageId); + synContext.setProperty("errorText", errorText); + synContext.setProperty("errorVariable", errorVariable); + synContext.setProperty("httpStatusCode", httpStatusCode); + synContext.setProperty("exceptionType", exceptionType); + } + + public static Object getKeyFromValue(Map maskedMsisdnMap, String value) { + for (Object o : maskedMsisdnMap.keySet()) { + if (value!= null && value.contains((String)maskedMsisdnMap.get(o))) { + return value.replace((String)maskedMsisdnMap.get(o), (String)o); + } + } + return null; + } + + private boolean validateSMSOperatorResponse(MessageContext messageContext, ArrayList requestAddressesSuffixes, JSONObject payload) { + if (!validateOperatorAddressesWithRequestAddresses(requestAddressesSuffixes, payload)) { + log.error("Operator returned incorrect Addresses."); + setErrorInContext( + messageContext, + MSISDNConstants.SVC0001, + "A service error occurred. Error code is %1", + "operator_addresses_mismatched", "500", "SERVICE_EXCEPTION"); + messageContext.setProperty("INTERNAL_ERROR", "true"); + return false; + } + if (!validateOperatorDeliveryInfosWithRequestAddresses(requestAddressesSuffixes, payload)) { + log.error("Operator returned incorrect deliveryInfos."); + setErrorInContext( + messageContext, + MSISDNConstants.SVC0001, + "A service error occurred. Error code is %1", + "operator_deliveryinfo_mismatched", "500", "SERVICE_EXCEPTION"); + messageContext.setProperty("INTERNAL_ERROR", "true"); + return false; + } + return true; + } + + private boolean validateOperatorAddressesWithRequestAddresses(ArrayList requestAddressesSuffixes, JSONObject payload) { + JSONArray addresses = payload.getJSONArray(MSISDNConstants.ADDRESS); + ArrayList payloadAddressSuffixes = new ArrayList<>(); + if (addresses != null) { + for (int i = 0; i < addresses.length(); i++) { + payloadAddressSuffixes.add(MSISDNUtils.getMSISDNSuffix(addresses.get(i).toString())); + } + } + return requestAddressesSuffixes.containsAll(payloadAddressSuffixes) && payloadAddressSuffixes.containsAll(requestAddressesSuffixes); + } + + private boolean validateOperatorDeliveryInfosWithRequestAddresses(ArrayList requestAddressesSuffixes, JSONObject payload) { + if (!payload.isNull(MSISDNConstants.DELIVERY_INFO_LIST)) { + JSONObject deliveryInfoList = payload.getJSONObject(MSISDNConstants.DELIVERY_INFO_LIST); + if (!deliveryInfoList.isNull("deliveryInfo")) { + JSONArray deliveryInfoArray = deliveryInfoList.getJSONArray("deliveryInfo"); + if (deliveryInfoArray == null || deliveryInfoArray.length() == 0) { + return true; + } + ArrayList payloadAddressSuffixes = new ArrayList<>(); + if (deliveryInfoArray != null) { + for (int i = 0; i < deliveryInfoArray.length(); i++) { + payloadAddressSuffixes.add(MSISDNUtils.getMSISDNSuffix(deliveryInfoArray.getJSONObject(i).getString( + MSISDNConstants.ADDRESS))); + } + } + return requestAddressesSuffixes.containsAll(payloadAddressSuffixes) && payloadAddressSuffixes.containsAll(requestAddressesSuffixes); + } + } + return true; + } +} diff --git a/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/dao/APIDAO.java b/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/dao/APIDAO.java index 37ae684..f8218ad 100644 --- a/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/dao/APIDAO.java +++ b/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/dao/APIDAO.java @@ -432,7 +432,7 @@ public int getSubscriptionId(String apiID, String applicationID) return -1; } - public boolean checkWhiteListed(String MSISDN, String applicationId, + public boolean checkWhiteListed(String msisdn, String applicationId, String subscriptionId, String apiId) throws Exception { Connection connection = null; @@ -467,23 +467,23 @@ public boolean checkWhiteListed(String MSISDN, String applicationId, // "(`subscriptionID` = ? AND `msisdn` = ? AND `api_id` = ? AND `application_id` = >) OR \n" // + preparedStatement.setString(1, subscriptionId); - preparedStatement.setString(2, MSISDN); + preparedStatement.setString(2, msisdn); preparedStatement.setString(3, apiId); preparedStatement.setString(4, applicationId); // "(`subscriptionID` = null AND `msisdn` = ? AND `api_id` = ? AND `application_id` = ?) OR\n" - preparedStatement.setString(5, MSISDN); + preparedStatement.setString(5, msisdn); preparedStatement.setString(6, apiId); preparedStatement.setString(7, applicationId); // "(`subscriptionID` = ? AND `msisdn` = ? AND `api_id` = null AND `application_id` = null) OR \n" // + preparedStatement.setString(8, subscriptionId); - preparedStatement.setString(9, MSISDN); + preparedStatement.setString(9, msisdn); // "(`subscriptionID` = null AND `msisdn` = ? AND `api_id` = null AND `application_id` = ?) OR \n" // + - preparedStatement.setString(10, MSISDN); + preparedStatement.setString(10, msisdn); preparedStatement.setString(11, applicationId); // "(`subscriptionID` = null AND `msisdn` = null AND `api_id` = null AND `application_id` = ?) OR \n" diff --git a/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/service/APIService.java b/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/service/APIService.java index 395d110..c4eae00 100644 --- a/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/service/APIService.java +++ b/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/service/APIService.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Map; +import com.wso2telco.dep.user.masking.UserMaskHandler; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -146,6 +147,24 @@ public boolean isBlackListedNumber(String apiId, String msisdn) return false; } + + public boolean isBlackListedNumber(String apiId, String msisdn, String secretKey) + throws Exception { + try { + List msisdnArrayList = apiDAO.readBlacklistNumbers(apiId); + return (msisdnArrayList.contains(msisdn) + || msisdnArrayList.contains("tel3A+" + msisdn) + || msisdnArrayList.contains( + UserMaskHandler.maskUserId(msisdn, true, secretKey)) + || msisdnArrayList.contains("tel3A+" + + UserMaskHandler.maskUserId(msisdn, true, secretKey))); + } catch (Exception ex) { + log.error("Error while checking whether the msisdn :" + msisdn + + " is blacklisted", ex); + throw ex; + } + } + public String getSubscriptionID(String apiId, String applicationId) throws Exception { return String.valueOf(apiDAO.getSubscriptionId(apiId, applicationId)); diff --git a/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/util/MSISDNConstants.java b/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/util/MSISDNConstants.java new file mode 100644 index 0000000..afe252f --- /dev/null +++ b/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/util/MSISDNConstants.java @@ -0,0 +1,29 @@ +package com.wso2telco.dep.common.mediation.util; + +public class MSISDNConstants { + + public static final String USER_MASKING_SECRET_KEY = "USER_MASKING_SECRET_KEY"; + + /** The Constant TEL:+. */ + public static final String TEL_1= "tel:+"; + + /** The Constant TEL:. */ + public static final String TEL_2= "tel:"; + + /** The Constant TEL. */ + public static final String TEL_3= "tel"; + + /** The Constant + */ + public static final String PLUS = "+"; + + + public static final String DELIVERY_INFO_LIST = "deliveryInfoList"; + + public static final String SVC0001 = "SVC0001"; + + public static final String OUTBOUND_SMS_MESSAGE_REQUEST = "outboundSMSMessageRequest"; + + public static final String ANONYMIZE = "anonymize"; + + public static final String ADDRESS = "address"; +} diff --git a/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/util/MSISDNUtils.java b/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/util/MSISDNUtils.java new file mode 100644 index 0000000..21dad1f --- /dev/null +++ b/com.wso2telco.dep.common.mediation/src/main/java/com/wso2telco/dep/common/mediation/util/MSISDNUtils.java @@ -0,0 +1,22 @@ +package com.wso2telco.dep.common.mediation.util; + +public class MSISDNUtils { + + + public static String getMSISDNSuffix(String msisdn) { + String msisdnSuffix = msisdn; + if (msisdn != null && !msisdn.isEmpty()) { + if (msisdn.contains(MSISDNConstants.TEL_1)) { + msisdnSuffix = msisdn.replace(MSISDNConstants.TEL_1, ""); + } else if (msisdn.contains(MSISDNConstants.TEL_2)) { + msisdnSuffix = msisdn.replace(MSISDNConstants.TEL_2, ""); + } else if (msisdn.contains(MSISDNConstants.TEL_3)) { + msisdnSuffix = msisdn.replace(MSISDNConstants.TEL_3, ""); + } else if (msisdn.contains(MSISDNConstants.PLUS)) { + msisdnSuffix = msisdn.replace(MSISDNConstants.PLUS, ""); + } + } + return msisdnSuffix; + } + +} diff --git a/com.wso2telco.dep.common.registry.resources/mediationConfig.xml b/com.wso2telco.dep.common.registry.resources/mediationConfig.xml index 1607ee4..316d303 100644 --- a/com.wso2telco.dep.common.registry.resources/mediationConfig.xml +++ b/com.wso2telco.dep.common.registry.resources/mediationConfig.xml @@ -27,4 +27,6 @@ false + + changethis diff --git a/com.wso2telco.dep.common.synapse/artifact.xml b/com.wso2telco.dep.common.synapse/artifact.xml index 4a62e6c..50a2f33 100644 --- a/com.wso2telco.dep.common.synapse/artifact.xml +++ b/com.wso2telco.dep.common.synapse/artifact.xml @@ -89,6 +89,9 @@ src/main/synapse-config/templates/com.wso2telco.dep.common.loggingExtension.Template.xml + + src/main/synapse-config/templates/com.wso2telco.dep.common.anonymizeUserData.Template.xml + src/main/synapse-config/sequences/com.wso2telco.dep.common.main.response.Sequence.xml diff --git a/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.anonymizeUserData.Template.xml b/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.anonymizeUserData.Template.xml new file mode 100644 index 0000000..ddeba3f --- /dev/null +++ b/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.anonymizeUserData.Template.xml @@ -0,0 +1,22 @@ + + diff --git a/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.loggingExtension.Template.xml b/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.loggingExtension.Template.xml index 75c355c..1b8d853 100644 --- a/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.loggingExtension.Template.xml +++ b/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.loggingExtension.Template.xml @@ -41,28 +41,30 @@ - + + - + - + + - + @@ -75,11 +77,12 @@ + - + - + @@ -92,8 +95,9 @@ + - + @@ -108,11 +112,12 @@ + - + - + diff --git a/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.main.request.datapublisher.Template.xml b/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.main.request.datapublisher.Template.xml index 5101656..d4daad1 100644 --- a/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.main.request.datapublisher.Template.xml +++ b/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.main.request.datapublisher.Template.xml @@ -27,8 +27,14 @@ mc.setProperty('GENERATED_API_ID', generated_api_version); "/> - - + + + + + + + + @@ -92,4 +98,4 @@ - \ No newline at end of file + diff --git a/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.main.response.datapublisher.Template.xml b/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.main.response.datapublisher.Template.xml index 85ea615..4257b3c 100644 --- a/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.main.response.datapublisher.Template.xml +++ b/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.main.response.datapublisher.Template.xml @@ -28,8 +28,14 @@ mc.setProperty('GENERATED_API_ID', generated_api_version); "/> - - + + + + + + + + @@ -99,4 +105,4 @@ - \ No newline at end of file + diff --git a/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.msisdnValidator.Template.xml b/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.msisdnValidator.Template.xml index 45e1195..92bf048 100644 --- a/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.msisdnValidator.Template.xml +++ b/com.wso2telco.dep.common.synapse/src/main/synapse-config/templates/com.wso2telco.dep.common.msisdnValidator.Template.xml @@ -36,10 +36,24 @@ - + + + + + + + + - + + + + + + + + diff --git a/pom.xml b/pom.xml index e1d964f..88aaca0 100644 --- a/pom.xml +++ b/pom.xml @@ -122,6 +122,11 @@ axis2 ${apache.axis2.wso2.version} + + com.wso2telco.dep + user-masking + ${com.wso2telco.dep.version} +