当前位置: 首页>>代码示例>>Java>>正文


Java DialogCallbackHandler类代码示例

本文整理汇总了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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:26,代码来源:Default.java

示例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;  
}
 
开发者ID:robsonsmartins,项目名称:fiap-mba-java-projects,代码行数:14,代码来源:CryptoDeviceManager.java


注:本文中的com.sun.security.auth.callback.DialogCallbackHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。