当前位置: 首页>>代码示例>>Java>>正文


Java TextInputCallback.setText方法代码示例

本文整理汇总了Java中javax.security.auth.callback.TextInputCallback.setText方法的典型用法代码示例。如果您正苦于以下问题:Java TextInputCallback.setText方法的具体用法?Java TextInputCallback.setText怎么用?Java TextInputCallback.setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.security.auth.callback.TextInputCallback的用法示例。


在下文中一共展示了TextInputCallback.setText方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleTextInputCallback

import javax.security.auth.callback.TextInputCallback; //导入方法依赖的package包/类
private void handleTextInputCallback(TextInputCallback tic)
    throws IOException {
    // prompt for text input
    System.out.print(tic.getPrompt());
    System.out.flush();
    tic.setText((new BufferedReader
        (new InputStreamReader(System.in))).readLine());
}
 
开发者ID:1stResponder,项目名称:nics-tools,代码行数:9,代码来源:LoginTest.java

示例2: handleTextInput

import javax.security.auth.callback.TextInputCallback; //导入方法依赖的package包/类
protected void handleTextInput(TextInputCallback c) throws IOException
{
  BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  out.print(c.getPrompt());
  String text = in.readLine();
  if (text != null)
    c.setText(text);
}
 
开发者ID:vilie,项目名称:javify,代码行数:9,代码来源:ConsoleCallbackHandler.java

示例3: handleTextInput

import javax.security.auth.callback.TextInputCallback; //导入方法依赖的package包/类
protected synchronized void handleTextInput(TextInputCallback c)
{
  Frame ownerFrame = new Frame();
  Dialog dialog = new Dialog(ownerFrame);
  dialog.setTitle(c.getPrompt());
  dialog.setLayout(new BorderLayout());
  Label label = new Label(c.getPrompt());
  TextArea text = new TextArea(10, 40);
  if (c.getDefaultText() != null)
    {
      text.setText(c.getDefaultText());
    }
  Panel buttons = new Panel();
  Button ok = new Button(messages.getString("callback.ok"));
  ok.setActionCommand(ACTION_OK);
  ok.addActionListener(this);
  Button cancel = new Button(messages.getString("callback.cancel"));
  cancel.setActionCommand(ACTION_CANCEL);
  cancel.addActionListener(this);
  dialog.add(label, BorderLayout.NORTH);
  dialog.add(text, BorderLayout.CENTER);
  buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
  buttons.add(ok);
  buttons.add(cancel);
  dialog.add(buttons, BorderLayout.SOUTH);
  dialog.pack();
  dialog.show();
  try { wait(); }
  catch (InterruptedException ie) { }
  if (actionCommand.equals(ACTION_OK))
    {
      c.setText(text.getText());
    }
  dialog.dispose();
  ownerFrame.dispose();
}
 
开发者ID:vilie,项目名称:javify,代码行数:37,代码来源:AWTCallbackHandler.java

示例4: handle

import javax.security.auth.callback.TextInputCallback; //导入方法依赖的package包/类
/**
 * Retrieve the information requested in the provided <code>Callbacks</code>.
 * This implementation only recognizes {@link NameCallback},
 * {@link PasswordCallback} and {@link TextInputCallback}.
 * {@link TextInputCallback} is used to pass the various additional
 * parameters required for DIGEST authentication. 
 *
 * @param callbacks The set of <code>Callback</code>s to be processed
 *
 * @exception IOException if an input/output error occurs
 * @exception UnsupportedCallbackException if the login method requests
 *  an unsupported callback type
 */
@Override
public void handle(Callback callbacks[])
    throws IOException, UnsupportedCallbackException {

    for (int i = 0; i < callbacks.length; i++) {

        if (callbacks[i] instanceof NameCallback) {
            if (realm.getContainer().getLogger().isTraceEnabled())
                realm.getContainer().getLogger().trace(sm.getString("jaasCallback.username", username));
            ((NameCallback) callbacks[i]).setName(username);
        } else if (callbacks[i] instanceof PasswordCallback) {
            final char[] passwordcontents;
            if (password != null) {
                passwordcontents = password.toCharArray();
            } else {
                passwordcontents = new char[0];
            }
            ((PasswordCallback) callbacks[i]).setPassword
                (passwordcontents);
        } else if (callbacks[i] instanceof TextInputCallback) {
            TextInputCallback cb = ((TextInputCallback) callbacks[i]);
            if (cb.getPrompt().equals("nonce")) {
                cb.setText(nonce);
            } else if (cb.getPrompt().equals("nc")) {
                cb.setText(nc);
            } else if (cb.getPrompt().equals("cnonce")) {
                cb.setText(cnonce);
            } else if (cb.getPrompt().equals("qop")) {
                cb.setText(qop);
            } else if (cb.getPrompt().equals("realmName")) {
                cb.setText(realmName);
            } else if (cb.getPrompt().equals("md5a2")) {
                cb.setText(md5a2);
            } else if (cb.getPrompt().equals("authMethod")) {
                cb.setText(authMethod);
            } else {
                throw new UnsupportedCallbackException(callbacks[i]);
            }
        } else {
            throw new UnsupportedCallbackException(callbacks[i]);
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:57,代码来源:JAASCallbackHandler.java

示例5: handle

import javax.security.auth.callback.TextInputCallback; //导入方法依赖的package包/类
/**
 * Retrieve the information requested in the provided <code>Callbacks</code>.
 * This implementation only recognizes {@link NameCallback},
 * {@link PasswordCallback} and {@link TextInputCallback}.
 * {@link TextInputCallback} is ued to pass the various additional
 * parameters required for DIGEST authentication. 
 *
 * @param callbacks The set of <code>Callback</code>s to be processed
 *
 * @exception IOException if an input/output error occurs
 * @exception UnsupportedCallbackException if the login method requests
 *  an unsupported callback type
 */
public void handle(Callback callbacks[])
    throws IOException, UnsupportedCallbackException {

    for (int i = 0; i < callbacks.length; i++) {

        if (callbacks[i] instanceof NameCallback) {
            if (realm.getContainer().getLogger().isTraceEnabled())
                realm.getContainer().getLogger().trace(sm.getString("jaasCallback.username", username));
            ((NameCallback) callbacks[i]).setName(username);
        } else if (callbacks[i] instanceof PasswordCallback) {
            final char[] passwordcontents;
            if (password != null) {
                passwordcontents = password.toCharArray();
            } else {
                passwordcontents = new char[0];
            }
            ((PasswordCallback) callbacks[i]).setPassword
                (passwordcontents);
        } else if (callbacks[i] instanceof TextInputCallback) {
            TextInputCallback cb = ((TextInputCallback) callbacks[i]);
            if (cb.getPrompt().equals("nonce")) {
                cb.setText(nonce);
            } else if (cb.getPrompt().equals("nc")) {
                cb.setText(nc);
            } else if (cb.getPrompt().equals("cnonce")) {
                cb.setText(cnonce);
            } else if (cb.getPrompt().equals("qop")) {
                cb.setText(qop);
            } else if (cb.getPrompt().equals("realmName")) {
                cb.setText(realmName);
            } else if (cb.getPrompt().equals("md5a2")) {
                cb.setText(md5a2);
            } else if (cb.getPrompt().equals("authMethod")) {
                cb.setText(authMethod);
            } else {
                throw new UnsupportedCallbackException(callbacks[i]);
            }
        } else {
            throw new UnsupportedCallbackException(callbacks[i]);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:56,代码来源:JAASCallbackHandler.java

示例6: handle

import javax.security.auth.callback.TextInputCallback; //导入方法依赖的package包/类
/**
 * Retrieve the information requested in the provided <code>Callbacks</code>
 * . This implementation only recognizes {@link NameCallback},
 * {@link PasswordCallback} and {@link TextInputCallback}.
 * {@link TextInputCallback} is used to pass the various additional
 * parameters required for DIGEST authentication.
 *
 * @param callbacks
 *            The set of <code>Callback</code>s to be processed
 *
 * @exception IOException
 *                if an input/output error occurs
 * @exception UnsupportedCallbackException
 *                if the login method requests an unsupported callback type
 */
@Override
public void handle(Callback callbacks[]) throws IOException, UnsupportedCallbackException {

	for (int i = 0; i < callbacks.length; i++) {

		if (callbacks[i] instanceof NameCallback) {
			if (realm.getContainer().getLogger().isTraceEnabled())
				realm.getContainer().getLogger().trace(sm.getString("jaasCallback.username", username));
			((NameCallback) callbacks[i]).setName(username);
		} else if (callbacks[i] instanceof PasswordCallback) {
			final char[] passwordcontents;
			if (password != null) {
				passwordcontents = password.toCharArray();
			} else {
				passwordcontents = new char[0];
			}
			((PasswordCallback) callbacks[i]).setPassword(passwordcontents);
		} else if (callbacks[i] instanceof TextInputCallback) {
			TextInputCallback cb = ((TextInputCallback) callbacks[i]);
			if (cb.getPrompt().equals("nonce")) {
				cb.setText(nonce);
			} else if (cb.getPrompt().equals("nc")) {
				cb.setText(nc);
			} else if (cb.getPrompt().equals("cnonce")) {
				cb.setText(cnonce);
			} else if (cb.getPrompt().equals("qop")) {
				cb.setText(qop);
			} else if (cb.getPrompt().equals("realmName")) {
				cb.setText(realmName);
			} else if (cb.getPrompt().equals("md5a2")) {
				cb.setText(md5a2);
			} else if (cb.getPrompt().equals("authMethod")) {
				cb.setText(authMethod);
			} else {
				throw new UnsupportedCallbackException(callbacks[i]);
			}
		} else {
			throw new UnsupportedCallbackException(callbacks[i]);
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:57,代码来源:JAASCallbackHandler.java

示例7: handleTextInput

import javax.security.auth.callback.TextInputCallback; //导入方法依赖的package包/类
protected void handleTextInput(TextInputCallback c)
{
  c.setText("");
}
 
开发者ID:vilie,项目名称:javify,代码行数:5,代码来源:DefaultCallbackHandler.java

示例8: handleTextInput

import javax.security.auth.callback.TextInputCallback; //导入方法依赖的package包/类
protected void handleTextInput (final TextInputCallback callback)
  throws IOException
{
  final JDialog dialog = new JDialog ();
  Container content = dialog.getContentPane ();
  content.setLayout (new GridBagLayout ());

  content.add (new JLabel (callback.getPrompt ()),
                           new GridBagConstraints (0, 0, 1, 1, 0, 0,
                                                   GridBagConstraints.NORTHWEST,
                                                   GridBagConstraints.NONE,
                                                   new Insets (10, 10, 15, 5), 0, 0));

  final JTextArea text = new JTextArea (24, 80);
  text.setEditable (true);
  String _text;
  if ((_text = callback.getDefaultText ()) != null)
    text.setText (_text);
  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, 1, 1, 1, 1, 1,
                                       GridBagConstraints.CENTER,
                                       GridBagConstraints.BOTH,
                                       new Insets (5, 10, 5, 10), 0, 0));

  ActionListener listener = new ActionListener ()
    {
      public void actionPerformed (ActionEvent ae)
      {
        String cmd = ae.getActionCommand ();
        if (cmd.equals ("okay"))
          callback.setText (text.getText ());
        dialog.setVisible (false);
        synchronized (callback)
          {
            callback.notify ();
          }
      }
    };

  JPanel buttons = new JPanel ();
  buttons.setLayout (new FlowLayout (FlowLayout.RIGHT));
  JButton cancel = new JButton (messages.getString ("callback.cancel"));
  JButton okay = new JButton (messages.getString ("callback.ok"));
  cancel.setActionCommand ("cancel");
  cancel.addActionListener (listener);
  buttons.add (cancel);
  okay.setActionCommand ("okay");
  okay.addActionListener (listener);
  buttons.add (okay);
  content.add (buttons, new GridBagConstraints (0, 2, 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);
}
 
开发者ID:vilie,项目名称:javify,代码行数:65,代码来源:SwingCallbackHandler.java

示例9: handleTextInput

import javax.security.auth.callback.TextInputCallback; //导入方法依赖的package包/类
protected void handleTextInput (final TextInputCallback callback)
  throws IOException
{
  final JDialog dialog = new JDialog ();
  Container content = dialog.getContentPane ();
  content.setLayout (new GridBagLayout ());

  content.add (new JLabel (callback.getPrompt ()),
                           new GridBagConstraints (0, 0, 1, 1, 0, 0,
                                                   GridBagConstraints.NORTHWEST,
                                                   GridBagConstraints.NONE,
                                                   new Insets (10, 10, 15, 5), 0, 0));
  
  final JTextArea text = new JTextArea (24, 80);
  text.setEditable (true);
  String _text;
  if ((_text = callback.getDefaultText ()) != null)
    text.setText (_text);
  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, 1, 1, 1, 1, 1,
                                       GridBagConstraints.CENTER,
                                       GridBagConstraints.BOTH,
                                       new Insets (5, 10, 5, 10), 0, 0));

  ActionListener listener = new ActionListener ()
    {
      public void actionPerformed (ActionEvent ae)
      {
        String cmd = ae.getActionCommand ();
        if (cmd.equals ("okay"))
          callback.setText (text.getText ());
        dialog.setVisible (false);
        synchronized (callback)
          {
            callback.notify ();
          }
      }
    };

  JPanel buttons = new JPanel ();
  buttons.setLayout (new FlowLayout (FlowLayout.RIGHT));
  JButton cancel = new JButton (messages.getString ("callback.cancel"));
  JButton okay = new JButton (messages.getString ("callback.ok"));
  cancel.setActionCommand ("cancel");
  cancel.addActionListener (listener);
  buttons.add (cancel);
  okay.setActionCommand ("okay");
  okay.addActionListener (listener);
  buttons.add (okay);
  content.add (buttons, new GridBagConstraints (0, 2, 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);
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:65,代码来源:SwingCallbackHandler.java

示例10: getData

import javax.security.auth.callback.TextInputCallback; //导入方法依赖的package包/类
@Override
protected Object[] getData() {
    TextInputCallback t = new TextInputCallback("prmpt","defText");
    t.setText("new text");
    return new Object[] { new TextInputCallback("prompt","defaultTextInput"), t };
}
 
开发者ID:shannah,项目名称:cn1,代码行数:7,代码来源:TextInputCallbackTest.java


注:本文中的javax.security.auth.callback.TextInputCallback.setText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。