home *** CD-ROM | disk | FTP | other *** search
- package java.rmi;
-
- import java.io.FileDescriptor;
- import java.net.InetAddress;
- import java.net.URL;
- import java.net.UnknownHostException;
- import java.rmi.server.RMIClassLoader;
-
- public class RMISecurityManager extends SecurityManager {
- private boolean inLoadedClass() {
- return ((SecurityManager)this).inClassLoader();
- }
-
- public Object getSecurityContext() {
- return RMIClassLoader.getSecurityContext(((SecurityManager)this).currentClassLoader());
- }
-
- public synchronized void checkCreateClassLoader() {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("classloader");
- }
- }
-
- public synchronized void checkAccess(Thread var1) {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("thread");
- }
- }
-
- public synchronized void checkAccess(ThreadGroup var1) {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("threadgroup");
- }
- }
-
- public synchronized void checkExit(int var1) {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("exit", String.valueOf(var1));
- }
- }
-
- public synchronized void checkExec(String var1) {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("exec", var1);
- }
- }
-
- public synchronized void checkLink(String var1) {
- switch (((SecurityManager)this).classLoaderDepth()) {
- case 2:
- case 3:
- throw new RMISecurityException("link", var1);
- default:
- }
- }
-
- public synchronized void checkPropertiesAccess() {
- if (((SecurityManager)this).classLoaderDepth() == 2) {
- throw new RMISecurityException("properties");
- }
- }
-
- public synchronized void checkPropertyAccess(String var1) {
- if (((SecurityManager)this).classLoaderDepth() == 2 && !"true".equalsIgnoreCase(System.getProperty(var1 + ".rmi"))) {
- throw new RMISecurityException("properties");
- }
- }
-
- public synchronized void checkRead(String var1) {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("file.read", var1);
- }
- }
-
- public void checkRead(String var1, Object var2) {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("file.read", var1);
- }
- }
-
- public synchronized void checkWrite(String var1) {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("file.write", var1);
- }
- }
-
- public void checkDelete(String var1) {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("file.delete", var1);
- }
- }
-
- public synchronized void checkRead(FileDescriptor var1) {
- if (this.inLoadedClass() && !((SecurityManager)this).inClass("java.net.SocketInputStream") || !var1.valid()) {
- throw new RMISecurityException("fd.read");
- }
- }
-
- public synchronized void checkWrite(FileDescriptor var1) {
- if (this.inLoadedClass() && !((SecurityManager)this).inClass("java.net.SocketOutputStream") || !var1.valid()) {
- throw new RMISecurityException("fd.write");
- }
- }
-
- public synchronized void checkListen(int var1) {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("socket.listen", String.valueOf(var1));
- }
- }
-
- public synchronized void checkAccept(String var1, int var2) {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("socket.accept", var1 + ":" + var2);
- }
- }
-
- public void checkMulticast(InetAddress var1) {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("checkmulticast");
- }
- }
-
- public void checkMulticast(InetAddress var1, byte var2) {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("checkmulticast");
- }
- }
-
- public synchronized void checkConnect(String var1, int var2) {
- if (this.inLoadedClass()) {
- int var3 = ((SecurityManager)this).classDepth("sun.rmi.transport.tcp.TCPChannel");
- if (var3 <= 1) {
- Object var4 = this.getSecurityContext();
- if (var4 != null && var4 instanceof URL) {
- this.checkConnect(((URL)var4).getHost(), var1);
- } else {
- throw new RMISecurityException("checkConnect", "To " + var1 + ":" + var2);
- }
- }
- }
- }
-
- private synchronized void checkConnect(String var1, String var2) {
- try {
- super.inCheck = true;
- if (var1.equals(var2)) {
- try {
- InetAddress var13 = InetAddress.getByName(var2);
- return;
- } catch (UnknownHostException var10) {
- throw new RMISecurityException("checkConnect", "To " + var2);
- }
- }
-
- try {
- InetAddress var5 = InetAddress.getByName(var2);
- InetAddress var6 = InetAddress.getByName(var1);
- if (!var6.equals(var5)) {
- throw new RMISecurityException("checkConnect", "To " + var2);
- }
- } catch (UnknownHostException var11) {
- throw new RMISecurityException("checkConnect", "To " + var2);
- }
- } finally {
- super.inCheck = false;
- }
-
- }
-
- public void checkConnect(String var1, int var2, Object var3) {
- this.checkConnect(var1, var2);
- if (var3 != null) {
- if (var3 instanceof URL) {
- this.checkConnect(((URL)var3).getHost(), var1);
- } else {
- throw new RMISecurityException("checkConnect (unknown context)", "To " + var1);
- }
- }
- }
-
- public synchronized boolean checkTopLevelWindow(Object var1) {
- return !this.inLoadedClass();
- }
-
- public synchronized void checkPackageAccess(String var1) {
- if (this.inLoadedClass()) {
- for(int var2 = var1.indexOf(46); var2 > 0; var2 = var1.indexOf(46, var2 + 1)) {
- String var3 = var1.substring(0, var2);
- if (Boolean.getBoolean("package.restrict.access." + var3)) {
- throw new RMISecurityException("checkpackageaccess", var1);
- }
- }
-
- }
- }
-
- public synchronized void checkPackageDefinition(String var1) {
- if (this.inLoadedClass()) {
- for(int var2 = var1.indexOf(46); var2 > 0; var2 = var1.indexOf(46, var2 + 1)) {
- String var3 = var1.substring(0, var2);
- if (Boolean.getBoolean("package.restrict.definition." + var3)) {
- throw new RMISecurityException("checkpackagedefinition", var1);
- }
- }
-
- }
- }
-
- public synchronized void checkSetFactory() {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("cannotsetfactory");
- }
- }
-
- public void checkPrintJobAccess() {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("getPrintJob");
- }
- }
-
- public void checkSystemClipboardAccess() {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("checksystemclipboardaccess");
- }
- }
-
- public void checkAwtEventQueueAccess() {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("checkawteventqueueaccess");
- }
- }
-
- public void checkMemberAccess(Class var1, int var2) {
- if (var2 != 0) {
- ClassLoader var3 = ((SecurityManager)this).currentClassLoader();
- if (var3 != null && var3 != var1.getClassLoader()) {
- throw new RMISecurityException("checkmemberaccess");
- }
- }
-
- }
-
- public void checkSecurityAccess(String var1) {
- if (this.inLoadedClass()) {
- throw new RMISecurityException("checksecurityaccess", var1);
- }
- }
- }
-