本文整理汇总了Java中org.littleshoot.proxy.ProxyAuthenticator类的典型用法代码示例。如果您正苦于以下问题:Java ProxyAuthenticator类的具体用法?Java ProxyAuthenticator怎么用?Java ProxyAuthenticator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProxyAuthenticator类属于org.littleshoot.proxy包,在下文中一共展示了ProxyAuthenticator类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setupProxy
import org.littleshoot.proxy.ProxyAuthenticator; //导入依赖的package包/类
@BeforeClass
public static void setupProxy() {
ProxyAuthenticator auth = new ProxyAuthenticator() {
@Override
public boolean authenticate(String username, String password) {
return proxyUsername.equals(username) && proxyPassword.equals(password);
}
@Override
public String getRealm() {
return null;
}
};
server = DefaultHttpProxyServer.bootstrap().withPort(proxyPort).withProxyAuthenticator(auth).start();
setProxySettingForClient();
}
开发者ID:Talend,项目名称:components,代码行数:20,代码来源:SalesforceProxyTestIT.java
示例2: DefaultHttpProxyServer
import org.littleshoot.proxy.ProxyAuthenticator; //导入依赖的package包/类
private DefaultHttpProxyServer(String name,
TransportProtocol transportProtocol,
InetSocketAddress address,
SslEngineSource sslEngineSource,
boolean authenticateSslClients,
ProxyAuthenticator proxyAuthenticator,
ChainedProxyManager chainProxyManager,
MitmManager mitmManager,
HttpFiltersSource filterSource,
boolean useDnsSec,
boolean transparent,
int idleConnectionTimeout,
Collection<ActivityTracker> activityTrackers) {
this(new ServerGroup(name), transportProtocol, address,
sslEngineSource, authenticateSslClients, proxyAuthenticator,
chainProxyManager,
mitmManager, filterSource, useDnsSec, transparent,
idleConnectionTimeout, activityTrackers);
}
开发者ID:Mobideck,项目名称:appdeck-android,代码行数:20,代码来源:DefaultHttpProxyServer.java
示例3: DefaultHttpProxyServerBootstrap
import org.littleshoot.proxy.ProxyAuthenticator; //导入依赖的package包/类
private DefaultHttpProxyServerBootstrap(
ServerGroup serverGroup,
TransportProtocol transportProtocol,
InetSocketAddress requestedAddress,
SslEngineSource sslEngineSource,
boolean authenticateSslClients,
ProxyAuthenticator proxyAuthenticator,
ChainedProxyManager chainProxyManager,
MitmManager mitmManager,
HttpFiltersSource filtersSource,
boolean transparent, int idleConnectionTimeout,
Collection<ActivityTracker> activityTrackers,
int connectTimeout, HostResolver serverResolver,
long readThrottleBytesPerSecond,
long writeThrottleBytesPerSecond,
InetSocketAddress localAddress,
String proxyAlias) {
this.serverGroup = serverGroup;
this.transportProtocol = transportProtocol;
this.requestedAddress = requestedAddress;
this.port = requestedAddress.getPort();
this.sslEngineSource = sslEngineSource;
this.authenticateSslClients = authenticateSslClients;
this.proxyAuthenticator = proxyAuthenticator;
this.chainProxyManager = chainProxyManager;
this.mitmManager = mitmManager;
this.filtersSource = filtersSource;
this.transparent = transparent;
this.idleConnectionTimeout = idleConnectionTimeout;
if (activityTrackers != null) {
this.activityTrackers.addAll(activityTrackers);
}
this.connectTimeout = connectTimeout;
this.serverResolver = serverResolver;
this.readThrottleBytesPerSecond = readThrottleBytesPerSecond;
this.writeThrottleBytesPerSecond = writeThrottleBytesPerSecond;
this.localAddress = localAddress;
this.proxyAlias = proxyAlias;
}
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:40,代码来源:DefaultHttpProxyServer.java
示例4: DefaultHttpProxyServerBootstrap
import org.littleshoot.proxy.ProxyAuthenticator; //导入依赖的package包/类
private DefaultHttpProxyServerBootstrap(
DefaultHttpProxyServer original,
TransportProtocol transportProtocol,
InetSocketAddress requestedAddress,
SslEngineSource sslEngineSource,
boolean authenticateSslClients,
ProxyAuthenticator proxyAuthenticator,
ChainedProxyManager chainProxyManager,
MitmManager mitmManager,
HttpFiltersSource filtersSource,
boolean transparent, int idleConnectionTimeout,
Collection<ActivityTracker> activityTrackers,
int connectTimeout, HostResolver serverResolver,
long readThrottleBytesPerSecond, long writeThrottleBytesPerSecond) {
this.original = original;
this.transportProtocol = transportProtocol;
this.requestedAddress = requestedAddress;
this.port = requestedAddress.getPort();
this.sslEngineSource = sslEngineSource;
this.authenticateSslClients = authenticateSslClients;
this.proxyAuthenticator = proxyAuthenticator;
this.chainProxyManager = chainProxyManager;
this.filtersSource = filtersSource;
this.transparent = transparent;
this.idleConnectionTimeout = idleConnectionTimeout;
if (activityTrackers != null) {
this.activityTrackers.addAll(activityTrackers);
}
this.connectTimeout = connectTimeout;
this.serverResolver = serverResolver;
this.readThrottleBytesPerSecond = readThrottleBytesPerSecond;
this.writeThrottleBytesPerSecond = writeThrottleBytesPerSecond;
}
开发者ID:Elitward,项目名称:LittleProxy,代码行数:34,代码来源:DefaultHttpProxyServer.java
示例5: start
import org.littleshoot.proxy.ProxyAuthenticator; //导入依赖的package包/类
public static HttpProxyServer start() {
System.out.println("*** STARTED TEST PROXY SERVER ***");
HttpProxyServer proxyServer = DefaultHttpProxyServer.bootstrap().withPort(8089).withProxyAuthenticator(new ProxyAuthenticator() {
@Override
public boolean authenticate(String username, String password) {
return username.equals("test") && password.equals("works");
}
}).start();
return proxyServer;
}
开发者ID:jirkapinkas,项目名称:sitemonitoring-production,代码行数:11,代码来源:ProxyServerUtil.java
示例6: DefaultHttpProxyServerBootstrap
import org.littleshoot.proxy.ProxyAuthenticator; //导入依赖的package包/类
private DefaultHttpProxyServerBootstrap(
DefaultHttpProxyServer original,
TransportProtocol transportProtocol,
InetSocketAddress address,
SslEngineSource sslEngineSource,
boolean authenticateSslClients,
ProxyAuthenticator proxyAuthenticator,
ChainedProxyManager chainProxyManager,
MitmManager mitmManager,
HttpFiltersSource filtersSource, boolean useDnsSec,
boolean transparent, int idleConnectionTimeout,
Collection<ActivityTracker> activityTrackers) {
this.original = original;
this.transportProtocol = transportProtocol;
this.address = address;
this.port = address.getPort();
this.sslEngineSource = sslEngineSource;
this.authenticateSslClients = authenticateSslClients;
this.proxyAuthenticator = proxyAuthenticator;
this.chainProxyManager = chainProxyManager;
this.filtersSource = filtersSource;
this.useDnsSec = useDnsSec;
this.transparent = transparent;
this.idleConnectionTimeout = idleConnectionTimeout;
if (activityTrackers != null) {
this.activityTrackers.addAll(activityTrackers);
}
}
开发者ID:Mobideck,项目名称:appdeck-android,代码行数:29,代码来源:DefaultHttpProxyServer.java
示例7: startProxy
import org.littleshoot.proxy.ProxyAuthenticator; //导入依赖的package包/类
/**
* Runs a proxy server counting requests
* @param authenticating true if the proxy should require authentication
* @throws Exception if an error occurred
*/
private void startProxy(boolean authenticating) throws Exception {
proxyPort = findPort();
HttpProxyServerBootstrap bootstrap = DefaultHttpProxyServer.bootstrap()
.withPort(proxyPort)
.withFiltersSource(new HttpFiltersSourceAdapter() {
public HttpFilters filterRequest(HttpRequest originalRequest,
ChannelHandlerContext ctx) {
return new HttpFiltersAdapter(originalRequest) {
@Override
public void proxyToServerRequestSent() {
proxyCounter++;
}
};
}
});
if (authenticating) {
bootstrap = bootstrap.withProxyAuthenticator(new ProxyAuthenticator() {
@Override
public boolean authenticate(String userName, String password) {
return PROXY_USERNAME.equals(userName) &&
PROXY_PASSWORD.equals(password);
}
@Override
public String getRealm() {
return "gradle-download-task";
}
});
}
proxy = bootstrap.start();
}
开发者ID:michel-kraemer,项目名称:gradle-download-task,代码行数:40,代码来源:ProxyTest.java
示例8: authenticationRequired
import org.littleshoot.proxy.ProxyAuthenticator; //导入依赖的package包/类
/**
* <p>
* Checks whether the given HttpRequest requires authentication.
* </p>
*
* <p>
* If the request contains credentials, these are checked.
* </p>
*
* <p>
* If authentication is still required, either because no credentials were
* provided or the credentials were wrong, this writes a 407 response to the
* client.
* </p>
*
* @param request
* @return
*/
private boolean authenticationRequired(HttpRequest request) {
if (authenticated.get()) {
return false;
}
final ProxyAuthenticator authenticator = proxyServer
.getProxyAuthenticator();
if (authenticator == null)
return false;
if (!request.headers().contains(HttpHeaders.Names.PROXY_AUTHORIZATION)) {
writeAuthenticationRequired(authenticator.getRealm());
return true;
}
List<String> values = request.headers().getAll(
HttpHeaders.Names.PROXY_AUTHORIZATION);
String fullValue = values.iterator().next();
String value = StringUtils.substringAfter(fullValue, "Basic ").trim();
byte[] decodedValue = Base64.decodeBase64(value.getBytes(Charset.forName("UTF-8")));
String decodedString = new String(decodedValue, Charset.forName("UTF-8"));
String userName = StringUtils.substringBefore(decodedString, ":");
String password = StringUtils.substringAfter(decodedString, ":");
if (!authenticator.authenticate(userName, password)) {
writeAuthenticationRequired(authenticator.getRealm());
return true;
}
LOG.debug("Got proxy authorization!");
// We need to remove the header before sending the request on.
String authentication = request.headers().get(
HttpHeaders.Names.PROXY_AUTHORIZATION);
LOG.debug(authentication);
request.headers().remove(HttpHeaders.Names.PROXY_AUTHORIZATION);
authenticated.set(true);
return false;
}
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:60,代码来源:ClientToProxyConnection.java
示例9: getProxyAuthenticator
import org.littleshoot.proxy.ProxyAuthenticator; //导入依赖的package包/类
protected ProxyAuthenticator getProxyAuthenticator() {
return proxyAuthenticator;
}
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:4,代码来源:DefaultHttpProxyServer.java
示例10: withProxyAuthenticator
import org.littleshoot.proxy.ProxyAuthenticator; //导入依赖的package包/类
@Override
public HttpProxyServerBootstrap withProxyAuthenticator(
ProxyAuthenticator proxyAuthenticator) {
this.proxyAuthenticator = proxyAuthenticator;
return this;
}
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:7,代码来源:DefaultHttpProxyServer.java
示例11: authenticationRequired
import org.littleshoot.proxy.ProxyAuthenticator; //导入依赖的package包/类
/**
* <p>
* Checks whether the given HttpRequest requires authentication.
* </p>
*
* <p>
* If the request contains credentials, these are checked.
* </p>
*
* <p>
* If authentication is still required, either because no credentials were
* provided or the credentials were wrong, this writes a 407 response to the
* client.
* </p>
*
* @param request
* @return
*/
private boolean authenticationRequired(HttpRequest request) {
if (authenticated.get()) {
return false;
}
final ProxyAuthenticator authenticator = proxyServer
.getProxyAuthenticator();
if (authenticator == null)
return false;
if (!request.headers().contains(HttpHeaders.Names.PROXY_AUTHORIZATION)) {
writeAuthenticationRequired();
return true;
}
List<String> values = request.headers().getAll(
HttpHeaders.Names.PROXY_AUTHORIZATION);
String fullValue = values.iterator().next();
String value = StringUtils.substringAfter(fullValue, "Basic ")
.trim();
byte[] decodedValue = Base64.decodeBase64(value);
try {
String decodedString = new String(decodedValue, "UTF-8");
String userName = StringUtils.substringBefore(decodedString,
":");
String password = StringUtils.substringAfter(decodedString,
":");
if (!authenticator.authenticate(userName,
password)) {
writeAuthenticationRequired();
return true;
}
} catch (UnsupportedEncodingException e) {
LOG.error("Could not decode?", e);
}
LOG.info("Got proxy authorization!");
// We need to remove the header before sending the request on.
String authentication = request.headers().get(
HttpHeaders.Names.PROXY_AUTHORIZATION);
LOG.info(authentication);
request.headers().remove(HttpHeaders.Names.PROXY_AUTHORIZATION);
authenticated.set(true);
return false;
}
开发者ID:Elitward,项目名称:LittleProxy,代码行数:66,代码来源:ClientToProxyConnection.java
注:本文中的org.littleshoot.proxy.ProxyAuthenticator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论