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} as a mechanism
007 * for doing this.
008 *
009 * <p>
010 * See the {@link com.pusher.client.util.HttpAuthorizer HttpAuthorizer} as an
011 * example.
012 * </p>
013 */
014public interface Authorizer {
015
016    /**
017     * Called when a channel is to be authenticated.
018     *
019     * @param channelName
020     *            The name of the channel to be authenticated.
021     * @param socketId
022     *            A unique socket connection ID to be used with the
023     *            authentication. This uniquely identifies the connection that
024     *            the subscription is being authenticated for.
025     * @return An authentication token.
026     * @throws AuthorizationFailureException
027     *             if the authentication fails.
028     */
029    String authorize(String channelName, String socketId) throws AuthorizationFailureException;
030}