public boolean implies(Permission perm) { final SocketPermission that;
public boolean implies(Permission perm) { SocketPermission p;
    public boolean implies(Permission perm) {        final SocketPermission that;        //System.out.println("implies");        // First make sure we are the right object type        if (perm instanceof SocketPermission) {            that = (SocketPermission) perm;        } else {            return false;        }        // Next check the actions        if ((this.mask & that.mask) != that.mask) {            return false;        }        // Now check ports        final int[] ourPorts = getPorts(hostport);        final int[] theirPorts = getPorts(that.hostport);        if ((theirPorts[ 0] < ourPorts[ 0]) || (theirPorts[ 1] > ourPorts[ 1])) {            return (false);        }        // Finally we can check the hosts        final String ourhost = getHost(hostport);        final String theirhost = getHost(that.hostport);        // Are they equal?        if (ourhost.equals(theirhost)) return true;        if (ourhost.equals("*")) return true;        // Try the canonical names        String ourcanonical = null, theircanonical = null;        try {            ourcanonical = InetAddress.getByName(ourhost).getHostName();            theircanonical = InetAddress.getByName(theirhost).getHostName();        } catch (UnknownHostException e) {            // Who didn't resolve? Just assume current address is canonical            // enough            // Is this ok to do?        }        if (ourcanonical == null) ourcanonical = ourhost;        if (theircanonical == null) theircanonical = theirhost;        if (ourcanonical.equals(theircanonical)) return (true);        // Well, last chance. Try for a wildcard        if (ourhost.indexOf("*.") != -1) {            String wild_domain = ourhost.substring(ourhost.indexOf("*" + 1));            if (theircanonical.endsWith(wild_domain)) return (true);        }        // Didn't make it        return false;    }