📄 userauthentication.java
字号:
package proxy;
import java.io.InputStream;
import java.io.InterruptedIOException;
import java.io.OutputStream;
/**
* 用户密码认证认证处理
*
* @author liwen
*
*/
public class UserAuthentication {
public UserAuthentication() {
}
public boolean doSocksAuthorized(int authMothed, InputStream in,
OutputStream out) throws Exception {
if (authMothed == ProxyServer.AUTHENTICATION_TYPE_HTTP) {
return this.doHttpAuthorized(in, out);
}
return false;
}
private boolean doHttpAuthorized(InputStream in, OutputStream out)
throws Exception {
/*String Unauthorized = "HTTP/1.0 407 Unauthorized\r\n"
+ "Server: Simple Proxy\r\n"
+ "Proxy-Authenticate: Basic realm=\"Http Proxy Authorization\"\r\n"
+ "Cache-control: no-cache\r\n" + "\r\n"
+ "<Html><Body><H1> Unauthorized ...</H1></Body>\r\n";
try {
out.write(Unauthorized.getBytes());
out.flush();
} catch (InterruptedIOException e) {
// System.out.println(" put server InterruptedIOException: "
// + e);
}*/
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -