Happy New Year @ 2012
Happy New Year @ 2012
It is a difficult year, no matter to the world or to me. There are too many disasters, the financial crisis, making lots of people die or poor. And for my job, we finally make out company site launch. We got too many to work out in order to meet numerous deadline: Launch date, pre-sale, etc. But no matter what, this 2012 I am preparing for my new era. I hope to work our our future with my love. And I wish I can share my skills to help more people to work out more great sites.
Wish you all best in 2012!
Solution: java.security.AccessControlException: access denied (java.net.SocketPermission host connect,resolve)
I am not Java Applet expert, but I found this worth for sharing.
I was told by my boss to check for the resolved ip for CDN domain. As I know, the resolved ip for a CDN domain is vary from geographic to geographic.It does not work to place the detection code on a particular server.
JavaScript does not have such thing besides basic client IP. So I tried using Actioncript, and turn out that AS# does has net package, and sadly it works on AIR 2 but Flash. So my boss throw out an idea to look for the information through Java Applet.
I am a new comer of Java Applet. In my mind, Java Applet is evil, which crash my browser in old time, making my computer run slower. Despite that, I know Java Applet should be able to do this job.
My mind is that Java Applet run on JVM, which should be able to get the information on client side. I search for example and find the following code should help me get the resolved domain ip:
InetAddress thisIp = java.net.InetAddress.getByName("{cdn.domain.com}");
String ip = thisIp.getHostAddress();
I can run the code, generate the .class file. But I fail to make it runs in browser no matter how I try. Until I find out the Java control panel and the console log. I get the reason why it stop working:
java.security.AccessControlException: access denied (java.net.SocketPermission cdn.domain.com resolve)
Well, definite I try to test a valid CDN domain URL, however it just keep saying the access denied. Due to the knowledge about flash cross domain experience, I know this should be something about foreign domain issue. So I try to change the domain that I try to look up from CDN domain to my blog domain or some URL with snap-f.net as domain, and the result is: work!!!
Thanks god.
So how about if it has to look up a foreign domain? I am not sure but here has a website talk about keystore or cert that may help working out the purpose:
http://www.khattam.info/solved-java-security-accesscontrolexception-access-denied-java-net-socketpermission-host-connectresolve-2010-03-24.html