gpt4 book ai didi

java - 将代理与 JavaPNS 2.2 结合使用

转载 作者:行者123 更新时间:2023-11-30 11:38:38 31 4
gpt4 key购买 nike

我正在尝试使用 JavaPNS 2.2 通过代理推送到苹果设备。我的 java 应用程序在防火墙后面的 jBoss 上运行,与 apple 服务通信的唯一方法是通过该代理。

 public ApplePushNotification(File certificate){

super();
ProxyManager.setProxy("myproxy", "myport");
this.certificate = certificate;

}

我遇到了这个异常。

javapns.communication.exceptions.CommunicationException: Communication exception: java.io.IOException: Unable to tunnel through. Proxy returns "HTTP/1.1 407 Proxy Authentication Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )"

所以我阅读了 ProxyManager.java 文件以找到授权的方法。我发现了这个:

        /**
* Configure the authorization for the proxy configured through the setProxy method.
*
* @param username the user name to use
* @param password the password to use
*/
public static void setProxyBasicAuthorization(String username, String password) {
setProxyAuthorization(encodeProxyAuthorization(username, password));
}

我尝试使用像 ProxyManager.setProxy("myproxy", "myport"); 这样的静态方法,但我无法使用它。我真的很感激一些帮助。谢谢

附加链接:

http://code.google.com/p/javapns/source/browse/trunk/src/javapns/communication/ProxyManager.java

http://code.google.com/p/javapns/

最佳答案

最后,我让它可以与 JavaPNS 2.3 Beta 一起使用。

ProxyManager.setProxy("myProxy", "myPort");
ProxyManager.setProxyBasicAuthorization("username", "password");

如果你想让它运行JavaPNS 2.2,你需要自己实现它。但是使用 2.3 是一种更简单的方法。只需将 javaPNS_2.3_Beta_2.jar 作为库包含到您的项目中。

https://github.com/azinman/javapns/blob/master/JavaPNS_2.3_Beta_2.jar?raw=true

关于java - 将代理与 JavaPNS 2.2 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13562942/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com