private static void testInvalidOptions() throws Exception {
// if keyStoreType is PKCS11, keyStoreURL must be NONE
KeyStoreLoginModule m = new KeyStoreLoginModule();
Subject s = new Subject();
Map options = new HashMap();
options.put(O_TYPE, P11KEYSTORE);
m.initialize(s, null, null, options);
try {
m.login();
throw new SecurityException("expected exception");
} catch (LoginException le) {
// good
//le.printStackTrace();
System.out.println("test " + testnum++ + " passed");
}
// if keyStoreType is PKCS11, keyStoreURL is NONE,
// then privateKeyPasswordURL must not be specified
options = new HashMap();
options.put(O_TYPE, P11KEYSTORE);
options.put(O_URL, NONE);
options.put(O_KPASS_URL, KPASS_URL);
m.initialize(s, null, null, options);
try {
m.login();
throw new SecurityException("expected exception");
} catch (LoginException le) {
// good
//le.printStackTrace();
System.out.println("test " + testnum++ + " passed");
}
// if protected is true, keyStorePasswordURL must not be specified
options = new HashMap();
options.put(O_PPATH, "true");
options.put(O_SPASS_URL, SPASS_URL);
m.initialize(s, null, null, options);
try {
m.login();
throw new SecurityException("expected exception");
} catch (LoginException le) {
// good
//le.printStackTrace();
System.out.println("test " + testnum++ + " passed");
}
// if protected is true, privateKeyPasswordURL must not be specified
options = new HashMap();
options.put(O_PPATH, "true");
options.put(O_KPASS_URL, KPASS_URL);
m.initialize(s, null, null, options);
try {
m.login();
throw new SecurityException("expected exception");
} catch (LoginException le) {
// good
//le.printStackTrace();
System.out.println("test " + testnum++ + " passed");