Skip to content

Commit

Permalink
Removed obsolete "Cryptography Strength" dialog; minor code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikramer committed Jan 6, 2024
1 parent 8e67d6e commit 864d674
Show file tree
Hide file tree
Showing 17 changed files with 25 additions and 385 deletions.
10 changes: 0 additions & 10 deletions kse/src/main/java/org/kse/gui/KseFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
import org.kse.gui.actions.CopyAction;
import org.kse.gui.actions.CopyKeyPairAction;
import org.kse.gui.actions.CopyTrustedCertificateAction;
import org.kse.gui.actions.CryptographyStrengthAction;
import org.kse.gui.actions.CutAction;
import org.kse.gui.actions.CutKeyPairAction;
import org.kse.gui.actions.CutTrustedCertificateAction;
Expand Down Expand Up @@ -470,7 +469,6 @@ public final class KseFrame implements StatusBar {
private final CheckUpdateAction checkUpdateAction = new CheckUpdateAction(this);
private final SecurityProvidersAction securityProvidersAction = new SecurityProvidersAction(this);
private final SystemInformationAction systemInformationAction = new SystemInformationAction(this);
private final CryptographyStrengthAction cryptographyStrengthAction = new CryptographyStrengthAction(this);
private final JarsAction jarsAction = new JarsAction(this);
private final AboutAction aboutAction = new AboutAction(this);
private final KeyPairCertificateChainDetailsAction keyPairCertificateChainDetailsAction =
Expand Down Expand Up @@ -1073,14 +1071,6 @@ private void initMenu() {
(String) securityProvidersAction.getValue(Action.LONG_DESCRIPTION), this);
jmHelp.add(jmiSecurityProviders);

jmiCryptographyStrength = new JMenuItem(cryptographyStrengthAction);
PlatformUtil.setMnemonic(jmiCryptographyStrength,
res.getString("KseFrame.jmiCryptographyStrength.mnemonic").charAt(0));
jmiCryptographyStrength.setToolTipText(null);
new StatusBarChangeHandler(jmiCryptographyStrength,
(String) cryptographyStrengthAction.getValue(Action.LONG_DESCRIPTION), this);
jmHelp.add(jmiCryptographyStrength);

jmiJars = new JMenuItem(jarsAction);
PlatformUtil.setMnemonic(jmiJars, res.getString("KseFrame.jmiJars.mnemonic").charAt(0));
jmiJars.setToolTipText(null);
Expand Down
4 changes: 1 addition & 3 deletions kse/src/main/java/org/kse/gui/actions/CloseAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ public boolean closeKeyStore(KeyStoreHistory history) {

private boolean needSave(KeyStoreState state) {
if (state != null) {
if (!state.isSavedState() && !state.isInitialState()) {
return true;
}
return !state.isSavedState() && !state.isInitialState();
}
return false;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ protected void doAction() {

CryptoFileType fileType = CryptoFileUtil.detectFileType(detectTypeFile);

String message = null;

String message;
if (fileType != null) {
message = MessageFormat.format(res.getString("DetectFileTypeAction.DetectedFileType.message"),
detectTypeFile.getName(), fileType.friendly());
Expand Down
33 changes: 16 additions & 17 deletions kse/src/main/java/org/kse/gui/actions/ExamineClipboardAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
*/
public class ExamineClipboardAction extends KeyStoreExplorerAction {

private static ResourceBundle resExt = ResourceBundle.getBundle("org/kse/gui/dialogs/extensions/resources");
private static final ResourceBundle resExt = ResourceBundle.getBundle("org/kse/gui/dialogs/extensions/resources");

private static final long serialVersionUID = -4374420674229658652L;

Expand Down Expand Up @@ -211,23 +211,22 @@ private static byte[] decodeIfBase64(String data) {
}

private boolean isRedirect(int status) {
// normally, 3xx is redirect
if (status != HttpURLConnection.HTTP_OK) {
if (status == HttpURLConnection.HTTP_MOVED_TEMP || status == HttpURLConnection.HTTP_MOVED_PERM
|| status == HttpURLConnection.HTTP_SEE_OTHER)
return true;
}
return false;
// normally, 3xx is redirect
if (status != HttpURLConnection.HTTP_OK) {
return status == HttpURLConnection.HTTP_MOVED_TEMP || status == HttpURLConnection.HTTP_MOVED_PERM ||
status == HttpURLConnection.HTTP_SEE_OTHER;
}
return false;
}

private void downloadCrl(URL url) throws IOException, CryptoException {
HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
int status = urlConn.getResponseCode();
if (isRedirect(status)) {
String newUrl = urlConn.getHeaderField("Location");
url = new URL(newUrl);
urlConn = (HttpURLConnection) url.openConnection();
}
HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
int status = urlConn.getResponseCode();
if (isRedirect(status)) {
String newUrl = urlConn.getHeaderField("Location");
url = new URL(newUrl);
urlConn = (HttpURLConnection) url.openConnection();
}
try (InputStream is = urlConn.getInputStream()) {
X509CRL crl = X509CertUtil.loadCRL(IOUtils.toByteArray(is));
if (crl != null) {
Expand Down Expand Up @@ -262,7 +261,7 @@ private void downloadCert(URL url) throws IOException, CryptoException {

private void showPrivateKey(byte[] data, CryptoFileType fileType) throws IOException, CryptoException {
PrivateKey privKey = null;
Password password = null;
Password password;
PrivateKeyFormat format = null;

switch (fileType) {
Expand Down Expand Up @@ -320,7 +319,7 @@ private Password getPassword() {
return dGetPassword.getPassword();
}

private void showPublicKey(byte[] data) throws IOException, CryptoException {
private void showPublicKey(byte[] data) throws CryptoException {
PublicKey publicKey = OpenSslPubUtil.load(data);

DViewPublicKey dViewPublicKey = new DViewPublicKey(frame, res.getString(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ protected void doAction() {

/**
* Generate DH Parameters in the currently opened KeyStore.
*
* @return Does not return any value
*/
public void generateDHParameters() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
public class GenerateKeyPairAction extends KeyStoreExplorerAction implements HistoryAction {
private static final long serialVersionUID = 1L;

private KseFrame kseFrame;
private final KseFrame kseFrame;
/**
* Construct action.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
*/
public class ImportTrustedCertificateAction extends AuthorityCertificatesAction implements HistoryAction {
private static final long serialVersionUID = 1L;
private X509Certificate trustCertFromConstructor;
private final X509Certificate trustCertFromConstructor;
private File certFile;

/**
Expand Down
2 changes: 1 addition & 1 deletion kse/src/main/java/org/kse/gui/actions/OpenAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void openKeyStore(File keyStoreFile, String defaultPassword) {
// use (optional) default password for first try
Password password = (defaultPassword != null) ? new Password(defaultPassword.toCharArray()) : null;

KeyStore openedKeyStore = null;
KeyStore openedKeyStore;
boolean firstTry = true;
while (true) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
public class PreferencesAction extends ExitAction {
private static final long serialVersionUID = 1L;
private KseFrame kseFrame;
private final KseFrame kseFrame;

/**
* Construct action.
Expand Down
2 changes: 1 addition & 1 deletion kse/src/main/java/org/kse/gui/actions/RedoAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
public class RedoAction extends KeyStoreExplorerAction {
private static final long serialVersionUID = 1L;
private String defaultName;
private final String defaultName;

/**
* Construct action.
Expand Down
2 changes: 1 addition & 1 deletion kse/src/main/java/org/kse/gui/actions/UndoAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
public class UndoAction extends KeyStoreExplorerAction {
private static final long serialVersionUID = 1L;
private String defaultName;
private final String defaultName;

/**
* Construct action.
Expand Down
Loading

0 comments on commit 864d674

Please sign in to comment.