Search in sources :

Example 31 with ConfirmationCallback

use of javax.security.auth.callback.ConfirmationCallback in project Payara by payara.

the class CallbackGUIBindings method getDefaultConfirmationCallbackUIBinding.

/**
 * Creates a default ConfirmationCallback binding (because the caller did
 * not provide one).
 * @return the default ConfirmationCallbackUIBinding
 */
public CallbackGUIBindings.Confirmation getDefaultConfirmationCallbackUIBinding() {
    ConfirmationCallback defaultCallback = new ConfirmationCallback(ConfirmationCallback.INFORMATION, ConfirmationCallback.OK_CANCEL_OPTION, ConfirmationCallback.OK);
    CallbackGUIBindings.Confirmation binding = new CallbackGUIBindings.Confirmation();
    binding.setCallback(defaultCallback);
    return binding;
}
Also used : ConfirmationCallback(javax.security.auth.callback.ConfirmationCallback)

Example 32 with ConfirmationCallback

use of javax.security.auth.callback.ConfirmationCallback in project Payara by payara.

the class DefaultGUICallbackHandlerTest method run.

private void run() throws IOException, UnsupportedCallbackException {
    CallbackHandler ch = new DefaultGUICallbackHandler();
    ChoiceCallback choiceCB = new ChoiceCallback("Choose one", new String[] { "First", "Second", "Third", "Fourth", "Fifth", "Sixth", "Seventh" }, 0, false);
    ConfirmationCallback confirmationCB = new ConfirmationCallback("Decide", ConfirmationCallback.INFORMATION, ConfirmationCallback.OK_CANCEL_OPTION, ConfirmationCallback.OK);
    NameCallback nameCB = new NameCallback("Username", "who");
    PasswordCallback passwordCB = new PasswordCallback("Password", false);
    TextInputCallback textInCB = new TextInputCallback("Enter something interesting", "Good stuff to start with...");
    TextOutputCallback textOutCB = new TextOutputCallback(TextOutputCallback.WARNING, "Some fascinating text of great interest to the user goes here");
    LanguageCallback langCB = new LanguageCallback();
    Callback[] callbacks = new Callback[] { choiceCB, confirmationCB, nameCB, passwordCB, textInCB, textOutCB, langCB };
    ch.handle(callbacks);
    System.out.println("ChoiceCallback choice(s):");
    for (int index : choiceCB.getSelectedIndexes()) {
        if (index > 0) {
            System.out.println("  " + choiceCB.getChoices()[index]);
        } else {
            System.out.println("  Selection not made");
        }
    }
    System.out.print("ConfirmationCallback result: ");
    if (confirmationCB.getOptions() == null) {
        System.out.println(confirmationResultToString(confirmationCB.getSelectedIndex()));
    } else {
        System.out.println(confirmationCB.getOptions()[confirmationCB.getSelectedIndex()]);
    }
    System.out.println("NameCallback result: " + nameCB.getName());
    System.out.println("PasswordCallback result: " + new String(passwordCB.getPassword()));
    System.out.println("TextInputCallback result: " + textInCB.getText());
    System.out.println("LanguageCallback result: " + langCB.getLocale().getDisplayName());
}
Also used : CallbackHandler(javax.security.auth.callback.CallbackHandler) ConfirmationCallback(javax.security.auth.callback.ConfirmationCallback) TextOutputCallback(javax.security.auth.callback.TextOutputCallback) LanguageCallback(javax.security.auth.callback.LanguageCallback) TextInputCallback(javax.security.auth.callback.TextInputCallback) ChoiceCallback(javax.security.auth.callback.ChoiceCallback) NameCallback(javax.security.auth.callback.NameCallback) TextInputCallback(javax.security.auth.callback.TextInputCallback) PasswordCallback(javax.security.auth.callback.PasswordCallback) LanguageCallback(javax.security.auth.callback.LanguageCallback) ChoiceCallback(javax.security.auth.callback.ChoiceCallback) TextOutputCallback(javax.security.auth.callback.TextOutputCallback) NameCallback(javax.security.auth.callback.NameCallback) ConfirmationCallback(javax.security.auth.callback.ConfirmationCallback) Callback(javax.security.auth.callback.Callback) PasswordCallback(javax.security.auth.callback.PasswordCallback)

Aggregations

ConfirmationCallback (javax.security.auth.callback.ConfirmationCallback)32 NameCallback (javax.security.auth.callback.NameCallback)20 PasswordCallback (javax.security.auth.callback.PasswordCallback)20 ChoiceCallback (javax.security.auth.callback.ChoiceCallback)15 Callback (javax.security.auth.callback.Callback)14 Test (org.testng.annotations.Test)13 TextOutputCallback (javax.security.auth.callback.TextOutputCallback)9 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)6 JsonValue (org.forgerock.json.JsonValue)6 DevicePrint (org.forgerock.openam.authentication.modules.deviceprint.model.DevicePrint)6 HttpCallback (com.sun.identity.authentication.spi.HttpCallback)5 PagePropertiesCallback (com.sun.identity.authentication.spi.PagePropertiesCallback)5 RedirectCallback (com.sun.identity.authentication.spi.RedirectCallback)5 TextInputCallback (javax.security.auth.callback.TextInputCallback)5 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 LanguageCallback (javax.security.auth.callback.LanguageCallback)4 HiddenValueCallback (com.sun.identity.authentication.callbacks.HiddenValueCallback)3 ScriptTextOutputCallback (com.sun.identity.authentication.callbacks.ScriptTextOutputCallback)3