-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: display certificate information in help
- Loading branch information
Showing
3 changed files
with
104 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.tivo.kmttg.util; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.security.KeyStore; | ||
import java.security.KeyStoreException; | ||
import java.security.NoSuchAlgorithmException; | ||
import java.security.cert.CertificateException; | ||
import java.util.Scanner; | ||
|
||
public class GetKeyStore { | ||
private String keyPassword; | ||
private KeyStore keyStore; | ||
public GetKeyStore(String cdata, String programDir) | ||
throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException | ||
{ | ||
keyStore = KeyStore.getInstance("PKCS12"); | ||
// This is default USA password | ||
keyPassword = "KllX3KygL9"; // expires 1/24/2026 | ||
//String password = "vlZaKoduom"; // expires 5/3/2024 | ||
InputStream keyInput; | ||
if (cdata == null) { | ||
// Installation dir cdata.p12 file takes priority if it exists | ||
cdata = programDir + "/cdata.p12"; | ||
if ( new File(cdata).isFile() ) { | ||
keyInput = new FileInputStream(cdata); | ||
cdata = programDir + "/cdata.password"; | ||
if (new File(cdata).isFile()) { | ||
Scanner s = new Scanner(new File(cdata)); | ||
keyPassword = s.useDelimiter("\\A").next(); | ||
s.close(); | ||
} else { | ||
System.out.println("cdata.p12 file present, but cdata.password is not"); | ||
} | ||
} else { | ||
// Read default USA cdata.p12 from kmttg.jar | ||
keyInput = getClass().getResourceAsStream("/cdata.p12"); | ||
} | ||
} | ||
else | ||
keyInput = new FileInputStream(cdata); | ||
keyStore.load(keyInput, keyPassword.toCharArray()); | ||
keyInput.close(); | ||
} | ||
public KeyStore getKeyStore() { | ||
return keyStore; | ||
} | ||
|
||
public String getKeyPassword() { | ||
return keyPassword; | ||
} | ||
|
||
} |