Vista Combinata Vista Piatta Vista ad Albero
toggle
K Chand
java.lang.SecurityException: Attempted to get proxy selector
1 aprile 2013 2.14
Risposta

K Chand

Punteggio: New Member

Messaggi: 2

Data di Iscrizione: 27 febbraio 2013

Messaggi recenti

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.
Anonimo
RE: java.lang.SecurityException: Attempted to get proxy selector
2 aprile 2013 6.04
Risposta

Anonimo

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
2 aprile 2013 6.51
Risposta

Ray Augé

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 1171

Data di Iscrizione: 7 febbraio 2005

Messaggi recenti

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