1344 {
1345 // Not serialized; see serialization section at end of class
1346 // A ConcurrentSkipListMap is used to preserve order, so that most
1347 // recently added permissions are checked first (see JDK-4301064).
1348 private transient ConcurrentSkipListMap<String, SocketPermission> perms;
1349
1350 /**
1351 * Create an empty SocketPermissions object.
1352 *
1353 */
1354 public SocketPermissionCollection() {
1355 perms = new ConcurrentSkipListMap<>(new SPCComparator());
1356 }
1357
1358 /**
1359 * Adds a permission to the SocketPermissions. The key for the hash is
1360 * the name in the case of wildcards, or all the IP addresses.
1361 *
1362 * @param permission the Permission object to add.
1363 *
1364 * @exception IllegalArgumentException - if the permission is not a
1365 * SocketPermission
1366 *
1367 * @exception SecurityException - if this SocketPermissionCollection object
1368 * has been marked readonly
1369 */
1370 @Override
1371 public void add(Permission permission) {
1372 if (! (permission instanceof SocketPermission))
1373 throw new IllegalArgumentException("invalid permission: "+
1374 permission);
1375 if (isReadOnly())
1376 throw new SecurityException(
1377 "attempt to add a Permission to a readonly PermissionCollection");
1378
1379 SocketPermission sp = (SocketPermission)permission;
1380
1381 // Add permission to map if it is absent, or replace with new
1382 // permission if applicable. NOTE: cannot use lambda for
1383 // remappingFunction parameter until JDK-8076596 is fixed.
1384 perms.merge(sp.getName(), sp,
1385 new java.util.function.BiFunction<>() {
1386 @Override
1387 public SocketPermission apply(SocketPermission existingVal,
|
1344 {
1345 // Not serialized; see serialization section at end of class
1346 // A ConcurrentSkipListMap is used to preserve order, so that most
1347 // recently added permissions are checked first (see JDK-4301064).
1348 private transient ConcurrentSkipListMap<String, SocketPermission> perms;
1349
1350 /**
1351 * Create an empty SocketPermissions object.
1352 *
1353 */
1354 public SocketPermissionCollection() {
1355 perms = new ConcurrentSkipListMap<>(new SPCComparator());
1356 }
1357
1358 /**
1359 * Adds a permission to the SocketPermissions. The key for the hash is
1360 * the name in the case of wildcards, or all the IP addresses.
1361 *
1362 * @param permission the Permission object to add.
1363 *
1364 * @throws IllegalArgumentException - if the permission is not a
1365 * SocketPermission
1366 *
1367 * @throws SecurityException - if this SocketPermissionCollection object
1368 * has been marked readonly
1369 */
1370 @Override
1371 public void add(Permission permission) {
1372 if (! (permission instanceof SocketPermission))
1373 throw new IllegalArgumentException("invalid permission: "+
1374 permission);
1375 if (isReadOnly())
1376 throw new SecurityException(
1377 "attempt to add a Permission to a readonly PermissionCollection");
1378
1379 SocketPermission sp = (SocketPermission)permission;
1380
1381 // Add permission to map if it is absent, or replace with new
1382 // permission if applicable. NOTE: cannot use lambda for
1383 // remappingFunction parameter until JDK-8076596 is fixed.
1384 perms.merge(sp.getName(), sp,
1385 new java.util.function.BiFunction<>() {
1386 @Override
1387 public SocketPermission apply(SocketPermission existingVal,
|