Package javax.security.auth.callback

Examples of javax.security.auth.callback.NameCallback


            CallbackHandler handler = new CallbackHandler() {
          @Override
          public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
            for (int i = 0; i < callbacks.length; i++) {
              if (callbacks[i] instanceof NameCallback) {
                NameCallback nc = (NameCallback)callbacks[i];
                nc.setName(baseUsername);
              } else if (callbacks[i] instanceof PasswordCallback) {
                PasswordCallback pc = (PasswordCallback)callbacks[i];
                    char[] password = null;
                    if (credential != null) {
                      password = credential.getCredentialsAsCharArray();
View Full Code Here


         
          @Override
          public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
                for (Callback callback : callbacks) {
                    if (callback instanceof NameCallback) {
                        NameCallback nameCallback = (NameCallback)callback;
                        nameCallback.setName(username);
                    }
                    else if (callback instanceof PasswordCallback) {
                        PasswordCallback passwordCallback = (PasswordCallback)callback;
                        passwordCallback.setPassword(password.toCharArray());
                    }
View Full Code Here

   @SuppressWarnings("unchecked")
   public boolean login() throws LoginException
   {

      Callback[] callbacks = new Callback[2];
      callbacks[0] = new NameCallback("Username");
      callbacks[1] = new PasswordCallback("Password", false);

      try
      {
         callbackHandler.handle(callbacks);
View Full Code Here

        "Error: no CallbackHandler available "
          + "to garner authentication information from the user");
    // Setup default callback handlers.
    Callback[] callbacks =
      new Callback[] {
        new NameCallback("Username: "),
        new PasswordCallback("Password: ", false)};

    try {
      callbackHandler.handle(callbacks);
    } catch (IOException e) {
View Full Code Here

    // 提示输入用户名和密码;
    if (callbackHandler == null) {
      throw new LoginException("没有指明 CallBackHandler!");
    }
    Callback[] callbacks = new Callback[2];
    callbacks[0] = new NameCallback("用户名");
    callbacks[1] = new PasswordCallback("密码", false);
    try {
      callbackHandler.handle(callbacks);
      username = ((NameCallback) callbacks[0]).getName();
      password = ((PasswordCallback) callbacks[1]).getPassword();
View Full Code Here

     
      // Request a username and password
      if( handler == null )
         throw new LoginException("No CallbackHandler provied to SRPLoginModule");
     
      NameCallback nc = new NameCallback("Username: ", "guest");
      PasswordCallback pc = new PasswordCallback("Password: ", false);
      ByteArrayCallback bac = new ByteArrayCallback("Public key random number: ");
      TextInputCallback tic = new TextInputCallback("Auxillary challenge token: ");
      ArrayList tmpList = new ArrayList();
      tmpList.add(nc);
      tmpList.add(pc);
      if( externalRandomA == true )
         tmpList.add(bac);
      if( hasAuxChallenge == true )
         tmpList.add(tic);
      Callback[] callbacks = new Callback[tmpList.size()];
      tmpList.toArray(callbacks);
      try
      {
         handler.handle(callbacks);
         username = nc.getName();
         _password = pc.getPassword();
         if( _password != null )
            password = _password;
         pc.clearPassword();
         if( externalRandomA == true )
View Full Code Here

        for (int i = 0; i < callbacks.length; i++) {
            if (callbacks[i] instanceof NameCallback) {
              if (log.isDebugEnabled()) {
                log.debug("Handling username callback");
                }
                NameCallback cb = (NameCallback) callbacks[i];
                cb.setName(username);

            } else if (callbacks[i] instanceof PasswordCallback) {
              if (log.isDebugEnabled()) {
                log.debug("Handling password callback");
                }
                PasswordCallback cb = (PasswordCallback) callbacks[i];
                cb.setPassword(password);

            } else {
                throw new UnsupportedCallbackException(callbacks[i]);
            }
        }
View Full Code Here

          /* Handles Id request */
          if (callbacks[i] instanceof NameCallback) {
            if (LOG.isDebugEnabled())
              LOG.debug("Handling username callback");
                NameCallback nc = (NameCallback) callbacks[i];
                nc.setName(username);
            }
           
          /* Handles Credentitial request */
            else if (callbacks[i] instanceof PasswordCallback) {
            if (LOG.isDebugEnabled())
View Full Code Here

      throw new LoginException("Error: no CallbackHandler available "
          + "to garner authentication information from the user");
    }

    Callback[] callbacks = new Callback[3];
    callbacks[0] = new NameCallback(LoginUtils.USER);
    callbacks[1] = new PasswordCallback(LoginUtils.PASSWORD, false);
    callbacks[2] = new TextOutputCallback(TextOutputCallback.INFORMATION,
        LoginUtils.CRED_MESSAGE);

    try {
View Full Code Here

    {
      for (int i = 0; i < callbacks.length; i++) {
        Callback cb = callbacks[i];

        if (cb instanceof NameCallback) {
          NameCallback name = (NameCallback) cb;

          name.setName(_userName);
        }
        else if (cb instanceof PasswordCallback) {
          PasswordCallback password = (PasswordCallback) cb;

          password.setPassword(_password.toCharArray());
View Full Code Here

TOP

Related Classes of javax.security.auth.callback.NameCallback

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.