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;
}
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());
}
Aggregations