001package com.pusher.client;
002
003/**
004 * Subscriptions to {@link com.pusher.client.channel.PrivateChannel Private} and
005 * {@link com.pusher.client.channel.PresenceChannel presence} channels need to
006 * be authorized. This interface provides an {@link #authorize} method as a mechanism
007 * for doing this.
008 *
009 * <p>
010 * See the {@link com.pusher.client.util.HttpChannelAuthorizer HttpChannelAuthorizer} as an
011 * example.
012 * </p>
013 */
014public interface ChannelAuthorizer {
015    /**
016     * Called when a channel subscription is to be authorized.
017     *
018     * @param channelName The name of the channel to be authorized.
019     * @param socketId    A unique socket connection ID to be used with the
020     *                    authorization. This uniquely identifies the connection that
021     *                    the subscription is being authorized for.
022     * @return A channel authorization token.
023     * @throws AuthorizationFailureException if the authorization fails.
024     */
025    String authorize(String channelName, String socketId) throws AuthorizationFailureException;
026}