Error: java.security.AccessControlException: Access denied
Posted
by RMD
on Stack Overflow
See other posts from Stack Overflow
or by RMD
Published on 2010-04-14T08:24:46Z
Indexed on
2010/04/14
8:33 UTC
Read the original article
Hit count: 489
Hi, I have to connect to a https url with username and password to read a file. I am not able to connect to the server (see the error log below). I do not have much java experience so I need help with this code. I would really appreciate some help to solve this! Thank you.
Raquel
CODE: import lotus.domino.; import java.net.; import java.io.*; import javax.net.ssl.HttpsURLConnection;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try { String username = "123"; String password = "456"; String input = username + ":" + password; String encoding = new sun.misc.BASE64Encoder().encode (input.getBytes());
//Open the URL and read the text into a Buffer
String urlName = "https://server.org/Export.mvc/GetMeetings?modifiedSince=4/9/2010";
URL url = new URL(urlName);
HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Content-Length", String.valueOf (encoding.length()));
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setAllowUserInteraction(true);
connection.setRequestProperty("Authorization", "Basic " + encoding);
connection.setRequestProperty("Cookie", "LocationCode=Geneva");
connection.connect();
BufferedReader rd = null;
try{
rd = new BufferedReader(new InputStreamReader(connection.getInputStream()));
} catch (IOException e) {
System.out.println("Read failed");
System.exit(-1);
}
String line;
while((line = rd.readLine()) != null) {
System.out.println(line.toString());
}
rd.close();
connection.disconnect();
} catch(Exception e) { e.printStackTrace(); } } } LOG: java.security.AccessControlException: Access denied (java.lang.RuntimePermission exitVM.-1) at java.security.AccessController.checkPermission(AccessController.java:108) at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) at COM.ibm.JEmpower.applet.AppletSecurity.superDotCheckPermission(AppletSecurity.java:1449) at COM.ibm.JEmpower.applet.AppletSecurity.checkRuntimePermission(AppletSecurity.java:1311) at COM.ibm.JEmpower.applet.AppletSecurity.checkPermission(AppletSecurity.java:1611) at COM.ibm.JEmpower.applet.AppletSecurity.checkPermission(AppletSecurity.java:1464) at java.lang.SecurityManager.checkExit(SecurityManager.java:744) at java.lang.Runtime.exit(Runtime.java:99) at java.lang.System.exit(System.java:275) at JavaAgent.NotesMain(Unknown Source) at lotus.domino.AgentBase.runNotes(Unknown Source) at lotus.domino.NotesThread.run(Unknown Source)
© Stack Overflow or respective owner