merge-requests/1/head
Geeth Munasinghe 10 years ago
commit 172ab10ac0

@ -21,24 +21,35 @@ package cdm.api.windows.impl;
import cdm.api.windows.DiscoveryService; import cdm.api.windows.DiscoveryService;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
public class DiscoveryServiceImpl implements DiscoveryService { public class DiscoveryServiceImpl implements DiscoveryService {
private Logger LOGGER = Logger.getLogger(DiscoveryServiceImpl.class); private Logger LOGGER = Logger.getLogger(DiscoveryServiceImpl.class);
private String discoveryServiceFileName;
public Response getDiscoveryResponse(InputStream discoveryRequest) { public Response getDiscoveryResponse(InputStream discoveryRequest) {
LOGGER.info("Received Discovery Service POST Request [{}]"); LOGGER.info("Received Discovery Service POST Request [{}]");
String response = null; String response = null;
File file = null;
FileInputStream fis = null;
byte[] data = null;
try { 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) { } catch (IOException e) {
LOGGER.error("An Unexpected Error has occurred while processing the request ", 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(); return Response.ok().build();
} }
public void setDiscoveryServiceFileName(String discoveryServiceFileName) {
this.discoveryServiceFileName = discoveryServiceFileName;
}
} }

@ -40,11 +40,10 @@ import javax.xml.transform.stream.StreamResult;
import javax.xml.xpath.XPath; import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory; import javax.xml.xpath.XPathFactory;
import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.StringWriter; import java.io.StringWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.KeyFactory; import java.security.KeyFactory;
import java.security.PrivateKey; import java.security.PrivateKey;
import java.security.Security; import java.security.Security;
@ -65,8 +64,6 @@ public class EnrolmentServiceImpl implements EnrolmentService {
private String enrollmentResponseFile; private String enrollmentResponseFile;
private String responseFile;
private String wapProvisioningXmlFile; private String wapProvisioningXmlFile;
private String privatePemKeyFilePath; private String privatePemKeyFilePath;
@ -156,9 +153,21 @@ public class EnrolmentServiceImpl implements EnrolmentService {
public Response getPolicies(Document request) { public Response getPolicies(Document request) {
LOGGER.info("Received Get Policies Request"); LOGGER.info("Received Get Policies Request");
String response = null; String response = null;
File file = null;
FileInputStream fis = null;
byte[] data = null;
try { 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) { } catch (IOException e) {
LOGGER.error("An Unexpected Error has occurred while processing the request ", 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; this.enrollmentResponseFile = enrollmentResponseFile;
} }
public void setResponseFile(String responseFile) {
this.responseFile = responseFile;
}
public void setWapProvisioningXmlFile(String wapProvisioningXmlFile) { public void setWapProvisioningXmlFile(String wapProvisioningXmlFile) {
this.wapProvisioningXmlFile = wapProvisioningXmlFile; this.wapProvisioningXmlFile = wapProvisioningXmlFile;
} }

Loading…
Cancel
Save