本文整理汇总了Java中javax.security.auth.callback.TextOutputCallback.WARNING属性的典型用法代码示例。如果您正苦于以下问题:Java TextOutputCallback.WARNING属性的具体用法?Java TextOutputCallback.WARNING怎么用?Java TextOutputCallback.WARNING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.security.auth.callback.TextOutputCallback
的用法示例。
在下文中一共展示了TextOutputCallback.WARNING属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
@Override
public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException {
for (Callback callback : callbacks) {
if (callback instanceof TextOutputCallback) {
TextOutputCallback tc = (TextOutputCallback) callback;
switch (tc.getMessageType()) {
case TextOutputCallback.INFORMATION: logger.info(tc.getMessage()); break;
case TextOutputCallback.ERROR: logger.error(tc.getMessage()); break;
case TextOutputCallback.WARNING: logger.warn(tc.getMessage()); break;
}
} else if (callback instanceof NameCallback) {
NameCallback nc = (NameCallback) callback;
nc.setName(upn);
} else if (callback instanceof PasswordCallback) {
PasswordCallback pc = (PasswordCallback) callback;
pc.setPassword(this.password.toCharArray());
}
}
}
示例2: handleTextOutputCallback
private void handleTextOutputCallback(TextOutputCallback toc) {
debugMessage("Got TextOutputCallback");
// display the message according to the specified type
switch (toc.getMessageType()) {
case TextOutputCallback.INFORMATION:
debugMessage(toc.getMessage());
break;
case TextOutputCallback.ERROR:
debugMessage("ERROR: " + toc.getMessage());
break;
case TextOutputCallback.WARNING:
debugMessage("WARNING: " + toc.getMessage());
break;
default:
debugMessage("Unsupported message type: " +
toc.getMessageType());
}
}
示例3: processCallback
protected void processCallback(Callback callback) throws IOException, UnsupportedCallbackException
{
if (callback instanceof NameCallback) {
NameCallback namecb = (NameCallback)callback;
namecb.setName(context.getValue(SecurityContext.USER_NAME));
} else if (callback instanceof PasswordCallback) {
PasswordCallback passcb = (PasswordCallback)callback;
passcb.setPassword(context.getValue(SecurityContext.PASSWORD));
} else if (callback instanceof RealmCallback) {
RealmCallback realmcb = (RealmCallback)callback;
realmcb.setText(context.getValue(SecurityContext.REALM));
} else if (callback instanceof TextOutputCallback) {
TextOutputCallback textcb = (TextOutputCallback)callback;
if (textcb.getMessageType() == TextOutputCallback.INFORMATION) {
logger.info(textcb.getMessage());
} else if (textcb.getMessageType() == TextOutputCallback.WARNING) {
logger.warn(textcb.getMessage());
} else if (textcb.getMessageType() == TextOutputCallback.ERROR) {
logger.error(textcb.getMessage());
} else {
logger.debug("Auth message type {}, message {}", textcb.getMessageType(), textcb.getMessage());
}
} else {
throw new UnsupportedCallbackException(callback);
}
}
示例4: getIcon
private Icon getIcon(TextOutputCallback callback)
throws UnsupportedCallbackException {
switch (callback.getMessageType()) {
case TextOutputCallback.INFORMATION:
return iconFactory.getInfoIcon(iconFactory.getSmallIconSize());
case TextOutputCallback.WARNING:
return iconFactory.getWarningIcon(iconFactory.getSmallIconSize());
case TextOutputCallback.ERROR:
return iconFactory.getErrorIcon(iconFactory.getSmallIconSize());
default:
throw new UnsupportedCallbackException(callback,
"Unrecognized message type");
}
}
示例5: testTextOutputCallback_02
/**
* Test for TextOutputCallback(int msgType,String msg) ctor
*/
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");
}
}
示例6: handleTextOutput
protected void handleTextOutput (final TextOutputCallback callback)
throws IOException
{
final JDialog dialog = new JDialog ();
switch (callback.getMessageType ())
{
case TextOutputCallback.ERROR:
dialog.setTitle (messages.getString ("callback.error"));
break;
case TextOutputCallback.WARNING:
dialog.setTitle (messages.getString ("callback.warning"));
break;
case TextOutputCallback.INFORMATION:
dialog.setTitle (messages.getString ("callback.information"));
break;
}
Container content = dialog.getContentPane ();
content.setLayout (new GridBagLayout ());
final JTextArea text = new JTextArea (24, 80);
text.setEditable (false);
text.setText (callback.getMessage ());
text.setFont (new Font ("Monospaced", Font.PLAIN, 12));
JScrollPane textPane = new JScrollPane (text,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
content.add (textPane,
new GridBagConstraints (0, 0, 1, 1, 1, 1,
GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
new Insets (10, 10, 5, 10), 0, 0));
ActionListener listener = new ActionListener ()
{
public void actionPerformed (ActionEvent ae)
{
dialog.setVisible (false);
synchronized (callback)
{
callback.notify ();
}
}
};
JButton okay = new JButton (messages.getString ("callback.ok"));
okay.setActionCommand ("okay");
okay.addActionListener (listener);
content.add (okay, new GridBagConstraints (0, 1, 1, 1, 0, 0,
GridBagConstraints.SOUTHEAST,
GridBagConstraints.NONE,
new Insets (0, 10, 10, 10), 0, 0));
dialog.setResizable (true);
dialog.pack ();
dialog.setVisible (true);
dialog.getRootPane ().setDefaultButton (okay);
waitForInput (dialog, callback);
}
示例7: handle
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
for (int i = 0; i < callbacks.length; i++)
{
if (callbacks[i] instanceof TextOutputCallback)
{
TextOutputCallback toc = (TextOutputCallback)callbacks[i];
switch (toc.getMessageType())
{
case TextOutputCallback.INFORMATION:
System.out.println(toc.getMessage());
break;
case TextOutputCallback.ERROR:
System.out.println("ERROR: " + toc.getMessage());
break;
case TextOutputCallback.WARNING:
System.out.println("WARNING: " + toc.getMessage());
break;
default:
throw new IOException("Unsupported message type: " + toc.getMessageType());
}
}
else if (callbacks[i] instanceof NameCallback)
{
NameCallback nc = (NameCallback)callbacks[i];
System.err.print(nc.getPrompt());
System.err.flush();
nc.setName((new BufferedReader(new InputStreamReader(System.in))).readLine());
}
else if (callbacks[i] instanceof PasswordCallback)
{
PasswordCallback pc = (PasswordCallback)callbacks[i];
System.err.print(pc.getPrompt());
System.err.flush();
pc.setPassword(readPassword(System.in));
}
else if (callbacks[i] instanceof JRadiusCallback)
{
JRadiusCallback rcb = (JRadiusCallback)callbacks[i];
RadiusClient rc = rcb.getRadiusClient();
AttributeList list = new AttributeList();
rcb.setAuthAttributes(list);
rcb.setAcctAttributes(list);
System.err.print("Radius Server: ");
System.err.flush();
rc.setRemoteInetAddress(InetAddress.getByName((new BufferedReader(new InputStreamReader(System.in))).readLine()));
System.err.print("Shared Secret: ");
System.err.flush();
rc.setSharedSecret((new BufferedReader(new InputStreamReader(System.in))).readLine());
System.err.print("Auth Protocol: ");
System.err.flush();
String input = new BufferedReader(new InputStreamReader(System.in)).readLine();
rcb.setRadiusAuthenticator(RadiusClient.getAuthProtocol(input));
promptAttribute("NAS-Identifier", list);
}
else
{
throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
}
}
}