# Re: SocketPermission

Jan Luehe (luehe@laguna.eng.sun.com)
Thu, 29 Oct 1998 10:02:07 -0800 (PST)

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Morten Helles: "SecretKeys and KeyStore"
- Previous message: JDCNewsletter@Sun.com: "JDC Newsletter Vol. 2 No. 2"
- Maybe in reply to: Girasoli, Tony: "SocketPermission"

Tony:

> java.security.AccessControlException: access denied
> (java.net.SocketPermission 1
> 37.99.89.4:161 connect,resolve)
> at java.security.AccessControlContext.checkPermission(Compiled
> Code)
> at java.security.AccessController.checkPermission(Compiled Code)
> at java.lang.SecurityManager.checkPermission(Compiled Code)
> at
> java.lang.SecurityManager.checkConnect(SecurityManager.java:797)
> at java.net.Socket.<init>(Socket.java:208)
> at java.net.Socket.<init>(Socket.java:165)
> at snmp.SnmpContext.<init>(SnmpContext.java:142)
> at get_one.init(get_one.java:39)
> at sun.applet.AppletPanel.run(Compiled Code)
> at java.lang.Thread.run(Thread.java:475)
>
> Do I need to add some permissions in my code?

Try adding

grant {
permission java.net.SocketPermission "137.99.89.4:161", "connect,
resolve";
};

to your policy file.

This will grant the requested permission to *any* applet code.
You may want to restrict this permission to your applet
by adding a "codesource" (specifying where your applet
came from, and possibly who signed it) to the above grant
statement.

See

http://java.sun.com/products/jdk/1.2/docs/guide/security/PolicyFiles.html
http://java.sun.com/products/jdk/1.2/docs/guide/security/permissions.html
http://java.sun.com/products/jdk/1.2/docs/tooldocs/win32/policytool.html

for more details.

Jan

- Next message: Morten Helles: "SecretKeys and KeyStore"
- Previous message: JDCNewsletter@Sun.com: "JDC Newsletter Vol. 2 No. 2"
- Maybe in reply to: Girasoli, Tony: "SocketPermission"