1416 @Override
1417 public boolean implies(Permission permission)
1418 {
1419 if (! (permission instanceof SocketPermission))
1420 return false;
1421
1422 SocketPermission np = (SocketPermission) permission;
1423
1424 int desired = np.getMask();
1425 int effective = 0;
1426 int needed = desired;
1427
1428 //System.out.println("implies "+np);
1429 for (SocketPermission x : perms.values()) {
1430 //System.out.println(" trying "+x);
1431 if (((needed & x.getMask()) != 0) && x.impliesIgnoreMask(np)) {
1432 effective |= x.getMask();
1433 if ((effective & desired) == desired) {
1434 return true;
1435 }
1436 needed = (desired ^ effective);
1437 }
1438 }
1439 return false;
1440 }
1441
1442 /**
1443 * Returns an enumeration of all the SocketPermission objects in the
1444 * container.
1445 *
1446 * @return an enumeration of all the SocketPermission objects.
1447 */
1448 @Override
1449 @SuppressWarnings("unchecked")
1450 public Enumeration<Permission> elements() {
1451 return (Enumeration)Collections.enumeration(perms.values());
1452 }
1453
1454 @java.io.Serial
1455 private static final long serialVersionUID = 2787186408602843674L;
1456
|
1416 @Override
1417 public boolean implies(Permission permission)
1418 {
1419 if (! (permission instanceof SocketPermission))
1420 return false;
1421
1422 SocketPermission np = (SocketPermission) permission;
1423
1424 int desired = np.getMask();
1425 int effective = 0;
1426 int needed = desired;
1427
1428 //System.out.println("implies "+np);
1429 for (SocketPermission x : perms.values()) {
1430 //System.out.println(" trying "+x);
1431 if (((needed & x.getMask()) != 0) && x.impliesIgnoreMask(np)) {
1432 effective |= x.getMask();
1433 if ((effective & desired) == desired) {
1434 return true;
1435 }
1436 needed = (desired & ~effective);
1437 }
1438 }
1439 return false;
1440 }
1441
1442 /**
1443 * Returns an enumeration of all the SocketPermission objects in the
1444 * container.
1445 *
1446 * @return an enumeration of all the SocketPermission objects.
1447 */
1448 @Override
1449 @SuppressWarnings("unchecked")
1450 public Enumeration<Permission> elements() {
1451 return (Enumeration)Collections.enumeration(perms.values());
1452 }
1453
1454 @java.io.Serial
1455 private static final long serialVersionUID = 2787186408602843674L;
1456
|