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


Java TextOutputCallback.ERROR属性代码示例

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


在下文中一共展示了TextOutputCallback.ERROR属性的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());
		}
	}

}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:22,代码来源:UpnPwdCallbackHandler.java

示例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());
    }
}
 
开发者ID:1stResponder,项目名称:nics-tools,代码行数:19,代码来源:LoginTest.java

示例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);
  }
}
 
开发者ID:apache,项目名称:apex-core,代码行数:26,代码来源:DefaultCallbackHandler.java

示例4: prompt4NewPassword

private boolean prompt4NewPassword(CallbackHandler handler,
                                   Callback[] prompts, Callback[] errors)
    throws IOException, UnsupportedCallbackException
{
  String p = Messages.getFormattedString("KeyCloneCmd.28", //$NON-NLS-1$
                                         new String[] { destinationAlias,
                                                        String.valueOf(keyPasswordChars) });
  PasswordCallback pcb = new PasswordCallback(p, false);
  prompts[0] = pcb;
  handler.handle(prompts);
  char[] pwd1 = pcb.getPassword();
  pcb.clearPassword();
  if (pwd1 == null || pwd1.length == 0)
    {
      newKeyPasswordChars = (char[]) keyPasswordChars.clone();
      return true;
    }

  if (pwd1.length < 6)
    {
      errors[0] = new TextOutputCallback(TextOutputCallback.ERROR,
                                         Messages.getString("StorePasswdCmd.21")); //$NON-NLS-1$
      handler.handle(errors);
      return false;
    }

  newKeyPasswordChars = pwd1;
  return true;
}
 
开发者ID:vilie,项目名称:javify,代码行数:29,代码来源:KeyCloneCmd.java

示例5: customizeCallbacks

private void customizeCallbacks(int state, String msg) throws AuthLoginException {
    switch (state) {
        
        case STATE_ERROR: {
            TextOutputCallback toc = new TextOutputCallback(TextOutputCallback.ERROR, "Impersonation failed");
            replaceCallback(STATE_ERROR, 0, toc);
            break;
        }

        default:
    }
}
 
开发者ID:javedmshah,项目名称:impersonation-policy,代码行数:12,代码来源:ImpersonationModule.java

示例6: abort

/**
 * <p>
 * This method is called if the LoginContext's overall authentication failed.
 * (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules did
 * not succeed).
 * <p>
 * If this LoginModule's own authentication attempt succeeded (checked by
 * retrieving the private state saved by the {@code login} and
 * {@code commit} methods), then this method cleans up any state that was
 * originally saved.
 * <p>
 *
 * @return false if this LoginModule's own login and/or commit attempts
 *         failed, and true otherwise.
 */
@Override
public boolean abort() {
  if (!succeeded) {
    Callback[] callbacks = new Callback[1];
    callbacks[0] = new TextOutputCallback(TextOutputCallback.ERROR,
        LoginUtils.LOGIN_FAILED);
    try {
      callbackHandler.handle(callbacks);
    } catch (IOException | UnsupportedCallbackException ex) {
      // NO-OP.
    }
    return false;
  }
  if (!commitSucceeded) {
    // login succeeded but overall authentication failed
    succeeded = false;
    username = null;
    suffix = "";
    if (password != null) {
      for (int i = 0; i < password.length; i++) {
        password[i] = ' ';
      }
      password = null;
    }
    userPrincipal = null;
  } else {
    // overall authentication succeeded and commit succeeded,
    // but someone else's commit failed
    logout();
  }
  return true;
}
 
开发者ID:jspresso,项目名称:jspresso-ce,代码行数:47,代码来源:DevelopmentLoginModule.java

示例7: 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");
  }
}
 
开发者ID:jspresso,项目名称:jspresso-ce,代码行数:14,代码来源:DialogCallbackHandler.java

示例8: 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");
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:10,代码来源:TextOutputCallbackTest.java

示例9: 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);
}
 
开发者ID:vilie,项目名称:javify,代码行数:58,代码来源:SwingCallbackHandler.java

示例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");
	    }
	}
}
 
开发者ID:coova,项目名称:jradius,代码行数:66,代码来源:JAASAuthenticationTest.java


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