@Override public void checkPermission(Permission perm) { if (perm.getName().startsWith("exitVM")) { throw new SecurityException("System.exit is disabled"); } }
private void handlePermissionCheckEvent(SecurityPermissionCheckEvent event, StringBuilder stringBuilder) { handleDefiniteOutcomeEvent(event, stringBuilder); Permission permission = event.getPermission(); stringBuilder.append(",permission=[type=").append(permission.getClass().getName()); stringBuilder.append(",actions=").append(permission.getActions()); stringBuilder.append(",name=").append(permission.getName()).append(']'); }
@Override public void checkPermission(Permission perm) { // Disallowing access to System#getenv means that our // ReadOnlySystemAttributesMap will come into play. if ("getenv.*".equals(perm.getName())) { throw new AccessControlException("Accessing the system environment is disallowed"); } } };
@Override public void checkPermission(Permission perm) { //see http://download.oracle.com/javase/1.5.0/docs/api/java/lang/System.html#getenv() if ("getenv.*".equals(perm.getName())) { throw new AccessControlException("Accessing the system environment is disallowed"); } //see http://download.oracle.com/javase/1.5.0/docs/api/java/lang/System.html#getenv(java.lang.String) if (("getenv."+DISALLOWED_PROPERTY_NAME).equals(perm.getName())) { throw new AccessControlException( String.format("Accessing the system environment variable [%s] is disallowed", DISALLOWED_PROPERTY_NAME)); } } };
public boolean implies(final Permission permission) { if (permission == null || getSourcePermission().getClass() != permission.getClass()) { return false; } final Permission all = this.all; if (all != null) { return all.implies(permission); } final Permission ourPermission = byName.get(permission.getName()); return ourPermission != null && ourPermission.implies(permission); } }
private void handlePermissionCheckEvent(SecurityPermissionCheckEvent event, JsonObjectBuilder objectBuilder) { handleDefiniteOutcomeEvent(event, objectBuilder); Permission permission = event.getPermission(); JsonObjectBuilder permissionBuilder = Json.createObjectBuilder(); permissionBuilder.add("type", permission.getClass().getName()); permissionBuilder.add("actions", permission.getActions()); permissionBuilder.add("name", permission.getName()); objectBuilder.add("permission", permissionBuilder); }
/** * Learn whether the permission matches in case of a revoked permission. * @param perm The permission to check against. */ boolean matches(final java.security.Permission perm) { if (!className.equals(perm.getClass().getName())) { //NOSONAR return false; } if (name != null) { if (name.endsWith("*")) { if (!perm.getName().startsWith(name.substring(0, name.length() - 1))) { return false; } } else if (!name.equals(perm.getName())) { return false; } } if (actions != null) { final Set<String> as = parseActions(perm.getActions()); final int size = as.size(); as.removeAll(actions); // If no actions removed, then all allowed return as.size() != size; } return true; }
@Override public void checkPermission(final Permission permission) { if (permission instanceof FilePermission && permission.getName().endsWith(TEST_FIXTURE_PATH)) { throw new SecurityException(); } } }
@Override public void checkPermission(final Permission permission) { if ("getenv.*".equals(permission.getName())) { throw new SecurityException(); } } }
@Override public void checkPermission(Permission perm) { // Disallowing access to System#getenv means that our // ReadOnlySystemAttributesMap will come into play. if ("getenv.*".equals(perm.getName())) { throw new AccessControlException("Accessing the system environment is disallowed"); } // Disallowing access to the spring.profiles.active property means that // the BeanDefinitionReader won't be able to determine which profiles are // active. We should see an INFO-level message in the console about this // and as a result, any components marked with a non-default profile will // be ignored. if (("getenv." + AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME).equals(perm.getName())) { throw new AccessControlException( format("Accessing system environment variable [%s] is disallowed", AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME)); } } };
@Override public void checkPermission( Permission permission ) { if ( permission.getName().startsWith( "exitVM" ) ) { throw new SecurityException( "System exit not allowed" ); } if ( baseSecurityManager != null ) { baseSecurityManager.checkPermission( permission ); } else { return; } } }
@Override public void checkPermission( Permission permission ) { if ( permission.getName().startsWith( "exitVM" ) ) { throw new SecurityException( "System exit not allowed" ); } if ( baseSecurityManager != null ) { baseSecurityManager.checkPermission( permission ); } else { return; } }
private long getBitsForName(final Permission permission) { final long bits; final String name = permission.getName(); final StringEnumeration nameEnumeration = getNameEnumeration(); if ("*".equals(name)) { // add all names bits = (1L << nameEnumeration.size()) - 1; } else { bits = 1L << nameEnumeration.indexOf(name); } return bits; }
private int getBitsForName(final Permission permission) { final int bits; final String name = permission.getName(); final StringEnumeration nameEnumeration = getNameEnumeration(); if ("*".equals(name)) { // add all names bits = (1 << nameEnumeration.size()) - 1; } else { bits = 1 << nameEnumeration.indexOf(name); } return bits; }
@Override public void checkPermission(Permission permission) { if (permission.getName().startsWith("exitVM")) { throw new SecurityException("System exit not allowed"); } if (baseSecurityManager != null) { baseSecurityManager.checkPermission(permission); } } }
@Override public void checkPermission(final Permission perm) { if (perm instanceof RuntimePermission) { // deny access to the class to trigger the security exception if ("accessClassInPackage.sun.nio.ch".equals(perm.getName())) { throw new SecurityException(perm.toString()); } } } });
@Override public void checkPermission(final Permission perm) { if (perm instanceof RuntimePermission) { // deny access to the classloader to trigger the security exception if ("getClassLoader".equals(perm.getName())) { throw new SecurityException(perm.toString()); } } } });
String binaryPath = (new URL(Shaj.class.getProtectionDomain() .getCodeSource().getLocation(), ".")).openConnection() .getPermission().getName(); binaryPath = (new File(binaryPath)).getCanonicalPath();
/** * The central point in checking permissions. * Overridden from java.lang.SecurityManager * * @param perm The permission requested. */ @Override public void checkPermission(final java.security.Permission perm) { if (active) { if (delegateToOldSM && !perm.getName().equals("exitVM")) { boolean permOK = false; if (granted.implies(perm)) { permOK = true; } checkRevoked(perm); /* if the permission was not explicitly granted or revoked the original security manager will do its work */ if (!permOK && origSm != null) { origSm.checkPermission(perm); } } else { if (!granted.implies(perm)) { throw new SecurityException("Permission " + perm + " was not granted."); } checkRevoked(perm); } } }
@Override public void add(Permission permission) { if (permission instanceof ClassPermission && STANDARD.equals(permission.getName())) { for (String clazz : STANDARD_CLASSES) { impl.add(new ClassPermission(clazz)); } } else { impl.add(permission); } }