Package com.sun.security.auth.callback

Examples of com.sun.security.auth.callback.TextCallbackHandler


                    java.security.Security.getProperty(DEFAULT_HANDLER);
            // get the default callback handler
            if ((defaultHandler != null) && (defaultHandler.length() != 0)) {
                cb = null;
            } else {
                cb = new TextCallbackHandler();
            }
        }

        // New instance of LoginConfigImpl must be created for each login,
        // since the entry name is not passed as the first argument, but
View Full Code Here


import com.sun.security.auth.callback.TextCallbackHandler;
import javax.security.auth.callback.*;

public class Default {
   public static void main(String args[]) throws Exception {
        TextCallbackHandler h = new TextCallbackHandler();
        NameCallback nc = new NameCallback("Name: ", "charlie");
        ConfirmationCallback cc = new ConfirmationCallback
                        ("Correct?",
                        ConfirmationCallback.INFORMATION,
                        ConfirmationCallback.YES_NO_OPTION,
                        ConfirmationCallback.NO);

        Callback[] callbacks = { nc, cc };
        h.handle(callbacks);

        if (cc.getSelectedIndex() == ConfirmationCallback.YES) {
            System.out.println("yes");
        } else {
            System.out.println("no");
View Full Code Here

    public static void main(String[] args) throws Exception {
        // Provide answer in an individual stream so that the program
        // does not block.
        System.setIn(new ByteArrayInputStream("1\n".getBytes()));

        new TextCallbackHandler().handle(new Callback[]{
            new ConfirmationCallback("Prince", ConfirmationCallback.INFORMATION,
                    new String[]{"To be", "Not to be"}, 0)});
    }
View Full Code Here

    public static <T> T authenticateAndDo(final PrivilegedAction<T> action,
                                          final String authenticationEntry)
            throws LoginException
    {
        LoginContext lc = new LoginContext(authenticationEntry,
                                           new TextCallbackHandler());
        // Attempt authentication
        // We might want to do this in a "for" loop to give
        // user more than one chance to enter correct username/password
        lc.login();
View Full Code Here

TOP

Related Classes of com.sun.security.auth.callback.TextCallbackHandler

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.