BasicAcceptPolicy.java 950 Bytes
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3 4 5
/**
 * $RCSfile$
 * $Revision$
 * $Date$
 *
6
 * Copyright (C) 2004 Jive Software. All rights reserved.
Matt Tucker's avatar
Matt Tucker committed
7
 *
8 9
 * This software is published under the terms of the GNU Public License (GPL),
 * a copy of which is included in this distribution.
Matt Tucker's avatar
Matt Tucker committed
10
 */
11

Matt Tucker's avatar
Matt Tucker committed
12 13 14 15 16 17
package org.jivesoftware.net.policies;

import org.jivesoftware.net.AcceptPolicy;
import org.jivesoftware.net.Connection;

/**
18 19
 * The simplest possible accept policy that either accepts or rejects
 * all connections.
Matt Tucker's avatar
Matt Tucker committed
20 21 22 23 24 25 26 27
 *
 * @author Iain Shigeoka
 */
public class BasicAcceptPolicy implements AcceptPolicy {

    private boolean accept;

    /**
28 29
     * Create a basic accept policy that either accepts or denies all
     * incoming connections.
Matt Tucker's avatar
Matt Tucker committed
30 31 32 33 34 35 36 37 38 39 40
     *
     * @param alwaysAccept True if the policy should accept all connections
     */
    public BasicAcceptPolicy(boolean alwaysAccept){
        accept = alwaysAccept;
    }

    public boolean evaluate(Connection connection) {
        return accept;
    }
}