Returns whether this permission collection implies {@code permission}.
Basically it tests whether {@code permission} is the subset of this
collection.
if (!(permission instanceof SocketPermission)) {
return false;
}
SocketPermission sp, argPerm = (SocketPermission) permission;
int pmask = argPerm.actionsMask;
int allMask = 0;
int i = 0, count = permissions.size();
while ((i < count) && ((allMask & pmask) != pmask)) {
sp = (SocketPermission) permissions.elementAt(i);
if (sp.checkHost(argPerm)) {
if ((sp.actionsMask & SocketPermission.SP_RESOLVE) == SocketPermission.SP_RESOLVE) {
allMask |= SocketPermission.SP_RESOLVE;
}
// Only set flags if the port range and host can be implied
if ((argPerm.portMin >= sp.portMin)
&& (argPerm.portMax <= sp.portMax)) {
if ((sp.actionsMask & SocketPermission.SP_CONNECT) == SocketPermission.SP_CONNECT) {
allMask |= SocketPermission.SP_CONNECT;
}
if ((sp.actionsMask & SocketPermission.SP_ACCEPT) == SocketPermission.SP_ACCEPT) {
allMask |= SocketPermission.SP_ACCEPT;
}
if ((sp.actionsMask & SocketPermission.SP_LISTEN) == SocketPermission.SP_LISTEN) {
allMask |= SocketPermission.SP_LISTEN;
}
}
}
++i;
}
return (allMask & pmask) == pmask;