Skip to content

Commit

Permalink
Merge pull request #1618 from mohanachandran-s/develop
Browse files Browse the repository at this point in the history
MOSIP-35886 - Modified the injection of Auth Demo Service utils
  • Loading branch information
lsivanand authored Sep 24, 2024
2 parents cee32c6 + de0f1af commit 642da28
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.apache.commons.codec.binary.Hex;
import org.apache.log4j.Logger;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import io.mosip.kernel.core.util.CryptoUtil;
Expand All @@ -34,8 +33,7 @@ public class BioDataUtility extends AdminTestUtil {

private static final Logger logger = Logger.getLogger(BioDataUtility.class);

@Autowired
private Encrypt encrypt;
private Encrypt encrypt = new Encrypt();


private String encryptIsoBioValue(String isoBiovalue, String timestamp, String bioValueEncryptionTemplateJson,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,11 @@ public class CryptoCore implements CryptoCoreSpec<byte[], byte[], SecretKey, Pub

private static final String AES = "AES";

@Value("${mosip.kernel.crypto.gcm-tag-length:128}")
private int tagLength;
private final int tagLength = 128;

@Value("${mosip.automation.crypto.symmetric-algorithm-name:AES/GCM/NoPadding}")
private String symmetricAlgorithm;
private final String symmetricAlgorithm = "AES/GCM/NoPadding";

@Value("${mosip.kernel.crypto.asymmetric-algorithm-name:RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING}")
private String asymmetricAlgorithm;
private final String asymmetricAlgorithm = "RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING";

@Value("${mosip.kernel.crypto.hash-algorithm-name:PBKDF2WithHmacSHA512}")
private String passwordAlgorithm;
Expand All @@ -117,12 +114,7 @@ public class CryptoCore implements CryptoCoreSpec<byte[], byte[], SecretKey, Pub
@Value("${mosip.kernel.keymanager.hsm.keystore-type:PKCS11}")
private String keystoreType;

private SecureRandom secureRandom;

@PostConstruct
public void init() {
secureRandom = new SecureRandom();
}
private SecureRandom secureRandom = new SecureRandom();

@Override
public byte[] symmetricEncrypt(SecretKey key, byte[] data, byte[] aad) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.mosip.kernel.core.crypto.spi.CryptoCoreSpec;

import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.crypto.*;
Expand Down Expand Up @@ -35,8 +34,7 @@ public class CryptoUtil {
/**
* {@link CryptoCoreSpec} instance for cryptographic functionalities.
*/
@Autowired
private CryptoCore cryptoCore;
private CryptoCore cryptoCore = new CryptoCore();



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.log4j.Logger;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.testng.Reporter;

Expand Down Expand Up @@ -52,12 +51,8 @@ public class EncryptionDecrptionUtil extends AdminTestUtil{
public static String internalThumbPrint =null;
public static String idaFirThumbPrint =null;
private static ObjectMapper objMapper = new ObjectMapper();
@Autowired
private CryptoUtil cryptoUtil;
@Autowired
private KeyMgrUtil keymgrUtil;
@Autowired
private Encrypt encrypt;
private static CryptoUtil cryptoUtil = new CryptoUtil();
private static KeyMgrUtil keymgrUtil = new KeyMgrUtil();

static {
getThumbprints();
Expand Down Expand Up @@ -130,7 +125,7 @@ public Map<String, String> getInternalEncryptSessionKeyValue(String jsonString)
*/


public EncryptionResponseDto encrypt(String jsonString) throws Exception {
public static EncryptionResponseDto encrypt(String jsonString) throws Exception {

String refId= null;
boolean isInternal = false;
Expand Down Expand Up @@ -160,7 +155,7 @@ private static String getRefId(boolean isInternal, boolean isBiometrics) {
return refId;
}

private EncryptionResponseDto kernelEncrypt(String identityBlock, String refId) throws Exception {
private static EncryptionResponseDto kernelEncrypt(String identityBlock, String refId) throws Exception {
// String identityBlock = objMapper.writeValueAsString(jsonString);
SecretKey secretKey = cryptoUtil.genSecKey();
EncryptionResponseDto encryptionResponseDto = new EncryptionResponseDto();
Expand Down

0 comments on commit 642da28

Please sign in to comment.