Package javax.security.auth.callback

Examples of javax.security.auth.callback.TextOutputCallback


     * Test for TextOutputCallback(int msgType,String msg) ctor,
     * if msg is null or empty
     */
    public final void testInit() {
        try {
            text = new TextOutputCallback(1, "");
            fail("Message should not be empty or null");
        } catch (IllegalArgumentException e) {
        }
        try {
            text = new TextOutputCallback(1, null);
            fail("Message should not be empty or null");
        } catch (IllegalArgumentException e) {
        }

    }
View Full Code Here


    /**
     * Test for TextOutputCallback(int msgType,String msg) ctor
     */
    public final void testTextOutputCallback_01() {
        text = new TextOutputCallback(0, "message");
        assertEquals("message", text.getMessage());
        assertEquals(0, text.getMessageType());
    }
View Full Code Here

     */
    public final void testTextOutputCallback_02() {
        int[] m = { TextOutputCallback.INFORMATION, TextOutputCallback.WARNING,
                TextOutputCallback.ERROR };
        for (int i = 0; i < m.length; i++) {
            text = new TextOutputCallback(m[i], "message");
        }
    }
View Full Code Here

     * Test for TextOutputCallback(int msgType,String msg) ctor,
     * if mgsType is not INFORMATION, WARNING or ERROR, then expected IAE
     */
    public final void testTextOutputCallback_03() {
        try {
            text = new TextOutputCallback(5, "message");
            fail("messageType should be either INFORMATION, WARNING or ERROR");
        } catch (IllegalArgumentException e) {
        }
    }
View Full Code Here

        } catch (UnsupportedCallbackException e) {
            fail();
        }

        try {
            credentials.handle(new Callback[]{ new TextOutputCallback(0, "foo")});
            fail();
        } catch (UnsupportedCallbackException e) {
            // ok
        }
    }
View Full Code Here

    {
        ConfirmationCallback confirmation = null;

        for (int i = 0; i < callbacks.length; i++) {
            if (callbacks[i] instanceof TextOutputCallback) {
                TextOutputCallback tc = (TextOutputCallback) callbacks[i];

                String text;
                switch (tc.getMessageType()) {
                case TextOutputCallback.INFORMATION:
                    text = "";
                    break;
                case TextOutputCallback.WARNING:
                    text = "Warning: ";
                    break;
                case TextOutputCallback.ERROR:
                    text = "Error: ";
                    break;
                default:
                    throw new UnsupportedCallbackException(
                        callbacks[i], "Unrecognized message type");
                }

                String message = tc.getMessage();
                if (message != null) {
                    text += message;
                }
                if (text != null) {
                    System.err.println(text);
View Full Code Here

        ConfirmationInfo confirmation = new ConfirmationInfo();

        for (int i = 0; i < callbacks.length; i++) {
            if (callbacks[i] instanceof TextOutputCallback) {
                TextOutputCallback tc = (TextOutputCallback) callbacks[i];

                switch (tc.getMessageType()) {
                case TextOutputCallback.INFORMATION:
                    confirmation.messageType = JOptionPane.INFORMATION_MESSAGE;
                    break;
                case TextOutputCallback.WARNING:
                    confirmation.messageType = JOptionPane.WARNING_MESSAGE;
                    break;
                case TextOutputCallback.ERROR:
                    confirmation.messageType = JOptionPane.ERROR_MESSAGE;
                    break;
                default:
                    throw new UnsupportedCallbackException(
                        callbacks[i], "Unrecognized message type");
                }

                messages.add(tc.getMessage());

            } else if (callbacks[i] instanceof NameCallback) {
                final NameCallback nc = (NameCallback) callbacks[i];

                JLabel prompt = new JLabel(nc.getPrompt());
View Full Code Here

        } catch (UnsupportedCallbackException e) {
            fail();
        }

        try {
            credentials.handle(new Callback[]{ new TextOutputCallback(0, "foo")});
            fail();
        } catch (UnsupportedCallbackException e) {
            // ok
        }
    }
View Full Code Here

        } catch (UnsupportedCallbackException e) {
            fail();
        }

        try {
            credentials.handle(new Callback[]{ new TextOutputCallback(0, "foo")});
            fail();
        } catch (UnsupportedCallbackException e) {
            // ok
        }
    }
View Full Code Here

                throw new SaslException("Incorrect mechanisms");
            }
            if (protocol == null) {
                throw new SaslException("Protocol is null");
            }
            TextOutputCallback[] cb = { new TextOutputCallback(
                    TextOutputCallback.INFORMATION, "Information") };
            try {
                hnd.handle(cb);
            } catch (UnsupportedCallbackException e) {
                throw new SaslException("Incorrect callback handlere", e);
View Full Code Here

TOP

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

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.