Package javax.security.auth.callback

Examples of javax.security.auth.callback.PasswordCallback


            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();
                    }
                pc.setPassword(password);
                credentials = password;
              } else {
                throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback"); //$NON-NLS-1$
              }
            }
View Full Code Here


                    if (callback instanceof NameCallback) {
                        NameCallback nameCallback = (NameCallback)callback;
                        nameCallback.setName(username);
                    }
                    else if (callback instanceof PasswordCallback) {
                        PasswordCallback passwordCallback = (PasswordCallback)callback;
                        passwordCallback.setPassword(password.toCharArray());
                    }
                    else {
                        throw new UnsupportedCallbackException(callback, "Unrecognized Callback: " + callback); //$NON-NLS-1$
                    }
                }           
View Full Code Here

   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);
         String password = new String(((PasswordCallback)callbacks[1]).getPassword());
View Full Code Here

          + "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) {
      throw new LoginException("exception calling back: " + e.toString());
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();
    } catch (Exception e) {
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 )
            abytes = bac.getByteArray();
         if( hasAuxChallenge == true )
            this.auxChallenge = tic.getText();
      }
View Full Code Here

            } 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 Credentitial request */
            else if (callbacks[i] instanceof PasswordCallback) {
            if (LOG.isDebugEnabled())
              LOG.debug("Handling password callback");
                PasswordCallback pc = (PasswordCallback) callbacks[i];
                pc.setPassword(password);
            }
           
          /* Cannot Handle other request */
            else {
                throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
View Full Code Here

          + "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 {
      callbackHandler.handle(callbacks);
View Full Code Here

          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.PasswordCallback

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.