组合视图 统一视图 树状图
toggle
K Chand
java.lang.SecurityException: Attempted to get proxy selector
2013年4月1日 上午2:14
答复

K Chand

等级: New Member

帖子: 2

加入日期: 2013年2月27日

最近的帖子

Hi,

I have created a portlet which is retrieve an image from url. I used following code to get image.
1URL profileURL = new URL("http://somedomain.com/some-profile-image-url.jpg");
2InputStream inputStream = profileURL.openStream();

And its working fine but when I enable Security Manager, its through following exception:
 1java.lang.SecurityException: Attempted to get proxy selector
 2    at com.liferay.portal.security.pacl.checker.BaseChecker.throwSecurityException(BaseChecker.java:259)
 3    at com.liferay.portal.security.pacl.checker.NetChecker.checkPermission(NetChecker.java:38)
 4    at com.liferay.portal.security.pacl.ActivePACLPolicy.checkPermission(ActivePACLPolicy.java:55)
 5    at com.liferay.portal.security.lang.PortalSecurityManager.checkPermission(PortalSecurityManager.java:103)
 6    at com.liferay.portal.security.lang.PortalSecurityManager.checkPermission(PortalSecurityManager.java:74)
 7    at java.net.ProxySelector.getDefault(ProxySelector.java:73)
 8    at sun.net.www.protocol.http.HttpURLConnection$5.run(HttpURLConnection.java:790)
 9    at java.security.AccessController.doPrivileged(Native Method)
10    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:786)
11    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:726)
12    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1049)
13    at java.net.URL.openStream(URL.java:1010)


I have tried to debug code and I found following method in NetChecker.java:
 1    protected boolean hasGetProxySelector() {
 2        if (JavaDetector.isJDK7()) {
 3            Class<?> callerClass8 = Reflection.getCallerClass(8);
 4            String className8 = callerClass8.getName();
 5            if (className8.startsWith(_CLASS_NAME_SOCKS_SOCKET_IMPL) &&
 6                CheckerUtil.isAccessControllerDoPrivileged(9)) {
 7                logGetProxySelector(callerClass8, 8);
 8                return true;
 9            }
10        }
11        else {
12            Class<?> callerClass7 = Reflection.getCallerClass(7);
13            String className7 = callerClass7.getName();
14            if (className7.startsWith(_CLASS_NAME_SOCKS_SOCKET_IMPL) &&
15                CheckerUtil.isAccessControllerDoPrivileged(8)) {
16                logGetProxySelector(callerClass7, 7);
17                return true;
18            }
19        }
20        return false;
21    }
22
23private static final String _CLASS_NAME_SOCKS_SOCKET_IMPL = "java.net.SocksSocketImpl$";

But here className7 is sun.net.www.protocol.http.HttpURLConnection$5 so (className7.startsWith(_CLASS_NAME_SOCKS_SOCKET_IMPL) is always return false.

How can I resolve this problem. Thanks in Advance.
匿名
RE: java.lang.SecurityException: Attempted to get proxy selector
2013年4月2日 上午6:04
答复

匿名

Hi,

I could reproduce this issue on Liferay 6.1.20. However, now it seems to be fixed on our latest branch, since I don't get the proxy selector error message anymore.
The NetChecker.java class is slightly different now. I guess LPS-33789 has something to do with this behavior.

Cheers,
Gábor
Ray Augé
RE: java.lang.SecurityException: Attempted to get proxy selector
2013年4月2日 上午6:51
答复

Ray Augé

LIFERAY STAFF

等级: Liferay Legend

帖子: 1196

加入日期: 2005年2月7日

最近的帖子

As stated by Gábor, this issue is fixed in more recent builds and the fixes should be released in the next little while.

Participate in the State of Liferay Community 2017. Help the community and even win some prizes!