本文整理汇总了Java中com.sun.security.auth.callback.DialogCallbackHandler类的典型用法代码示例。如果您正苦于以下问题:Java DialogCallbackHandler类的具体用法?Java DialogCallbackHandler怎么用?Java DialogCallbackHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DialogCallbackHandler类属于com.sun.security.auth.callback包,在下文中一共展示了DialogCallbackHandler类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.sun.security.auth.callback.DialogCallbackHandler; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
DialogCallbackHandler h = new DialogCallbackHandler();
TextOutputCallback toc = new TextOutputCallback
(TextOutputCallback.INFORMATION,
"hello");
TextOutputCallback toc2 = new TextOutputCallback
(TextOutputCallback.INFORMATION,
"world");
ConfirmationCallback cc = new ConfirmationCallback
("Correct?",
ConfirmationCallback.INFORMATION,
ConfirmationCallback.YES_NO_OPTION,
ConfirmationCallback.NO);
Callback[] callbacks = { toc, toc2, cc };
h.handle(callbacks);
if (cc.getSelectedIndex() == ConfirmationCallback.YES) {
System.out.println("yes");
} else {
System.out.println("no");
}
System.exit(0);
}
示例2: instanceOfKeyStore
import com.sun.security.auth.callback.DialogCallbackHandler; //导入依赖的package包/类
private static KeyStore instanceOfKeyStore(Provider provider) throws Exception {
KeyStore keyStore = null;
Security.addProvider(provider);
CallbackHandler cmdLineHdlr = new DialogCallbackHandler();
KeyStore.Builder builder = KeyStore.Builder.newInstance ("PKCS11", null,
new KeyStore.CallbackHandlerProtection(cmdLineHdlr));
try {
keyStore = builder.getKeyStore();
} catch (KeyStoreException e) {
throw new Exception("Incorrect password or invalid certificate.");
}
return keyStore;
}