Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
import java.util.UUID;
import java.util.stream.Collectors;

import static io.mosip.kernel.biometrics.commons.CbeffValidator.validateXML;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.URL;
import io.mosip.kernel.biometrics.entities.BIR;
import io.mosip.kernel.cbeffutil.container.impl.CbeffContainerImpl;
import org.apache.commons.io.IOUtils;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;

import io.mosip.registration.processor.core.exception.PacketManagerNonRecoverableException;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
Expand Down Expand Up @@ -194,6 +205,12 @@ public class VerificationServiceImpl implements VerificationService {
/** The Constant PROTOCOL. */
public static final String PROTOCOL = "https";


@Value("${mosip.kernel.xsdstorage-uri}")
private String configServerFileStorageURL;

@Value("${mosip.kernel.xsdfile}")
private String schemaFileName;
/*
* This method will be called from the event bus passing messageDTO object
* containing rid Based o Rid fetch match reference Id and form request which is
Expand Down Expand Up @@ -528,7 +545,12 @@ private String getDataShareUrl(String id, String process) throws Exception {
List<String> modalities = getModalities(policy);
BiometricRecord biometricRecord = packetManagerService.getBiometrics(id, individualBiometricsLabel,
modalities, process, ProviderStageName.VERIFICATION);
byte[] content = cbeffutil.createXML(biometricRecord.getSegments());
//byte[] content = cbeffutil.createXML(biometricRecord.getSegments());
CbeffContainerImpl cbeffContainer = new CbeffContainerImpl();
//BIR bir = cbeffContainer.createBIRType(birList);
BIR bir = cbeffContainer.createBIRType(biometricRecord.getSegments());
InputStream xsd = new URL(configServerFileStorageURL + schemaFileName).openStream();
byte[] content =createXMLBytes(bir, IOUtils.toByteArray(xsd));
requestDto.setBiometrics(content != null ? CryptoUtil.encodeToURLSafeBase64(content) : null);
}

Expand Down Expand Up @@ -574,7 +596,18 @@ public String getFilename() {
LinkedHashMap datashare = (LinkedHashMap) response.get(DATASHARE);
return datashare.get(URL) != null ? datashare.get(URL).toString() : null;
}

public byte[] createXMLBytes(BIR bir, byte[] xsd) throws Exception {
validateXML(bir);
JAXBContext jaxbContext = JAXBContext.newInstance(new Class[]{BIR.class});
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty("jaxb.formatted.output", Boolean.TRUE);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(baos);
jaxbMarshaller.marshal(bir, writer);
byte[] savedData = baos.toByteArray();
writer.close();
return savedData;
}
private Map<String, String> getPolicyMap(LinkedHashMap<String, Object> policies) throws IOException {
Map<String, String> policyMap = new HashMap<>();
List<LinkedHashMap> attributes = (List<LinkedHashMap>) policies.get(VerificationConstants.SHAREABLE_ATTRIBUTES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void setListener(Message message) {

@Override
public void start() {
router.setRoute(this.postUrl(getVertx(), MessageBusAddress.MANUAL_ADJUDICATION_BUS_IN, MessageBusAddress.MANUAL_ADJUDICATION_BUS_OUT));
router.setRoute(this.postUrl(getVertx(), MessageBusAddress.VERIFICATION_BUS_IN, MessageBusAddress.VERIFICATION_BUS_OUT));
this.createServer(router.getRouter(), getPort());
}

Expand Down
Loading