Examples of PasswordCallback


Examples of javax.security.auth.callback.PasswordCallback

           
          /* 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

Examples of javax.security.auth.callback.PasswordCallback

          + "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

Examples of javax.security.auth.callback.PasswordCallback

          NameCallback name = (NameCallback) cb;

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

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

Examples of javax.security.auth.callback.PasswordCallback

    }

    public boolean login() throws LoginException {
        loginSucceeded = false;
        Callback[] callbacks = new Callback[]{new NameCallback("username"), new PasswordCallback("passsword", false)};
        try {
            callbackHandler.handle(callbacks);
        } catch (IOException e) {
            throw (LoginException) new LoginException("Could not execute callbacks").initCause(e);
        } catch (UnsupportedCallbackException e) {
View Full Code Here

Examples of javax.security.auth.callback.PasswordCallback

            return false;
        }
        Callback[] callbacks = new Callback[2];

        callbacks[0] = new NameCallback("User name");
        callbacks[1] = new PasswordCallback("Password", false);
        try {
            callbackHandler.handle(callbacks);
        } catch (IOException ioe) {
            throw (LoginException) new LoginException().initCause(ioe);
        } catch (UnsupportedCallbackException uce) {
View Full Code Here

Examples of javax.security.auth.callback.PasswordCallback

            final FieldTable ft = FieldTableFactory.newFieldTable(new DataInputStream(new ByteArrayInputStream(response)), response.length);
            String username = ft.getString("LOGIN");
            // we do not care about the prompt but it throws if null
            NameCallback nameCb = new NameCallback("prompt", username);
            // we do not care about the prompt but it throws if null
            PasswordCallback passwordCb = new PasswordCallback("prompt", false);
            // TODO: should not get pwd as a String but as a char array...
            String pwd = ft.getString("PASSWORD");
            AuthorizeCallback authzCb = new AuthorizeCallback(username, username);
            Callback[] callbacks = new Callback[]{nameCb, passwordCb, authzCb};
            _cbh.handle(callbacks);
            String storedPwd = new String(passwordCb.getPassword());
            if (storedPwd.equals(pwd))
            {
                _complete = true;
            }
            if (authzCb.isAuthorized() && _complete)
View Full Code Here

Examples of javax.security.auth.callback.PasswordCallback

    public boolean login() throws LoginException {
        Callback[] callbacks = new Callback[2];

        callbacks[0] = new NameCallback("User name");
        callbacks[1] = new PasswordCallback("Password", false);
        try {
            handler.handle(callbacks);
        } catch (IOException ioe) {
            throw (LoginException) new LoginException().initCause(ioe);
        } catch (UnsupportedCallbackException uce) {
View Full Code Here

Examples of javax.security.auth.callback.PasswordCallback

            return false;
        }
        Callback[] callbacks = new Callback[2];

        callbacks[0] = new NameCallback("User name");
        callbacks[1] = new PasswordCallback("Password", false);
        try {
            callbackHandler.handle(callbacks);
        } catch (IOException ioe) {
            throw (LoginException) new LoginException().initCause(ioe);
        } catch (UnsupportedCallbackException uce) {
View Full Code Here

Examples of javax.security.auth.callback.PasswordCallback

        // Set up our CallbackHandler requests
        if (callbackHandler == null)
            throw new LoginException("No CallbackHandler specified");
        Callback callbacks[] = new Callback[2];
        callbacks[0] = new NameCallback("Username: ");
        callbacks[1] = new PasswordCallback("Password: ", false);

        // Interact with the user to retrieve the username and password
        String username = null;
        String password = null;
        try {
View Full Code Here

Examples of javax.security.auth.callback.PasswordCallback

         throw new LoginException("Error: no CallbackHandler available " +
         "to collect authentication information");
      }
     
      NameCallback nc = new NameCallback("User name: ", "guest");
      PasswordCallback pc = new PasswordCallback("Password: ", false);
      Callback[] callbacks = {nc, pc};
      String username = null;
      String password = null;
      try
      {
         callbackHandler.handle(callbacks);
         username = nc.getName();
         char[] tmpPassword = pc.getPassword();
         if( tmpPassword != null )
         {
            credential = new char[tmpPassword.length];
            System.arraycopy(tmpPassword, 0, credential, 0, tmpPassword.length);
            pc.clearPassword();
            password = new String(credential);
         }
      }
      catch(IOException e)
      {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.