harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r506411 - in /harmony/enhanced/classlib/trunk/modules/security/src: main/java/common/java/security/Provider.java test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java
Date Mon, 12 Feb 2007 10:53:21 GMT
Author: smishura
Date: Mon Feb 12 02:53:21 2007
New Revision: 506411

URL: http://svn.apache.org/viewvc?view=rev&rev=506411
Log:
Fix and regression test for HARMONY-2761
[classlib][security] Security.getProviders throws NumberFormatException unexpectedly

Modified:
    harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Provider.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java

Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Provider.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Provider.java?view=diff&rev=506411&r1=506410&r2=506411
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Provider.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/Provider.java
Mon Feb 12 02:53:21 2007
@@ -311,8 +311,14 @@
     // specified attribute name/value pair.
     private boolean checkAttribute(String servAlg, String attribute, String val) {
         if (attribute.equalsIgnoreCase("KeySize")) { //$NON-NLS-1$
-            if (Integer.valueOf(getProperty(servAlg + " KeySize")).compareTo( //$NON-NLS-1$
-                    Integer.valueOf(val)) < 0) {
+
+            String attributeValue = getProperty(servAlg + " KeySize"); //$NON-NLS-1$
+            if (attributeValue == null) {
+                // provider doesn't provide KeySize attribute for the service
+                return false;
+            }
+
+            if (Integer.valueOf(attributeValue).compareTo(Integer.valueOf(val)) < 0) {
                 return false;
             } else {
                 return true;

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java?view=diff&rev=506411&r1=506410&r2=506411
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java
Mon Feb 12 02:53:21 2007
@@ -221,6 +221,10 @@
 
             filter = "MyService.MyAlgorithm KeySize:1025";
             assertNull(filter, Security.getProviders(filter));
+            
+            // Regression for HARMONY-2761
+            filter = "MyService.MyAlgorithmNoKeySize KeySize:512";
+            assertNull(filter, Security.getProviders(filter));
         } finally { //clean up
             Security.removeProvider(p.getName());
         }
@@ -270,6 +274,11 @@
             m.put("MessageDigest.SHA-1", "");
             assertNull("MyService.MyAlgorithm KeySize:1025", Security
                     .getProviders(m));
+            
+            // Regression for HARMONY-2761
+            m.clear();
+            m.put("MyService.MyAlgorithmNoKeySize KeySize", "512");
+            assertNull("No KeySize attribute", Security.getProviders(m));
         } finally { //clean up
             Security.removeProvider(p.getName());
         }
@@ -312,12 +321,16 @@
                 .getProperty("My Test Property"));
     }
     
+    @SuppressWarnings("serial")
     class MyProvider extends Provider {
         MyProvider() {
             super("MyProvider", 1.0, "Provider for testing");
             put("MessageDigest.SHA-1", "SomeClassName");
             put("MyService.MyAlgorithm", "SomeClassName");
             put("MyService.MyAlgorithm KeySize", "1024");
+
+            // service has no KeySize attribute
+            put("MyService.MyAlgorithmNoKeySize", "SomeClassName");
         }
     }
 



Mime
View raw message