001/* 002 * Copyright 2010-2015 Institut Pasteur. 003 * 004 * This file is part of Icy. 005 * 006 * Icy is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * Icy is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with Icy. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package icy.system; 020 021import java.io.FileDescriptor; 022import java.security.Permission; 023 024/** 025 * @author Stephane 026 */ 027public class IcySecurityManager extends SecurityManager 028{ 029 private static IcySecurityManager securityManager = null; 030 031 public static synchronized void init() 032 { 033 // initialize security manager 034 if (securityManager == null) 035 { 036 securityManager = new IcySecurityManager(); 037 System.setSecurityManager(securityManager); 038 } 039 } 040 041 @Override 042 public void checkConnect(String host, int port) 043 { 044 // ignore for now 045 } 046 047 @Override 048 public void checkConnect(String host, int port, Object context) 049 { 050 // ignore for now 051 } 052 053 @Override 054 public void checkDelete(String file) 055 { 056 // ignore for now 057 } 058 059 @Override 060 public boolean checkTopLevelWindow(Object window) 061 { 062 return true; 063 } 064 065 @Override 066 public void checkListen(int port) 067 { 068 // ignore for now 069 } 070 071 @Override 072 public void checkRead(String file) 073 { 074 // ignore for now 075 } 076 077 @Override 078 public void checkRead(FileDescriptor fd) 079 { 080 // ignore for now 081 } 082 083 @Override 084 public void checkRead(String file, Object context) 085 { 086 // ignore for now 087 } 088 089 @Override 090 public void checkWrite(FileDescriptor fd) 091 { 092 // ignore for now 093 } 094 095 @Override 096 public void checkWrite(String file) 097 {// ignore for now 098 } 099 100 @Override 101 public void checkPackageAccess(String pkg) 102 { 103 // ignore for now 104 } 105 106 @Override 107 public void checkPackageDefinition(String pkg) 108 { 109 // ignore for now 110 } 111 112 @Override 113 public void checkPropertiesAccess() 114 { 115 // ignore for now 116 } 117 118 @Override 119 public void checkPropertyAccess(String key) 120 { 121 // ignore for now 122 } 123 124 @Override 125 public void checkAccept(String host, int port) 126 { 127 // ignore for now 128 } 129 130 @Override 131 public void checkAccess(Thread t) 132 { 133 // ignore for now 134 } 135 136 @Override 137 public void checkAccess(ThreadGroup g) 138 { 139 // ignore for now 140 } 141 142 @Override 143 public void checkMemberAccess(Class<?> clazz, int which) 144 { 145 // ignore for now 146 } 147 148 @Override 149 public void checkPermission(Permission perm, Object context) 150 { 151 checkPermission(perm); 152 } 153 154 @Override 155 public void checkPermission(Permission perm) 156 { 157 // // TODO: handle plugins permissions here 158 // for (Class<?> c : getClassContext()) 159 // { 160 // if (Plugin.class.isAssignableFrom(c)) 161 // { 162 // // System.out.println(c.getSimpleName() + " : permission " + perm.toString()); 163 // } 164 // } 165 } 166}