我正在尝试制定正确的 Java 安全策略。我的代码需要解析并连接到两者login.salesforce.com
,并且xx99.salesforce.com
哪里xx99
可以取大约 100 个不同的值中的任何一个。
如果我对特定主机进行硬编码,它就可以工作 - 例如
permission java.net.SocketPermission "login.salesforce.com:443", "connect, resolve";
permission java.net.SocketPermission "na30.salesforce.com:443", "connect, resolve";
但这会导致我在我的安全策略文件中添加大约 100 个条目以涵盖所有可能性,并且 Salesforce 一直在添加新实例,使维护成为一场噩梦。
如果我通配任何主机/端口,它会起作用:
permission java.net.SocketPermission "*", "connect, resolve";
但显而易见的答案失败了——这个
permission java.net.SocketPermission "*.salesforce.com:443", "connect, resolve";
给我
2016-03-20 22:19:56,024 [user:*admin] [pipeline:Pipeline1] [thread:preview-pool-1-thread-1] WARN Pipeline - Stage 'com_streamsets_stage_destination_waveanalytics_WaveAnalyticsDTarget_1' initialization error: java.security.AccessControlException: access denied ("java.net.SocketPermission" "login.salesforce.com:443" "connect,resolve")
java.security.AccessControlException: access denied ("java.net.SocketPermission" "login.salesforce.com:443" "connect,resolve")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
at java.security.AccessController.checkPermission(AccessController.java:884)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1051)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:510)
...etc...
盯着这个已经有一段时间了——我就是不明白!