首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在JavaPNS 2.2中使用代理

在JavaPNS 2.2中使用代理
EN

Stack Overflow用户
提问于 2012-11-26 18:31:14
回答 1查看 2.5K关注 0票数 2

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

代码语言:javascript
复制
 public ApplePushNotification(File certificate){

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

}

我得到了这个异常。

代码语言:javascript
复制
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文件以找到授权的方法。我发现了这个:

代码语言:javascript
复制
        /**
         * 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/

EN

回答 1

Stack Overflow用户

发布于 2012-11-27 15:37:15

最后,我让它在JavaPNS 2.3Beta中工作。

代码语言:javascript
复制
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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13562942

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档