test/sun/security/pkcs11/KeyStore/Basic.java

Print this page
7191662: JCE providers should be located via ServiceLoader


 350 
 351         // load
 352         ks.load(null, tokenPwd);
 353         System.out.println("test " + testnum++ + " passed");
 354 
 355         // aliases
 356         Enumeration enu = ks.aliases();
 357         int count = 0;
 358         while (enu.hasMoreElements()) {
 359             count++;
 360             System.out.println("alias " +
 361                                 count +
 362                                 " = " +
 363                                 (String)enu.nextElement());
 364         }
 365     }
 366 
 367     private static void module() throws Exception {
 368 
 369         // perform Security.addProvider of P11 provider
 370         ProviderLoader.go(System.getProperty("CUSTOM_P11_CONFIG"));
 371 
 372         String KS_PROVIDER = "SunPKCS11-" + System.getProperty("TOKEN");
 373 
 374         KeyStoreLoginModule m = new KeyStoreLoginModule();
 375         Subject s = new Subject();
 376         Map options = new HashMap();
 377         options.put("keyStoreURL", "NONE");
 378         options.put("keyStoreType", KS_TYPE);
 379         options.put("keyStoreProvider", KS_PROVIDER);
 380         options.put("debug", "true");
 381         m.initialize(s, new TextCallbackHandler(), new HashMap(), options);
 382         m.login();
 383         m.commit();
 384         System.out.println("authenticated subject = " + s);
 385         m.logout();
 386         System.out.println("authenticated subject = " + s);
 387     }
 388 
 389     /**
 390      * SCA1000 does not handle extended secret key tests




 350 
 351         // load
 352         ks.load(null, tokenPwd);
 353         System.out.println("test " + testnum++ + " passed");
 354 
 355         // aliases
 356         Enumeration enu = ks.aliases();
 357         int count = 0;
 358         while (enu.hasMoreElements()) {
 359             count++;
 360             System.out.println("alias " +
 361                                 count +
 362                                 " = " +
 363                                 (String)enu.nextElement());
 364         }
 365     }
 366 
 367     private static void module() throws Exception {
 368 
 369         // perform Security.addProvider of P11 provider
 370         Security.addProvider(getSunPKCS11(System.getProperty("CUSTOM_P11_CONFIG")));
 371 
 372         String KS_PROVIDER = "SunPKCS11-" + System.getProperty("TOKEN");
 373 
 374         KeyStoreLoginModule m = new KeyStoreLoginModule();
 375         Subject s = new Subject();
 376         Map options = new HashMap();
 377         options.put("keyStoreURL", "NONE");
 378         options.put("keyStoreType", KS_TYPE);
 379         options.put("keyStoreProvider", KS_PROVIDER);
 380         options.put("debug", "true");
 381         m.initialize(s, new TextCallbackHandler(), new HashMap(), options);
 382         m.login();
 383         m.commit();
 384         System.out.println("authenticated subject = " + s);
 385         m.logout();
 386         System.out.println("authenticated subject = " + s);
 387     }
 388 
 389     /**
 390      * SCA1000 does not handle extended secret key tests