1110
1111 final class FilePermissionCollection extends PermissionCollection
1112 implements Serializable
1113 {
1114 // Not serialized; see serialization section at end of class
1115 private transient ConcurrentHashMap<String, Permission> perms;
1116
1117 /**
1118 * Create an empty FilePermissionCollection object.
1119 */
1120 public FilePermissionCollection() {
1121 perms = new ConcurrentHashMap<>();
1122 }
1123
1124 /**
1125 * Adds a permission to the FilePermissionCollection. The key for the hash is
1126 * permission.path.
1127 *
1128 * @param permission the Permission object to add.
1129 *
1130 * @exception IllegalArgumentException - if the permission is not a
1131 * FilePermission
1132 *
1133 * @exception SecurityException - if this FilePermissionCollection object
1134 * has been marked readonly
1135 */
1136 @Override
1137 public void add(Permission permission) {
1138 if (! (permission instanceof FilePermission))
1139 throw new IllegalArgumentException("invalid permission: "+
1140 permission);
1141 if (isReadOnly())
1142 throw new SecurityException(
1143 "attempt to add a Permission to a readonly PermissionCollection");
1144
1145 FilePermission fp = (FilePermission)permission;
1146
1147 // Add permission to map if it is absent, or replace with new
1148 // permission if applicable.
1149 perms.merge(fp.getName(), fp,
1150 new java.util.function.BiFunction<>() {
1151 @Override
1152 public Permission apply(Permission existingVal,
1153 Permission newVal) {
|
1110
1111 final class FilePermissionCollection extends PermissionCollection
1112 implements Serializable
1113 {
1114 // Not serialized; see serialization section at end of class
1115 private transient ConcurrentHashMap<String, Permission> perms;
1116
1117 /**
1118 * Create an empty FilePermissionCollection object.
1119 */
1120 public FilePermissionCollection() {
1121 perms = new ConcurrentHashMap<>();
1122 }
1123
1124 /**
1125 * Adds a permission to the FilePermissionCollection. The key for the hash is
1126 * permission.path.
1127 *
1128 * @param permission the Permission object to add.
1129 *
1130 * @throws IllegalArgumentException - if the permission is not a
1131 * FilePermission
1132 *
1133 * @throws SecurityException - if this FilePermissionCollection object
1134 * has been marked readonly
1135 */
1136 @Override
1137 public void add(Permission permission) {
1138 if (! (permission instanceof FilePermission))
1139 throw new IllegalArgumentException("invalid permission: "+
1140 permission);
1141 if (isReadOnly())
1142 throw new SecurityException(
1143 "attempt to add a Permission to a readonly PermissionCollection");
1144
1145 FilePermission fp = (FilePermission)permission;
1146
1147 // Add permission to map if it is absent, or replace with new
1148 // permission if applicable.
1149 perms.merge(fp.getName(), fp,
1150 new java.util.function.BiFunction<>() {
1151 @Override
1152 public Permission apply(Permission existingVal,
1153 Permission newVal) {
|