Package javax.security.auth.callback

Examples of javax.security.auth.callback.TextOutputCallback


        public void handle(Callback[] callbacks) throws IOException,
                UnsupportedCallbackException {
            for (Callback element : callbacks) {
                if (element instanceof TextOutputCallback) {
                    TextOutputCallback toc = (TextOutputCallback) element;
                    if (toc.getMessageType() != TextOutputCallback.INFORMATION) {
                        throw new IOException("Unsupported message type: "
                                + toc.getMessageType());
                    }
                } else {
                    throw new UnsupportedCallbackException(element,
                            "Callback should be TextOutputCallback");
                }
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

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

     * 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

public class TextOutputCallbackTest extends SerializationTest implements
        SerializationTest.SerializableAssert {

    @Override
    protected Object[] getData() {
        return new Object[] { new TextOutputCallback(
                TextOutputCallback.INFORMATION, "message") };
    }
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

     */
    public void handle(Callback[] callbacks) throws UnsupportedCallbackException {

        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

    {
        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

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.