5656import com .iemr .common .repository .callhandling .BeneficiaryCallRepository ;
5757import com .iemr .common .repository .callhandling .IEMRCalltypeRepositoryImplCustom ;
5858import com .iemr .common .utils .config .ConfigProperties ;
59+ import com .iemr .common .utils .encryption .AESUtil ;
5960import com .iemr .common .utils .exception .IEMRException ;
6061import com .iemr .common .utils .http .HttpUtils ;
6162import com .iemr .common .utils .mapper .InputMapper ;
@@ -81,6 +82,10 @@ public class CTIServiceImpl implements CTIService {
8182 private static final String CUSTOM_API_FAILURE = "0" ;
8283
8384 private static final String DEFAULT_IP = "0.0.0.0" ;
85+
86+ @ Autowired
87+ private AESUtil aesUtil ;
88+
8489
8590 @ Autowired
8691 private BeneficiaryCallRepository beneficiaryCallRepository ;
@@ -290,9 +295,16 @@ public OutputResponse getLoginKey(String request, String ipAddress) throws IEMRE
290295 String serverURL = ConfigProperties .getPropertyByName ("cti-server-ip" );
291296 AgentLoginKey agentState = objectMapper .readValue (request , AgentLoginKey .class );
292297
298+ String decryptPassword = null ;
299+
300+ String passphrase = ConfigProperties .getPropertyByName ("encryption.passphrase" );
301+
302+ decryptPassword = aesUtil .decrypt (passphrase , agentState .getPassword ());
303+
304+
293305 ctiURI = ctiURI .replace ("CTI_SERVER" , serverURL );
294306 ctiURI = ctiURI .replace ("USERNAME" , (agentState .getUsername () != null ) ? agentState .getUsername () : "" );
295- ctiURI = ctiURI .replace ("PASSWORD" , (agentState . getPassword () != null ) ? agentState . getPassword () : "" );
307+ ctiURI = ctiURI .replace ("PASSWORD" , (decryptPassword != null ) ? decryptPassword : "" );
296308 logger .info ("calling URL " + ctiURI );
297309 ctiURI = ctiURI .replace ("AGENT_IP" , ipAddress );
298310 String response = this .callUrl (ctiURI );// httpUtils.get(ctiURI);
0 commit comments