diff --git a/product/modules/agents/windows/jax-rs/src/main/java/cdm/api/windows/impl/DiscoveryServiceImpl.java b/product/modules/agents/windows/jax-rs/src/main/java/cdm/api/windows/impl/DiscoveryServiceImpl.java index 01ef564609c..59de66ae0f9 100644 --- a/product/modules/agents/windows/jax-rs/src/main/java/cdm/api/windows/impl/DiscoveryServiceImpl.java +++ b/product/modules/agents/windows/jax-rs/src/main/java/cdm/api/windows/impl/DiscoveryServiceImpl.java @@ -21,24 +21,35 @@ package cdm.api.windows.impl; import cdm.api.windows.DiscoveryService; import javax.ws.rs.core.Response; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Paths; + import org.apache.log4j.Logger; public class DiscoveryServiceImpl implements DiscoveryService { private Logger LOGGER = Logger.getLogger(DiscoveryServiceImpl.class); - private String discoveryServiceFileName; public Response getDiscoveryResponse(InputStream discoveryRequest) { LOGGER.info("Received Discovery Service POST Request [{}]"); String response = null; + File file = null; + FileInputStream fis = null; + byte[] data = null; + try { - response = new String(Files.readAllBytes(Paths.get(discoveryServiceFileName))); + + file = new File("./conf/discover-service.xml"); + fis = new FileInputStream(file); + data = new byte[(int) file.length()]; + fis.read(data); + fis.close(); + response = new String(data, "UTF-8"); + } catch (IOException e) { LOGGER.error("An Unexpected Error has occurred while processing the request ", e); } @@ -57,8 +68,5 @@ public class DiscoveryServiceImpl implements DiscoveryService { return Response.ok().build(); } - public void setDiscoveryServiceFileName(String discoveryServiceFileName) { - this.discoveryServiceFileName = discoveryServiceFileName; - } } diff --git a/product/modules/agents/windows/jax-rs/src/main/java/cdm/api/windows/impl/EnrolmentServiceImpl.java b/product/modules/agents/windows/jax-rs/src/main/java/cdm/api/windows/impl/EnrolmentServiceImpl.java index 71b797efeca..c3acde83871 100644 --- a/product/modules/agents/windows/jax-rs/src/main/java/cdm/api/windows/impl/EnrolmentServiceImpl.java +++ b/product/modules/agents/windows/jax-rs/src/main/java/cdm/api/windows/impl/EnrolmentServiceImpl.java @@ -40,11 +40,10 @@ import javax.xml.transform.stream.StreamResult; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathFactory; +import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.StringWriter; -import java.nio.file.Files; -import java.nio.file.Paths; import java.security.KeyFactory; import java.security.PrivateKey; import java.security.Security; @@ -65,8 +64,6 @@ public class EnrolmentServiceImpl implements EnrolmentService { private String enrollmentResponseFile; - private String responseFile; - private String wapProvisioningXmlFile; private String privatePemKeyFilePath; @@ -156,9 +153,21 @@ public class EnrolmentServiceImpl implements EnrolmentService { public Response getPolicies(Document request) { LOGGER.info("Received Get Policies Request"); + String response = null; + File file = null; + FileInputStream fis = null; + byte[] data = null; + try { - response = new String(Files.readAllBytes(Paths.get(responseFile))); + + file = new File("./conf/policy-service.xml"); + fis = new FileInputStream(file); + data = new byte[(int) file.length()]; + fis.read(data); + fis.close(); + response = new String(data, "UTF-8"); + } catch (IOException e) { LOGGER.error("An Unexpected Error has occurred while processing the request ", e); } @@ -250,10 +259,6 @@ public class EnrolmentServiceImpl implements EnrolmentService { this.enrollmentResponseFile = enrollmentResponseFile; } - public void setResponseFile(String responseFile) { - this.responseFile = responseFile; - } - public void setWapProvisioningXmlFile(String wapProvisioningXmlFile) { this.wapProvisioningXmlFile = wapProvisioningXmlFile; }