Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Sohandey committed Jul 27, 2023
2 parents fca3e91 + 7b36aee commit 1645b94
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
8 changes: 4 additions & 4 deletions authentication-demo-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<maven.jacoco.version>0.8.2</maven.jacoco.version>
<sonar.skip>true</sonar.skip>

<kernel-websubclient-api.version>1.2.0.1-B1</kernel-websubclient-api.version>
<kernel-websubclient-api.version>1.2.0.1-SNAPSHOT</kernel-websubclient-api.version>

</properties>

Expand Down Expand Up @@ -116,7 +116,7 @@
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-core</artifactId>
<version>1.2.0.1-B1</version>
<version>1.2.0.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -201,7 +201,7 @@
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-templatemanager-velocity</artifactId>
<version>1.2.0.1-B1</version>
<version>1.2.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
Expand All @@ -226,7 +226,7 @@
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-keymanager-service</artifactId>
<version>1.2.0.1-B2</version>
<version>1.2.0.1-SNAPSHOT</version>
<classifier>lib</classifier>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,12 +477,13 @@ public String decryptEkycData(
@PostMapping(path = "/decryptWithPartnerKey", produces = MediaType.TEXT_PLAIN_VALUE)
public String decryptWithPartnerKey(
@RequestBody String data,
@RequestParam(name = "partnerType", required = true) PartnerTypes partnerType,
@RequestParam(name = "partnerName", required = false) String partnerName,
@RequestParam(name = "keyFileNameByPartnerName", required = false) boolean keyFileNameByPartnerName,
@RequestParam(name = "certsDir", required = false) String certsDir,
@RequestParam(name = "moduleName", required = false) String moduleName
) throws Exception {
PrivateKeyEntry ekycKey = keyMgrUtil.getKeyEntry(keyMgrUtil.getKeysDirPath(certsDir, moduleName), PartnerTypes.EKYC, partnerName, keyFileNameByPartnerName);
PrivateKeyEntry ekycKey = keyMgrUtil.getKeyEntry(keyMgrUtil.getKeysDirPath(certsDir, moduleName), partnerType, partnerName, keyFileNameByPartnerName);
return cryptoCoreUtil.decrypt(data, ekycKey);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private PrivateKeyEntry getPrivateKeyEntry(String filePath) throws NoSuchAlgorit
KeyStore keyStore = KeyStore.getInstance(KEY_STORE);
try(InputStream p12FileStream = new FileInputStream(filePath);) {
keyStore.load(p12FileStream, getP12Pass());
return (PrivateKeyEntry) keyStore.getEntry(KEY_ALIAS, new PasswordProtection (getP12Pass()));
return (PrivateKeyEntry) keyStore.getEntry(getKeyAlias(), new PasswordProtection (getP12Pass()));
}
}
return null;
Expand Down Expand Up @@ -208,7 +208,7 @@ private PrivateKeyEntry generateKeys(PrivateKey signKey, String signCertType, St

KeyStore keyStore = KeyStore.getInstance(KEY_STORE);
keyStore.load(null, getP12Pass());
keyStore.setEntry(KEY_ALIAS, privateKeyEntry, new PasswordProtection (getP12Pass()));
keyStore.setEntry(getKeyAlias(), privateKeyEntry, new PasswordProtection (getP12Pass()));
Path parentPath = Paths.get(p12FilePath).getParent();
if (parentPath != null && !Files.exists(parentPath)) {
Files.createDirectories(parentPath);
Expand Down Expand Up @@ -368,7 +368,7 @@ public boolean updatePartnerCertificate(String partnerType, X509Certificate upda

KeyStore keyStore = KeyStore.getInstance(KEY_STORE);
keyStore.load(null, getP12Pass());
keyStore.setEntry(KEY_ALIAS, newPrivateKeyEntry, new PasswordProtection (getP12Pass()));
keyStore.setEntry(getKeyAlias(), newPrivateKeyEntry, new PasswordProtection (getP12Pass()));

OutputStream outputStream = new FileOutputStream(partnerFilePath);
keyStore.store(outputStream, getP12Pass());
Expand All @@ -379,6 +379,10 @@ public boolean updatePartnerCertificate(String partnerType, X509Certificate upda
return false;
}

private String getKeyAlias() {
return environment.getProperty("p12.key.alias", KEY_ALIAS);
}


public String getKeysDirPath(String certsDir, String moduleName) {
String domain = environment.getProperty(DOMAIN_URL, "localhost").replace("https://", "").replace("http://", "").replace("/", "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,3 +578,4 @@ mosip.iris.provider=ai.tech5.auth.service.T5AuthIrisImpl
#openapi properties to sort tag and operations of id-authentication services
springdoc.swagger-ui.tagsSorter=alpha
springdoc.swagger-ui.operationsSorter=alpha
p12.key.alias=keyalias

0 comments on commit 1645b94

Please sign in to comment.