xauthenticator.java

来自「java写的浏览器」· Java 代码 · 共 48 行

JAVA
48
字号
/****************************************************************
*              XBrowser  -  eXtended web Browser                *
*                                                               *
*           Copyright (c) 2000-2001  Armond Avanes              *
*     Refer to ReadMe & License files for more information      *
*                                                               *
*                                                               *
*                      By: Armond Avanes                        *
*       Armond555@yahoo.com     &    Armond333@yahoo.com        *
*                http://xbrowser.sourceforge.net/               *
*****************************************************************/
package xbrowser.util;

import java.net.*;

/** Standard authenticator object required by HttpURLConnection
 *  for WWW and Proxy Authorization.
 */
public class XAuthenticator extends Authenticator
{
	public static XAuthenticator getInstance()
	{
		if( instance==null )
			instance = new XAuthenticator();

		return instance;
	}

	private XAuthenticator()
	{
		Authenticator.setDefault(this);
	}

	public void setAuthenticationInfo(String user, String pass)
	{
		passAuth = new PasswordAuthentication(user, pass.toCharArray());
	}

	protected PasswordAuthentication getPasswordAuthentication()
	{
		return passAuth;
	}

// Attributes:
	private static XAuthenticator instance = null;
	private PasswordAuthentication passAuth = null;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?