Skip to content

Commit

Permalink
Merge pull request #1 from yaswanths2/BUG_MOSIP-10243
Browse files Browse the repository at this point in the history
Bug Fixes
  • Loading branch information
HimajaDhanyamraju2 committed Dec 2, 2020
2 parents 903e687 + 96ee579 commit db3963c
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ protected void generateAlert(Pane parentPane, String id, String context) {
if (!(label.isVisible() && id.equals(RegistrationConstants.DOB))) {
String[] split = context.split(type);
label.setText(split[0]);
label.setWrapText(true);
}

Tooltip tool = new Tooltip(context.contains(type) ? context.split(type)[0] : context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,22 @@ public void handle(WorkerStateEvent t) {
}
addBioStreamImage(currentSubType, currentModality,
registrationDTOBiometricsList.get(0).getNumOfRetries(), byteimage);

if (currentModality.equalsIgnoreCase(RegistrationConstants.IRIS_DOUBLE)
&& bioService.isMdmEnabled()) {

for (BiometricsDto biometricsDto : registrationDTOBiometricsList) {
byteimage = extractIrisImageData(biometricsDto.getAttributeISO());

if (byteimage != null) {
addRegistrationStreamImage(currentSubType,
biometricsDto.getBioAttribute(),
registrationDTOBiometricsList.get(0).getNumOfRetries(),
byteimage);
}
}
}

} catch (IOException exception) {
LOGGER.error(LOG_REG_BIOMETRIC_CONTROLLER, APPLICATION_NAME, APPLICATION_ID,
ExceptionUtils.getStackTrace(exception));
Expand Down Expand Up @@ -1950,22 +1966,26 @@ public void addBioStreamImage(String subType, String modality, int attempt, byte
String imagePath = getStubStreamImagePath(modality);
STREAM_IMAGES.put(String.format("%s_%s_%s", subType, modality, attempt),
new Image(this.getClass().getResourceAsStream(imagePath)));
if (getRegistrationDTOFromSession() != null) {
getRegistrationDTOFromSession().streamImages.put(
String.format("%s_%s_%s", subType,
isFace(modality) ? RegistrationConstants.FACE_FULLFACE : modality, attempt),
IOUtils.toByteArray(this.getClass().getResourceAsStream(imagePath)));
}

addRegistrationStreamImage(subType, isFace(modality) ? RegistrationConstants.FACE_FULLFACE : modality,
attempt, IOUtils.toByteArray(this.getClass().getResourceAsStream(imagePath)));

} else {
STREAM_IMAGES.put(String.format("%s_%s_%s", subType, modality, attempt),
new Image(new ByteArrayInputStream(streamImage)));
if (getRegistrationDTOFromSession() != null) {
getRegistrationDTOFromSession().streamImages.put(
String.format("%s_%s_%s", subType,
isFace(modality) ? RegistrationConstants.FACE_FULLFACE : modality, attempt),
streamImage);
}

addRegistrationStreamImage(subType, isFace(modality) ? RegistrationConstants.FACE_FULLFACE : modality,
attempt, streamImage);

}
}

private void addRegistrationStreamImage(String subType, String modality, int attempt, byte[] streamImage) {
if (getRegistrationDTOFromSession() != null) {
getRegistrationDTOFromSession().streamImages.put(String.format("%s_%s_%s", subType, modality, attempt),
streamImage);
}

}

public Image getBioStreamImage(String subType, String modality, int attempt) {
Expand Down Expand Up @@ -2673,6 +2693,80 @@ public byte[] extractFaceImageData(byte[] decodedBioValue) {
return null;
}

public byte[] extractIrisImageData(byte[] decodedBioValue) {

LOGGER.info(LOG_REG_BIOMETRIC_CONTROLLER, APPLICATION_NAME, APPLICATION_ID,
"Extracting iris image from decode bio value");

try (DataInputStream din = new DataInputStream(new ByteArrayInputStream(decodedBioValue))) {

// general header parsing
byte[] formatIdentifier = new byte[4];
din.read(formatIdentifier, 0, formatIdentifier.length);

LOGGER.info(LOG_REG_BIOMETRIC_CONTROLLER, APPLICATION_NAME, APPLICATION_ID,
"formatIdentifier >>>> " + new String(formatIdentifier));

int version = din.readInt();
int recordLength = din.readInt();
short noOfRepresentations = din.readShort();
byte certificationFlag = din.readByte();

// 1 -- left / right
// 2 -- both left and right
// 0 -- unknown
byte noOfIrisRepresented = din.readByte();

for (int i = 0; i < noOfRepresentations; i++) {
// Reading representation header
int representationLength = din.readInt();

byte[] captureDetails = new byte[14];
din.read(captureDetails, 0, captureDetails.length);

// qualityBlock
byte noOfQualityBlocks = din.readByte();
if (noOfQualityBlocks > 0) {
byte[] qualityBlocks = new byte[noOfQualityBlocks * 5];
din.read(qualityBlocks, 0, qualityBlocks.length);
}

short representationSequenceNo = din.readShort();

// 0 -- undefined
// 1 -- right
// 2 - left
byte eyeLabel = din.readByte();

byte imageType = din.readByte(); // cropped / uncropped

// 2 -- raw
// 10 -- jpeg2000
// 14 -- png
byte imageFormat = din.readByte();

byte[] otherDetails = new byte[24];
din.read(otherDetails, 0, otherDetails.length);

int imageLength = din.readInt();
byte[] image = new byte[imageLength];
din.read(image, 0, image.length);

ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(ImageIO.read(new ByteArrayInputStream(image)), "jpg", baos);

LOGGER.info(LOG_REG_BIOMETRIC_CONTROLLER, APPLICATION_NAME, APPLICATION_ID, "Converted JP2 to jpg");

return baos.toByteArray();
}
} catch (Exception exception) {
LOGGER.error(LOG_REG_BIOMETRIC_CONTROLLER, APPLICATION_NAME, APPLICATION_ID,
"Error while parsing iso to jpg : " + ExceptionUtils.getStackTrace(exception));

}
return null;
}

private Pane getExceptionImagePane(String modality) {

Pane exceptionImagePane = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ public void setLastUpdateTime() {
String latestUpdateTime = timestamps.stream().sorted((timestamp1, timestamp2) -> Timestamp
.valueOf(timestamp2).compareTo(Timestamp.valueOf(timestamp1))).findFirst().get();

lastSyncTime.setText(Timestamp.valueOf(latestUpdateTime).toLocalDateTime().format(
DateTimeFormatter.ofPattern(RegistrationConstants.ONBOARD_LAST_BIOMETRIC_UPDTAE_FORMAT)));
lastSyncTime.setText(Timestamp.valueOf(latestUpdateTime).toLocalDateTime()
.format(DateTimeFormatter.ofPattern(RegistrationConstants.ONBOARD_LAST_BIOMETRIC_UPDTAE_FORMAT))
+ RegistrationConstants.UTC_APPENDER);

setLastPreRegPacketDownloadedTime();
}
Expand Down Expand Up @@ -330,8 +331,8 @@ public void initialize(URL location, ResourceBundle resources) {
if (ts != null) {
DateTimeFormatter format = DateTimeFormatter
.ofPattern(RegistrationConstants.ONBOARD_LAST_BIOMETRIC_UPDTAE_FORMAT);
lastBiometricTime
.setText(RegistrationUIConstants.LAST_DOWNLOADED + " " + ts.toLocalDateTime().format(format));
lastBiometricTime.setText(RegistrationUIConstants.LAST_DOWNLOADED + " "
+ ts.toLocalDateTime().format(format) + RegistrationConstants.UTC_APPENDER);
}

if (!(getValueFromApplicationContext(RegistrationConstants.LOST_UIN_CONFIG_FLAG))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,15 +336,18 @@ private boolean languageSpecificValidation(Pane parentPane, TextField node, Stri
id.replaceAll(RegistrationConstants.ON_TYPE, RegistrationConstants.EMPTY)
.replaceAll(RegistrationConstants.LOCAL_LANGUAGE, RegistrationConstants.EMPTY),
RegistrationUIConstants.REGEX_TYPE);

boolean isBlackListed = false;
if (regex != null) {
if (inputText.matches(regex)) {
isInputValid = validateBlackListedWords(parentPane, node, id, blackListedWords, showAlert,
isBlackListed = validateBlackListedWords(parentPane, node, id, blackListedWords, showAlert,
String.format("%s %s %s",
messageBundle.getString(RegistrationConstants.BLACKLISTED_1),
getFromLabelMap(id),
messageBundle.getString(RegistrationConstants.BLACKLISTED_2)),
messageBundle.getString(RegistrationConstants.BLACKLISTED_ARE),
messageBundle.getString(RegistrationConstants.BLACKLISTED_IS));
isInputValid = isBlackListed;
} else {
isInputValid = false;
}
Expand All @@ -354,10 +357,13 @@ private boolean languageSpecificValidation(Pane parentPane, TextField node, Stri
}

if (!isInputValid) {
generateInvalidValueAlert(parentPane, node.getId(),
getFromLabelMap(label).concat(RegistrationConstants.SPACE)
.concat(messageBundle.getString(RegistrationConstants.REG_DDC_004)),
showAlert);

if (isBlackListed) {
generateInvalidValueAlert(
parentPane, node.getId(), getFromLabelMap(label).concat(RegistrationConstants.SPACE)
.concat(messageBundle.getString(RegistrationConstants.REG_DDC_004)),
showAlert);
}
if (isPreviousValid && !id.contains(RegistrationConstants.ON_TYPE)) {
addInvalidInputStyleClass(parentPane, node, false);
}
Expand All @@ -378,7 +384,8 @@ private boolean languageSpecificValidation(Pane parentPane, TextField node, Stri

private void addValidInputStyleClass(Pane parentPane, TextField node) {
Label nodeLabel = (Label) parentPane.lookup("#" + node.getId() + "Label");
if (nodeLabel == null && parentPane.getParent() != null && parentPane.getParent().getParent() != null && parentPane.getParent().getParent().getParent() != null) {
if (nodeLabel == null && parentPane.getParent() != null && parentPane.getParent().getParent() != null
&& parentPane.getParent().getParent().getParent() != null) {
nodeLabel = (Label) parentPane.getParent().getParent().getParent().lookup("#" + node.getId() + "Label");
}
// node.requestFocus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ private RegistrationConstants() {
public static final String TEMPLATE_PHOTO_USER_LANG = "PhotoPrim";
public static final String TEMPLATE_PHOTO_LOCAL_LANG = "PhotoSec";
public static final String TEMPLATE_APPLICANT_IMAGE_SOURCE = "ApplicantImageSource";
public static final String TEMPLATE_DATE_FORMAT = "dd/MM/yyyy";
public static final String TEMPLATE_DATE_FORMAT = "dd/MM/yyyy hh:mm a";
public static final String TEMPLATE_JPG_IMAGE_ENCODING = "data:image/jpg;base64,";
public static final String TEMPLATE_PNG_IMAGE_ENCODING = "data:image/png;base64,";
public static final String TEMPLATE_CROSS_MARK = "&#10008;";
Expand Down Expand Up @@ -1811,4 +1811,7 @@ public static List<String> fieldsToExclude() {
// UI Schema field group name
public static final String UI_SCHEMA_GROUP_FULL_NAME = "FullName";
public static final String MVEL_TYPE = "MVEL";

public static final String UTC_APPENDER = " (UTC)";

}
Loading

0 comments on commit db3963c

Please sign in to comment.