class PresenceAccess extends AccessModel {

    private static final Logger Log = LoggerFactory.getLogger(PresenceAccess.class);

    PresenceAccess() {
    }

    @Override
    public boolean canSubscribe(Node node, JID owner, JID subscriber) {<FILL_FUNCTION_BODY>}

    @Override
    public boolean canAccessItems(Node node, JID owner, JID subscriber) {
        return canSubscribe(node, owner, subscriber);
    }

    @Override
    public String getName() {
        return "presence";
    }

    @Override
    public PacketError.Condition getSubsriptionError() {
        return PacketError.Condition.not_authorized;
    }

    @Override
    public Element getSubsriptionErrorDetail() {
        return DocumentHelper.createElement(QName.get("presence-subscription-required",
                "http://jabber.org/protocol/pubsub#errors"));
    }

    @Override
    public boolean isAuthorizationRequired() {
        return false;
    }
}

        // Let node owners and sysadmins always subcribe to the node
        if (node.isAdmin(owner)) {
            return true;
        }
        XMPPServer server = XMPPServer.getInstance();
        for (JID nodeOwner : node.getOwners()) {
            // Give access to the owner of the roster :)
            if (nodeOwner.equals(owner)) {
                return true;
            }
            // Check that the node owner is a local user
            if (server.isLocal(nodeOwner)) {
                try {
                    Roster roster = server.getRosterManager().getRoster(nodeOwner.getNode());
                    RosterItem item = roster.getRosterItem(owner);
                    // Check that the subscriber is subscribe to the node owner's presence
                    return item != null && (RosterItem.SUB_BOTH == item.getSubStatus() ||
                            RosterItem.SUB_FROM == item.getSubStatus());
                }
                catch (UserNotFoundException e) {
                    // Do nothing
                }
            }
            else {
                // Owner of the node is a remote user. This should never happen.
                Log.warn("Node with access model Presence has a remote user as owner: {}",node.getUniqueIdentifier());
            }
        }
        return false;
    
<methods>public non-sealed void <init>() ,public abstract boolean canAccessItems(org.jivesoftware.openfire.pubsub.Node, JID, JID) ,public abstract boolean canSubscribe(org.jivesoftware.openfire.pubsub.Node, JID, JID) ,public abstract java.lang.String getName() ,public abstract PacketError.Condition getSubsriptionError() ,public abstract Element getSubsriptionErrorDetail() ,public abstract boolean isAuthorizationRequired() ,public static org.jivesoftware.openfire.pubsub.models.AccessModel valueOf(java.lang.String) <variables>public static final org.jivesoftware.openfire.pubsub.models.AccessModel authorize,public static final org.jivesoftware.openfire.pubsub.models.AccessModel open,public static final org.jivesoftware.openfire.pubsub.models.AccessModel presence,public static final org.jivesoftware.openfire.pubsub.models.AccessModel roster,public static final org.jivesoftware.openfire.pubsub.models.AccessModel whitelist