⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wangyucallbackhandler.java

📁 SSO客户端
💻 JAVA
字号:
/*
 * WangYuCallBackHandler.java
 *
 * Created on 2006年1月23日, 下午5:11
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package desktopsso.share;

import java.io.*;
import java.security.*;
import javax.security.auth.*;
import javax.security.auth.callback.*;

/**
 *
 * @author wangyu
 */
public class WangYuCallBackHandler implements CallbackHandler {
  //
  // The handle method does all the work and iterates through the array
  // of callbacks, examines the type, and takes the appropriate user
  // interaction action.
  public void handle(Callback[] callbacks) throws
      UnsupportedCallbackException, IOException {

    for(int i=0;i<callbacks.length;i++) {
      Callback cb = callbacks[i];
      //
      // Handle username aquisition
      if (cb instanceof NameCallback) {
        NameCallback nameCallback = (NameCallback)cb;
        System.out.print( nameCallback.getPrompt() + "? ");
        System.out.flush();
        String username = new BufferedReader(
            new InputStreamReader(System.in)).readLine();
        nameCallback.setName(username);
        //
        // Handle password aquisition
      } else if (cb instanceof PasswordCallback) {
        PasswordCallback passwordCallback = (PasswordCallback)cb;
        System.out.print( passwordCallback.getPrompt() + "? ");
        System.out.flush();
        String password = new BufferedReader(
            new InputStreamReader(System.in)).readLine();
        passwordCallback.setPassword(password.toCharArray());
        password = null;
        //
        // Other callback types are not handled here
      } else {
        throw new UnsupportedCallbackException(cb, "Unsupported Callback Type");
      }
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -