ADAL for Java Proxy

泪湿孤枕 提交于 2019-12-11 12:17:08

问题


I'm trying to add authentication through Azure AD in my app and for this purpose I select adal4j, because it's official library. But I surprised that this library doesn't support proxy(or am I wrong?). So, Does exist any workaround?


回答1:


There are two ways support proxy for Java.

  1. Command Line JVM Settings: The proxy settings are given to the JVM via command line arguments:

    java -Dhttp.proxyHost=proxyhostURL -Dhttp.proxyPort=proxyPortNumber -Dhttp.proxyUser=someUserName -Dhttp.proxyPassword=somePassword HelloWorldClass

  2. Setting System Properties in Code Add the following lines in your Java code so that JVM uses the proxy to make HTTP calls. This would, of course, require you to recompile your Java source. (The other methods do not require any recompilation):

    System.setProperty("http.proxyPort", "someProxyPort");
    System.setProperty("http.proxyUser", "someUserName");
    System.setProperty("http.proxyPassword", "somePassword");
    System.setProperty("http.proxyHost", "someProxyURL");
    

More information for Networking & Proxies & Properties in Java, Please refer to http://docs.oracle.com/javase/7/docs/technotes/guides/net/proxies.html and http://docs.oracle.com/javase/7/docs/technotes/guides/net/properties.html.

Best Regards.



来源:https://stackoverflow.com/questions/32522773/adal-for-java-proxy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!