本文整理汇总了Java中javax.security.auth.callback.TextOutputCallback.INFORMATION属性的典型用法代码示例。如果您正苦于以下问题:Java TextOutputCallback.INFORMATION属性的具体用法?Java TextOutputCallback.INFORMATION怎么用?Java TextOutputCallback.INFORMATION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.security.auth.callback.TextOutputCallback
的用法示例。
在下文中一共展示了TextOutputCallback.INFORMATION属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: handle
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");
}
}
}
示例6: 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");
}
}
示例7: setDName
/**
* @param name the X.500 distinguished name of the principal for whom the
* key/certificate are being generated.
* @throws UnsupportedCallbackException if no implementation of a name
* callback is available.
* @throws IOException if an I/O related exception occurs during the process.
* @throws IllegalArgumentException if the designated, or captured, value is
* not a valid X.500 distinguished name.
*/
private void setDName(String name) throws IOException,
UnsupportedCallbackException
{
if (name != null && name.trim().length() > 0)
name = name.trim();
else
{
// prompt user to provide one
String dnTxt = Messages.getString("GenKeyCmd.0"); //$NON-NLS-1$
String oDefault = Messages.getString("GenKeyCmd.6"); //$NON-NLS-1$
String lDefault = Messages.getString("GenKeyCmd.7"); //$NON-NLS-1$
String stDefault = Messages.getString("GenKeyCmd.8"); //$NON-NLS-1$
String cDefault = Messages.getString("GenKeyCmd.9"); //$NON-NLS-1$
String cnPrompt = Messages.getString("GenKeyCmd.10"); //$NON-NLS-1$
String oPrompt = Messages.getFormattedString("GenKeyCmd.11", oDefault); //$NON-NLS-1$
String ouPrompt = Messages.getString("GenKeyCmd.13"); //$NON-NLS-1$
String lPrompt = Messages.getFormattedString("GenKeyCmd.14", lDefault); //$NON-NLS-1$
String stPrompt = Messages.getFormattedString("GenKeyCmd.16", stDefault); //$NON-NLS-1$
String cPrompt = Messages.getFormattedString("GenKeyCmd.18", cDefault); //$NON-NLS-1$
TextOutputCallback dnCB = new TextOutputCallback(TextOutputCallback.INFORMATION,
dnTxt);
TextInputCallback cnCB = new TextInputCallback(cnPrompt);
TextInputCallback oCB = new TextInputCallback(oPrompt, oDefault);
TextInputCallback ouCB = new TextInputCallback(ouPrompt);
TextInputCallback lCB = new TextInputCallback(lPrompt, lDefault);
TextInputCallback sCB = new TextInputCallback(stPrompt, stDefault);
TextInputCallback cCB = new TextInputCallback(cPrompt, cDefault);
getCallbackHandler().handle(new Callback[] { dnCB, cnCB, oCB, ouCB, lCB, sCB, cCB });
StringBuilder sb = new StringBuilder();
// handle CN
name = parseUserPrompt(cnCB);
if (name != null && name.length() > 0)
sb.append("CN=").append(name); //$NON-NLS-1$
// handle O
name = parseUserPrompt(oCB);
if (name != null && name.length() > 0)
sb.append(",O=").append(name); //$NON-NLS-1$
// handle OU
name = parseUserPrompt(ouCB);
if (name != null && name.length() > 0)
sb.append(",OU=").append(name.trim()); //$NON-NLS-1$
// handle L
name = parseUserPrompt(lCB);
if (name != null && name.length() > 0)
sb.append(",L=").append(name.trim()); //$NON-NLS-1$
// handle ST
name = parseUserPrompt(sCB);
if (name != null && name.length() > 0)
sb.append(",ST=").append(name.trim()); //$NON-NLS-1$
// handle C
name = parseUserPrompt(cCB);
if (name != null && name.length() > 0)
sb.append(",C=").append(name.trim()); //$NON-NLS-1$
name = sb.toString().trim();
}
if (Configuration.DEBUG)
log.fine("dName=[" + name + "]"); //$NON-NLS-1$ //$NON-NLS-2$
distinguishedName = new X500DistinguishedName(name);
}
示例8: 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);
}
示例9: getData
@Override
protected Object[] getData() {
return new Object[] { new TextOutputCallback(
TextOutputCallback.INFORMATION, "message") };
}
示例10: 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");
}
}
}