/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* JAAS imports */
/* Java imports */
/**
* <p>
* Uses a Swing dialog window to query the user for answers to
* authentication questions.
* This can be used by a JAAS application to instantiate a
* CallbackHandler
* @see javax.security.auth.callback
*/
/* -- Fields -- */
/* The parent window, or null if using the default parent */
/* -- Methods -- */
/**
* Creates a callback dialog with the default parent window.
*/
public DialogCallbackHandler() { }
/**
* Creates a callback dialog and specify the parent window.
*
* @param parentComponent the parent window -- specify <code>null</code>
* for the default parent
*/
this.parentComponent = parentComponent;
}
/*
* An interface for recording actions to carry out if the user
* clicks OK for the dialog.
*/
private static interface Action {
void perform();
}
/**
* Handles the specified set of callbacks.
*
* @param callbacks the callbacks to handle
* @throws UnsupportedCallbackException if the callback is not an
* instance of NameCallback or PasswordCallback
*/
throws UnsupportedCallbackException
{
/* Collect messages to display in the dialog */
/* Collection actions to perform if the user clicks OK */
if (callbacks[i] instanceof TextOutputCallback) {
switch (tc.getMessageType()) {
break;
case TextOutputCallback.WARNING:
break;
case TextOutputCallback.ERROR:
break;
default:
throw new UnsupportedCallbackException(
callbacks[i], "Unrecognized message type");
}
} else if (callbacks[i] instanceof NameCallback) {
if (defaultName != null) {
}
/*
* Put the prompt and name in a horizontal box,
* and add that to the set of messages.
*/
/* Store the name back into the callback if OK */
public void perform() {
}
});
} else if (callbacks[i] instanceof PasswordCallback) {
final JPasswordField password =
}
public void perform() {
}
});
} else if (callbacks[i] instanceof ConfirmationCallback) {
}
} else {
throw new UnsupportedCallbackException(
callbacks[i], "Unrecognized Callback");
}
}
/* Display the dialog */
"Confirmation", /* title */
null, /* icon */
/* Perform the OK actions */
{
}
}
}
/*
* Provides assistance with translating between JAAS and Swing
* confirmation dialogs.
*/
private static class ConfirmationInfo {
private int[] translations;
/* Set the confirmation callback handler */
throws UnsupportedCallbackException
{
switch (confirmationOptionType) {
translations = new int[] {
};
break;
translations = new int[] {
};
break;
translations = new int[] {
};
break;
/*
* There's no way to know if the default option means
* to cancel the login, but there isn't a better way
* to guess this.
*/
translations = new int[] {
};
break;
default:
throw new UnsupportedCallbackException(
"Unrecognized option type: " + confirmationOptionType);
}
switch (confirmationMessageType) {
case ConfirmationCallback.WARNING:
break;
case ConfirmationCallback.ERROR:
break;
break;
default:
throw new UnsupportedCallbackException(
"Unrecognized message type: " + confirmationMessageType);
}
}
/* Process the result returned by the Swing dialog */
return;
}
if (translations[i] == result) {
break;
}
}
}
}
}