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


Java TextCallbackHandler类代码示例

本文整理汇总了Java中com.sun.security.auth.callback.TextCallbackHandler的典型用法代码示例。如果您正苦于以下问题:Java TextCallbackHandler类的具体用法?Java TextCallbackHandler怎么用?Java TextCallbackHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TextCallbackHandler类属于com.sun.security.auth.callback包,在下文中一共展示了TextCallbackHandler类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.sun.security.auth.callback.TextCallbackHandler; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
     TextCallbackHandler h = new TextCallbackHandler();
     NameCallback nc = new NameCallback("Name: ", "charlie");
     ConfirmationCallback cc = new ConfirmationCallback
                     ("Correct?",
                     ConfirmationCallback.INFORMATION,
                     ConfirmationCallback.YES_NO_OPTION,
                     ConfirmationCallback.NO);

     Callback[] callbacks = { nc, cc };
     h.handle(callbacks);

     if (cc.getSelectedIndex() == ConfirmationCallback.YES) {
         System.out.println("yes");
     } else {
         System.out.println("no");
     }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:Default.java

示例2: loginAndAction

import com.sun.security.auth.callback.TextCallbackHandler; //导入依赖的package包/类
public static void loginAndAction(String name, PrivilegedExceptionAction action)
    throws LoginException, PrivilegedActionException {

  // Create a callback handler
  CallbackHandler callbackHandler = new TextCallbackHandler();

  LoginContext context = null;

  try {
    // Create a LoginContext with a callback handler
    context = new LoginContext(name, callbackHandler);

    // Perform authentication
    context.login();
  } catch (LoginException e) {
    System.err.println("Login failed");
    e.printStackTrace();
    System.exit(-1);
  }

  // Perform action as authenticated user
  Subject subject = context.getSubject();
  if (verbose) {
    System.out.println(subject.toString());
  } else {
    System.out.println("Authenticated principal: " + subject.getPrincipals());
  }

  Subject.doAs(subject, action);

  context.logout();
}
 
开发者ID:criteo,项目名称:kerberos-docker,代码行数:33,代码来源:Jaas.java

示例3: main

import com.sun.security.auth.callback.TextCallbackHandler; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    // Provide answer in an individual stream so that the program
    // does not block.
    System.setIn(new ByteArrayInputStream("1\n".getBytes()));

    new TextCallbackHandler().handle(new Callback[]{
        new ConfirmationCallback("Prince", ConfirmationCallback.INFORMATION,
                new String[]{"To be", "Not to be"}, 0)});
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:Confirm.java

示例4: main

import com.sun.security.auth.callback.TextCallbackHandler; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
     System.setIn(new ByteArrayInputStream(new byte[0]));

     try {
         new TextCallbackHandler().handle(new Callback[]  {
             new NameCallback("Name: ") }
         );
     } catch (IOException ioe) {
         // This is OK
     }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:NPE.java

示例5: main

import com.sun.security.auth.callback.TextCallbackHandler; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
     TextCallbackHandler h = new TextCallbackHandler();
     PasswordCallback nc = new PasswordCallback("Invisible: ", false);
     PasswordCallback nc2 = new PasswordCallback("Visible: ", true);

     System.out.println("Two passwords will be prompted for. The first one " +
             "should have echo off, the second one on. Otherwise, this test fails");
     Callback[] callbacks = { nc, nc2 };
     h.handle(callbacks);
     System.out.println("You input " + new String(nc.getPassword()) +
             " and " + new String(nc2.getPassword()));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:Password.java

示例6: getDeprivilegedClasses

import com.sun.security.auth.callback.TextCallbackHandler; //导入依赖的package包/类
private static List<Class<?>> getDeprivilegedClasses() {

        List<Class<?>> classes = new ArrayList<Class<?>>();
        // Test from java.xml.crypto/javax/xml/crypto/dsig package
        classes.add(XMLSignatureFactory.class);
        // Test from java.xml.crypto/javax/xml/crypto package
        classes.add(KeySelectorException.class);
        // Test From java.security.jgss/javax/security/auth/kerberos package
        classes.add(KeyTab.class);
        // Test from jdk.security.jgss/com/sun/security/jgss package
        classes.add(AuthorizationDataEntry.class);
        // Test from jdk.security.auth/com/sun/security/auth/callback package
        classes.add(TextCallbackHandler.class);
        return classes;
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:DeprivilegedModuleLoaderTest.java


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