class RosterAccess extends AccessModel {

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

    RosterAccess() {
    }

    @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 "roster";
    }

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

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

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

        // Let node owners and sysadmins always subscribe to the node
        if (node.isAdmin(owner)) {
            return true;
        }
        for (JID nodeOwner : node.getOwners()) {
            if (nodeOwner.equals(owner)) {
                return true;
            }
        }
        // Check that the subscriber is a local user
        XMPPServer server = XMPPServer.getInstance();
        if (server.isLocal(owner)) {
            GroupManager gMgr = GroupManager.getInstance();
            Collection<String> nodeGroups = node.getRosterGroupsAllowed();
            for (String groupName : nodeGroups) {
                try {
                    Group group = gMgr.getGroup(groupName);
                    // access allowed if the node group is visible to the subscriber
                    if (server.getRosterManager().isGroupVisible(group, owner)) {
                        return true;
                    }
                } catch (GroupNotFoundException gnfe){ 
                    // ignore
                }
            }
        }
        else {
            // Subscriber is a remote user. This should never happen.
            Log.warn("Node with access model Roster has a remote user as subscriber: {}", 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