2424
2525import java .security .Provider ;
2626import java .security .Security ;
27- import java .util .HashMap ;
28- import java .util .Map ;
2927
3028/*
3129 * @test
@@ -49,41 +47,31 @@ public final class VerifyMissingAttributes {
4947 };
5048
5149 public static void main (String [] args ) throws Throwable {
52- Map <String , String > attrs = new HashMap <>();
5350 Provider sunProvider = Security .getProvider ("SUN" );
5451 for (String svcAlg : svcAlgImplementedIn ) {
55- attrs .clear ();
56- attrs .put (svcAlg + " ImplementedIn" , "Software" );
57- doQuery (sunProvider , attrs );
52+ String filter = svcAlg + " ImplementedIn:Software" ;
53+ doQuery (sunProvider , filter );
5854 }
5955 if (Double .parseDouble (
6056 System .getProperty ("java.specification.version" )) >= 17 ) {
61- attrs .clear ();
62- attrs .put ("KeyFactory.RSASSA-PSS SupportedKeyClasses" ,
57+ String filter = "KeyFactory.RSASSA-PSS SupportedKeyClasses:" +
6358 "java.security.interfaces.RSAPublicKey" +
64- "|java.security.interfaces.RSAPrivateKey" ) ;
65- doQuery (Security .getProvider ("SunRsaSign" ), attrs );
59+ "|java.security.interfaces.RSAPrivateKey" ;
60+ doQuery (Security .getProvider ("SunRsaSign" ), filter );
6661 }
6762 System .out .println ("TEST PASS - OK" );
6863 }
6964
70- private static void doQuery (Provider expectedProvider ,
71- Map < String , String > attrs ) throws Exception {
65+ private static void doQuery (Provider expectedProvider , String filter )
66+ throws Exception {
7267 if (expectedProvider == null ) {
7368 throw new Exception ("Provider not found." );
7469 }
75- Provider [] providers = Security .getProviders (attrs );
70+ Provider [] providers = Security .getProviders (filter );
7671 if (providers == null || providers .length != 1 ||
7772 providers [0 ] != expectedProvider ) {
78- StringBuffer sb = new StringBuffer ();
79- attrs .entrySet ().stream ().forEach (ent -> {
80- sb .append (ent .getKey ());
81- sb .append (": " );
82- sb .append (ent .getValue ());
83- sb .append (System .lineSeparator ());
84- });
8573 throw new Exception ("Failure retrieving the provider with this" +
86- " query: " + sb . toString () );
74+ " query: " + filter );
8775 }
8876 }
8977}
0 commit comments