Examples of PasswordCallback


Examples of javax.security.auth.callback.PasswordCallback

        ResultSet passwordResultSet = null;
        ResultSet roleResultSet = null;

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

        try {
            callbackHandler.handle(callbacks);
        } catch (IOException ioe) {
            throw new LoginException(ioe.getMessage());
View Full Code Here

Examples of javax.security.auth.callback.PasswordCallback

    @Override
    public boolean login() throws LoginException
    {
        Callback[] callbacks = new Callback[2];
        callbacks[0] = new NameCallback("Name");
        callbacks[1] = new PasswordCallback("Password", false);

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

Examples of javax.security.auth.callback.PasswordCallback

        for (Callback current : callbacks) {
            if (current instanceof NameCallback) {
                NameCallback ncb = (NameCallback) current;
                ncb.setName(principal.getName());
            } else if (current instanceof PasswordCallback) {
                PasswordCallback pcb = (PasswordCallback) current;
                pcb.setPassword(ppCredential.getPassword());
            } else if (current instanceof RealmCallback) {
                RealmCallback rcb = (RealmCallback) current;
                rcb.setText(rcb.getDefaultText());
            } else {
                UnsupportedCallbackException e = new UnsupportedCallbackException(current);
View Full Code Here

Examples of javax.security.auth.callback.PasswordCallback

      throws LoginException
   {
      try
      {
         NameCallback cbName = new NameCallback("Enter username");
         PasswordCallback cbPassword = new PasswordCallback("Enter password", false);
  
         // Get the username and password from the callback handler
         callbackHandler.handle(new Callback[] { cbName, cbPassword });
         username = cbName.getName();
      }
View Full Code Here

Examples of javax.security.auth.callback.PasswordCallback

                // may later add a Callback to obtain the server info to verify is a server was identified with
                // the specified username.

                for (Callback current : callbacks) {
                    if (current instanceof PasswordCallback) {
                        PasswordCallback pcb = (PasswordCallback) current;
                        char[] password = pcb.getPassword();
                        return (password != null && password.length > 0);
                    } else if (current instanceof VerifyPasswordCallback) {
                        return ((VerifyPasswordCallback) current).isVerified();
                    } else if (current instanceof DigestHashCallback) {
                        return ((DigestHashCallback) current).getHash() != null;
View Full Code Here

Examples of javax.security.auth.callback.PasswordCallback

//                    } else {
//                        logger.fine("cb.getPrompt(): " + cb.getPrompt());
//                        throw new UnsupportedCallbackException(callbacks[i]);
//                    }
                } else if (callbacks[i] instanceof PasswordCallback) {
                    PasswordCallback cb = (PasswordCallback) callbacks[i];
                    if (usePW) {
                        // TODO: replace by native func to suppress password echo
                        System.out.print(cb.getPrompt() + " ");
                        System.out.flush();
                        String pw = new BufferedReader(new InputStreamReader(System.in)).readLine();
                        cb.setPassword(pw.toCharArray());
                        pw = null;
                    } else {
                        cb.setPassword(new char[0]);
                    }
                } else if (callbacks[i] instanceof ConfirmationCallback) {
                    ConfirmationCallback cb = (ConfirmationCallback) callbacks[i];
                    cb.setSelectedIndex(cb.getDefaultOption());
                } else {
                    throw new UnsupportedCallbackException(callbacks[i]);
                }
            }
        }
View Full Code Here

Examples of javax.security.auth.callback.PasswordCallback

            }
            String host = args[0];
            int port = Integer.parseInt(args[1]);
            logger.info("connect to host(" + host + ":" + port + ")");
            NameCallback ncb = new NameCallback("user:");
            PasswordCallback pwcb = new PasswordCallback("password:", false);
            Callback[] callbacks = {ncb, pwcb};
            MyCallbackHandler cb = new MyCallbackHandler();
            usePW = true;
            cb.handle(callbacks);
            String username = ncb.getName();
            String userpw = pwcb.getPassword().toString();
            if (useKS) {
                PasswordCallback kspw = new PasswordCallback("keystore password:", true);
                Callback[] kcallbacks = {kspw};
                cb.handle(kcallbacks);
                File caTop = new File(caTopPath);
                File keyStore = new File(keystorePath);
                JGDIProxy.setupSSL(host, port, caTop, keyStore, kspw.getPassword());
                kspw.clearPassword();
                kspw = null;
            }
            Object credentials = new String[]{username, userpw};
            JGDIProxy jgdiProxy = JGDIFactory.newJMXInstance(host, port, credentials);
View Full Code Here

Examples of javax.security.auth.callback.PasswordCallback

                case TYPE_USER:
                case TYPE_SGE_DAEMON:   
                    if(pwFile == null) {
                        CallbackHandler cbh = new TextCallbackHandler();
                       
                        PasswordCallback keystorePWCallback = new PasswordCallback("keystore password: ", false);
                       
                        Callback [] cb = new Callback [] {
                            keystorePWCallback,
                        };
                       
                        cbh.handle(cb);
                        pw = keystorePWCallback.getPassword();
                        if(pw == null) {
                            pw = new char[0];
                        }
                    } else {
                        FileReader fr = new FileReader(pwFile);
View Full Code Here

Examples of javax.security.auth.callback.PasswordCallback

            }
           
            nc.setName(result);
           
         } else if (callbacks[i] instanceof PasswordCallback) {
            PasswordCallback pc = (PasswordCallback) callbacks[i];
           
            System.err.print(pc.getPrompt());
            System.err.flush();
           
            pc.setPassword(readPassword(System.in));
           
         } else if (callbacks[i] instanceof ConfirmationCallback) {
            confirmation = (ConfirmationCallback) callbacks[i];
           
         } else {
View Full Code Here

Examples of javax.security.auth.callback.PasswordCallback

            log.exiting("GECATrustManagerLoginModule", "login", Boolean.valueOf(loginSucceeded));
            return loginSucceeded;
        }
       
        NameCallback usernameCallback = new NameCallback("username");
        PasswordCallback passwordCallback = new PasswordCallback("password", true);

        try {
            callbackHandler.handle(new Callback[]{usernameCallback, passwordCallback});
        } catch (UnsupportedCallbackException ex) {
            LoginException le = new LoginException("callback is not supported");
            le.initCause(ex);
            throw le;
        } catch (IOException ex) {
            LoginException le = new LoginException("io error in callback handler");
            le.initCause(ex);
            throw le;
        }

        String password = new String(passwordCallback.getPassword());
        Properties props = new Properties();
        try {
            props.load(new ByteArrayInputStream(password.getBytes()));
        } catch (IOException ex) {
            // Can not happen we are reading from a byte array
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.