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


Java TextInputCallback类代码示例

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


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

示例1: fillResultFromCallback

import javax.security.auth.callback.TextInputCallback; //导入依赖的package包/类
private void fillResultFromCallback ( final Callback cb, final javax.security.auth.callback.Callback jcb )
{
    if ( cb instanceof TextCallback && jcb instanceof TextInputCallback )
    {
        ( (TextCallback)cb ).setValue ( ( (TextInputCallback)jcb ).getText () );
    }
    else if ( cb instanceof UserNameCallback && jcb instanceof NameCallback )
    {
        ( (UserNameCallback)cb ).setValue ( ( (NameCallback)jcb ).getName () );
    }
    else if ( cb instanceof PasswordCallback && jcb instanceof javax.security.auth.callback.PasswordCallback )
    {
        ( (PasswordCallback)cb ).setPassword ( String.valueOf ( ( (javax.security.auth.callback.PasswordCallback)jcb ).getPassword () ) );
    }
    else
    {
        cb.cancel ();
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:20,代码来源:JavaCallbackHandler.java

示例2: convert

import javax.security.auth.callback.TextInputCallback; //导入依赖的package包/类
private javax.security.auth.callback.Callback convert ( final Callback cb )
{
    if ( cb instanceof UserNameCallback )
    {
        return new NameCallback ( ( (UserNameCallback)cb ).getLabel () );
    }
    else if ( cb instanceof TextCallback )
    {
        return new TextInputCallback ( ( (TextCallback)cb ).getLabel () );
    }
    if ( cb instanceof PasswordCallback )
    {
        return new javax.security.auth.callback.PasswordCallback ( ( (PasswordCallback)cb ).getLabel (), false );
    }
    return null;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:17,代码来源:JavaCallbackHandler.java

示例3: addLoginCallbackMessage

import javax.security.auth.callback.TextInputCallback; //导入依赖的package包/类
private void addLoginCallbackMessage(Callback[] callbacks)
throws UnsupportedCallbackException
{
    int i = 0;
    try {
        for (i = 0; i < callbacks.length; i++) {
            if (callbacks[i] instanceof TextOutputCallback) {
                handleTextOutputCallback((TextOutputCallback)callbacks[i]);
            } else if (callbacks[i] instanceof NameCallback) {
                handleNameCallback((NameCallback)callbacks[i]);
            } else if (callbacks[i] instanceof PasswordCallback) {
                handlePasswordCallback((PasswordCallback)callbacks[i]);
            } else if (callbacks[i] instanceof TextInputCallback) {
                handleTextInputCallback((TextInputCallback)callbacks[i]);
            } else if (callbacks[i] instanceof ChoiceCallback) {
                handleChoiceCallback((ChoiceCallback)callbacks[i]);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
        throw new UnsupportedCallbackException(callbacks[i],e.getMessage());
    }
}
 
开发者ID:1stResponder,项目名称:nics-tools,代码行数:24,代码来源:LoginTest.java

示例4: addLoginCallbackMessage

import javax.security.auth.callback.TextInputCallback; //导入依赖的package包/类
private void addLoginCallbackMessage(Callback[] callbacks)
throws UnsupportedCallbackException {
    int i = 0;
    try {
        for (i = 0; i < callbacks.length; i++) {
            if (callbacks[i] instanceof TextOutputCallback) {
                handleTextOutputCallback((TextOutputCallback)callbacks[i]);
            } else if (callbacks[i] instanceof NameCallback) {
                handleNameCallback((NameCallback)callbacks[i]);
            } else if (callbacks[i] instanceof PasswordCallback) {
                handlePasswordCallback((PasswordCallback)callbacks[i]);
            } else if (callbacks[i] instanceof TextInputCallback) {
                handleTextInputCallback((TextInputCallback)callbacks[i]);
            } else if (callbacks[i] instanceof ChoiceCallback) {
                handleChoiceCallback((ChoiceCallback)callbacks[i]);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
        throw new UnsupportedCallbackException(callbacks[i],e.getMessage());
    }
}
 
开发者ID:1stResponder,项目名称:nics-tools,代码行数:23,代码来源:FailedLoginTest.java

示例5: 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

示例6: parseUserPrompt

import javax.security.auth.callback.TextInputCallback; //导入依赖的package包/类
private String parseUserPrompt(TextInputCallback ticb)
{
  String result = ticb.getText();
  if (result == null || result.trim().length() == 0)
    result = ticb.getDefaultText();
  else if (result.trim().equals(".")) //$NON-NLS-1$
    result = null;
  else
    result = result.trim();

  return result;
}
 
开发者ID:vilie,项目名称:javify,代码行数:13,代码来源:GenKeyCmd.java

示例7: handle

import javax.security.auth.callback.TextInputCallback; //导入依赖的package包/类
public void handle(Callback[] callbacks)
  throws IOException, UnsupportedCallbackException
{
  if (callbacks == null)
    throw new NullPointerException();
  for (int i = 0; i < callbacks.length; i++)
    {
      if (callbacks[i] == null)
        continue;
      if (callbacks[i] instanceof ChoiceCallback)
        handleChoice((ChoiceCallback) callbacks[i]);
      else if (callbacks[i] instanceof ConfirmationCallback)
        handleConfirmation((ConfirmationCallback) callbacks[i]);
      else if (callbacks[i] instanceof LanguageCallback)
        handleLanguage((LanguageCallback) callbacks[i]);
      else if (callbacks[i] instanceof NameCallback)
        handleName((NameCallback) callbacks[i]);
      else if (callbacks[i] instanceof PasswordCallback)
        handlePassword((PasswordCallback) callbacks[i]);
      else if (callbacks[i] instanceof TextInputCallback)
        handleTextInput((TextInputCallback) callbacks[i]);
      else if (callbacks[i] instanceof TextOutputCallback)
        handleTextOutput((TextOutputCallback) callbacks[i]);
      else
        handleOther(callbacks[i]);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:28,代码来源:AbstractCallbackHandler.java

示例8: 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

示例9: 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

示例10: assertDeserialized

import javax.security.auth.callback.TextInputCallback; //导入依赖的package包/类
public void assertDeserialized(Serializable golden, Serializable test) {
    assertTrue(test instanceof TextInputCallback);
    assertEquals(((TextInputCallback) golden).getDefaultText(),
            ((TextInputCallback) test).getDefaultText());
    assertEquals(((TextInputCallback) golden).getPrompt(),
            ((TextInputCallback) test).getPrompt());
    assertEquals(((TextInputCallback) golden).getText(),
            ((TextInputCallback) test).getText());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:10,代码来源:TextInputCallbackTest.java

示例11: 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

示例12: 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

示例13: 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

示例14: setDName

import javax.security.auth.callback.TextInputCallback; //导入依赖的package包/类
/**
 * @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);
}
 
开发者ID:vilie,项目名称:javify,代码行数:77,代码来源:GenKeyCmd.java

示例15: handleTextInput

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


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