Skip to content

Commit

Permalink
code modularity checkin.
Browse files Browse the repository at this point in the history
  • Loading branch information
subwiz committed Jul 23, 2016
1 parent 5dbfb33 commit 346697c
Showing 1 changed file with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,33 +146,32 @@ private void loadFile() {
private static final String fmtChangeMsg = "Keystore seems to be in {0} format.\nWant to update the format to {0}?";
private static final String fmtChangeDialogTitle = "Change `Format' to {0}?";

private void storeTypeUsingDetectedExtn(KeyStoreType detectedType) {
if(jp_type.getSelectedKeyStoreType() != detectedType) {
final int result = JOptionPane.showConfirmDialog(this,
MessageFormat.format(fmtChangeMsg, detectedType),
MessageFormat.format(fmtChangeDialogTitle, detectedType),
JOptionPane.YES_NO_OPTION);
if(result == JOptionPane.YES_OPTION) {
jp_type.setSelectedKeyStoreType(detectedType);
}
}
}

private void loadFile(File f) {
if(f == null) {
// do nothing--cancel pressed
}
else if(f.canRead()) {
final String fileName = f.getName();
final String fileName = f.getName().toLowerCase();
if(fileName.endsWith(".p12") || fileName.endsWith(".pfx")) {
if(jp_type.getSelectedKeyStoreType() == JKS) {
final int result = JOptionPane.showConfirmDialog(this,
MessageFormat.format(fmtChangeMsg, PKCS12),
MessageFormat.format(fmtChangeDialogTitle, PKCS12),
JOptionPane.YES_NO_OPTION);
if(result == JOptionPane.YES_OPTION) {
jp_type.setSelectedKeyStoreType(PKCS12);
}
}
storeTypeUsingDetectedExtn(PKCS12);
}
else if(fileName.endsWith(".jks")) {
if(jp_type.getSelectedKeyStoreType() == PKCS12) {
final int result = JOptionPane.showConfirmDialog(this,
MessageFormat.format(fmtChangeMsg, JKS),
MessageFormat.format(fmtChangeDialogTitle, JKS),
JOptionPane.YES_NO_OPTION);
if(result == JOptionPane.YES_OPTION) {
jp_type.setSelectedKeyStoreType(JKS);
}
}
storeTypeUsingDetectedExtn(JKS);
}
else if(fileName.endsWith(".pem")) {
storeTypeUsingDetectedExtn(PEM);
}
jtf_file.setText(f.getAbsolutePath());
}
Expand Down

0 comments on commit 346697c

Please sign in to comment.