フォーラム

ホーム » 1. Marketplace App Development

構造的に表示 平面上に表示 ツリー上に表示
toggle
K Chand
java.lang.SecurityException: Attempted to get proxy selector
2013/04/01 2:14
答え

K Chand

ランク: New Member

投稿: 2

参加年月日: 2013/02/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/04/02 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/04/02 6:51
答え

Ray Augé

LIFERAY STAFF

ランク: Liferay Legend

投稿: 1196

参加年月日: 2005/02/07

最近の投稿

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!