changeset 537:09c91b85a1a7

Use interface types in JCV classes where applicable
author Adam Domurad <adomurad@redhat.com>
date Fri, 19 Oct 2012 14:34:16 -0400
parents 274ff243ba73
children 8eb44f9dc27c
files ChangeLog netx/net/sourceforge/jnlp/security/AppVerifier.java netx/net/sourceforge/jnlp/security/JNLPAppVerifier.java netx/net/sourceforge/jnlp/security/PluginAppVerifier.java netx/net/sourceforge/jnlp/tools/JarCertVerifier.java
diffstat 5 files changed, 40 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Oct 22 11:02:38 2012 -0400
+++ b/ChangeLog	Fri Oct 19 14:34:16 2012 -0400
@@ -35,6 +35,13 @@
 	* netx/net/sourceforge/jnlp/security/PluginAppVerifier.java: Same.
 	* netx/net/sourceforge/jnlp/tools/JarCertVerifier.java: Same.
 
+2012-10-19  Adam Domurad  <adomurad@redhat.com>
+
+	* netx/net/sourceforge/jnlp/security/AppVerifier.java: Use interface 
+	types for declared types where applicable.
+	* netx/net/sourceforge/jnlp/security/PluginAppVerifier.java: Same.
+	* netx/net/sourceforge/jnlp/tools/JarCertVerifier.java: Same.
+
 2012-10-19  Danesh Dadachanji  <ddadacha@redhat.com>
 
 	Rework JarCertVerifier certificate management to handle multiple
--- a/netx/net/sourceforge/jnlp/security/AppVerifier.java	Mon Oct 22 11:02:38 2012 -0400
+++ b/netx/net/sourceforge/jnlp/security/AppVerifier.java	Fri Oct 19 14:34:16 2012 -0400
@@ -38,7 +38,7 @@
 package net.sourceforge.jnlp.security;
 
 import java.security.cert.CertPath;
-import java.util.HashMap;
+import java.util.Map;
 
 import net.sourceforge.jnlp.JNLPFile;
 import net.sourceforge.jnlp.LaunchException;
@@ -58,8 +58,8 @@
      * @return True if the app trusts its publishers.
      */
     public boolean hasAlreadyTrustedPublisher(
-            HashMap<CertPath, CertInformation> certs,
-            HashMap<String, Integer> signedJars);
+            Map<CertPath, CertInformation> certs,
+            Map<String, Integer> signedJars);
 
     /**
      * Checks if the app has signer(s) whose certs along their chains are in CA certs.
@@ -68,8 +68,8 @@
      * signed entries each one has.
      * @return True if the app has a root in the CA certs store.
      */
-    public boolean hasRootInCacerts(HashMap<CertPath, CertInformation> certs,
-            HashMap<String, Integer> signedJars);
+    public boolean hasRootInCacerts(Map<CertPath, CertInformation> certs,
+            Map<String, Integer> signedJars);
 
     /**
      * Checks if the app's jars are covered by the provided certificates, enough
@@ -79,8 +79,8 @@
      * signed entries each one has.
      * @return
      */
-    public boolean isFullySigned(HashMap<CertPath, CertInformation> certs,
-            HashMap<String, Integer> signedJars);
+    public boolean isFullySigned(Map<CertPath, CertInformation> certs,
+            Map<String, Integer> signedJars);
 
     /**
      * Prompt the user with requests for trusting the certificates used by this app
--- a/netx/net/sourceforge/jnlp/security/JNLPAppVerifier.java	Mon Oct 22 11:02:38 2012 -0400
+++ b/netx/net/sourceforge/jnlp/security/JNLPAppVerifier.java	Fri Oct 19 14:34:16 2012 -0400
@@ -40,7 +40,6 @@
 import static net.sourceforge.jnlp.runtime.Translator.R;
 
 import java.security.cert.CertPath;
-import java.util.HashMap;
 import java.util.Map;
 
 import net.sourceforge.jnlp.JNLPFile;
@@ -53,8 +52,8 @@
 
     @Override
     public boolean hasAlreadyTrustedPublisher(
-            HashMap<CertPath, CertInformation> certs,
-            HashMap<String, Integer> signedJars) {
+            Map<CertPath, CertInformation> certs,
+            Map<String, Integer> signedJars) {
         int sumOfSignableEntries = JarCertVerifier.getTotalJarEntries(signedJars);
         for (CertInformation certInfo : certs.values()) {
             Map<String, Integer> certSignedJars = certInfo.getSignedJars();
@@ -68,8 +67,8 @@
     }
 
     @Override
-    public boolean hasRootInCacerts(HashMap<CertPath, CertInformation> certs,
-            HashMap<String, Integer> signedJars) {
+    public boolean hasRootInCacerts(Map<CertPath, CertInformation> certs,
+            Map<String, Integer> signedJars) {
         int sumOfSignableEntries = JarCertVerifier.getTotalJarEntries(signedJars);
         for (CertInformation certInfo : certs.values()) {
             Map<String, Integer> certSignedJars = certInfo.getSignedJars();
@@ -83,8 +82,8 @@
     }
 
     @Override
-    public boolean isFullySigned(HashMap<CertPath, CertInformation> certs,
-            HashMap<String, Integer> signedJars) {
+    public boolean isFullySigned(Map<CertPath, CertInformation> certs,
+            Map<String, Integer> signedJars) {
         int sumOfSignableEntries = JarCertVerifier.getTotalJarEntries(signedJars);
         for (CertPath cPath : certs.keySet()) {
             // If this cert has signed everything, return true
--- a/netx/net/sourceforge/jnlp/security/PluginAppVerifier.java	Mon Oct 22 11:02:38 2012 -0400
+++ b/netx/net/sourceforge/jnlp/security/PluginAppVerifier.java	Fri Oct 19 14:34:16 2012 -0400
@@ -41,7 +41,8 @@
 
 import java.security.cert.CertPath;
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 import net.sourceforge.jnlp.JNLPFile;
 import net.sourceforge.jnlp.LaunchException;
@@ -53,8 +54,8 @@
 
     @Override
     public boolean hasAlreadyTrustedPublisher(
-            HashMap<CertPath, CertInformation> certs,
-            HashMap<String, Integer> signedJars) {
+            Map<CertPath, CertInformation> certs,
+            Map<String, Integer> signedJars) {
 
         boolean allPublishersTrusted = true;
 
@@ -77,8 +78,8 @@
     }
 
     @Override
-    public boolean hasRootInCacerts(HashMap<CertPath, CertInformation> certs,
-            HashMap<String, Integer> signedJars) {
+    public boolean hasRootInCacerts(Map<CertPath, CertInformation> certs,
+            Map<String, Integer> signedJars) {
 
         boolean allRootCAsTrusted = true;
 
@@ -101,8 +102,8 @@
     }
 
     @Override
-    public boolean isFullySigned(HashMap<CertPath, CertInformation> certs,
-            HashMap<String, Integer> signedJars) {
+    public boolean isFullySigned(Map<CertPath, CertInformation> certs,
+            Map<String, Integer> signedJars) {
 
         boolean isFullySigned = true;
 
@@ -127,8 +128,8 @@
     @Override
     public void checkTrustWithUser(JarCertVerifier jcv, JNLPFile file)
             throws LaunchException {
-        ArrayList<CertPath> certPaths = buildCertPathsList(jcv);
-        ArrayList<CertPath> alreadyApprovedByUser = new ArrayList<CertPath>();
+        List<CertPath> certPaths = buildCertPathsList(jcv);
+        List<CertPath> alreadyApprovedByUser = new ArrayList<CertPath>();
         for (String jarName : jcv.getJarSignableEntries().keySet()) {
             boolean trustFoundOrApproved = false;
             for (CertPath cPathApproved : alreadyApprovedByUser) {
@@ -190,9 +191,9 @@
      *   3. Roots in the CA store but have signing issues
      *   4. Everything else
      */
-    public ArrayList<CertPath> buildCertPathsList(JarCertVerifier jcv) {
-        ArrayList<CertPath> certPathsList = jcv.getCertsList();
-        ArrayList<CertPath> returnList = new ArrayList<CertPath>();
+    public List<CertPath> buildCertPathsList(JarCertVerifier jcv) {
+        List<CertPath> certPathsList = jcv.getCertsList();
+        List<CertPath> returnList = new ArrayList<CertPath>();
 
         for (CertPath cPath : certPathsList) {
             if (!returnList.contains(cPath)
--- a/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java	Mon Oct 22 11:02:38 2012 -0400
+++ b/netx/net/sourceforge/jnlp/tools/JarCertVerifier.java	Fri Oct 19 14:34:16 2012 -0400
@@ -78,19 +78,19 @@
     }
 
     /** All of the jar files that were verified for signing */
-    private ArrayList<String> verifiedJars = new ArrayList<String>();
+    private List<String> verifiedJars = new ArrayList<String>();
 
     /** All of the jar files that were not verified */
-    private ArrayList<String> unverifiedJars = new ArrayList<String>();
+    private List<String> unverifiedJars = new ArrayList<String>();
 
     /** The certificates used for jar verification linked to their respective information */
-    private HashMap<CertPath, CertInformation> certs = new HashMap<CertPath, CertInformation>();
+    private Map<CertPath, CertInformation> certs = new HashMap<CertPath, CertInformation>();
 
     /** Temporary cert path hack to be used to keep track of which one a UI dialog is using */
     private CertPath currentlyUsed;
 
     /** Absolute location to jars and the number of entries which are possibly signable */
-    private HashMap<String, Integer> jarSignableEntries = new HashMap<String, Integer>();
+    private Map<String, Integer> jarSignableEntries = new HashMap<String, Integer>();
 
     /** The application verifier to use by this instance */
     private AppVerifier appVerifier;
@@ -152,9 +152,9 @@
     /**
      * Get a list of the cert paths of all signers across the app.
      * 
-     * @return ArrayList of CertPath vars representing each of the signers present on any jar.
+     * @return List of CertPath vars representing each of the signers present on any jar.
      */
-    public ArrayList<CertPath> getCertsList() {
+    public List<CertPath> getCertsList() {
         return new ArrayList<CertPath>(certs.keySet());
     }
 
@@ -321,7 +321,7 @@
     VerifyResult verifyJarEntryCerts(String jarName, boolean jarHasManifest,
             Vector<JarEntry> entries) throws Exception {
         // Contains number of entries the cert with this CertPath has signed.
-        HashMap<CertPath, Integer> jarSignCount = new HashMap<CertPath, Integer>();
+        Map<CertPath, Integer> jarSignCount = new HashMap<CertPath, Integer>();
         int numSignableEntriesInJar = 0;
 
         // Record current time just before checking the jar begins.