All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.threerings.facebook.servlet.FacebookAppServlet Maven / Gradle / Ivy

The newest version!
//
// $Id$

package com.threerings.facebook.servlet;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.inject.Inject;

import com.threerings.app.data.AppCodes;
import com.threerings.app.server.AppServlet;

/**
 * A base servlet that handles the Facebook authentication hoop jumping.
 */
public class FacebookAppServlet extends AppServlet
{
    /**
     * Ensures a user is authenticated before sending them on to indexUrl. See {@link Swizzler} for
     * details.
     *
     * @return - true if they're authenticated and on their way to indexUrl, false if they're being
     * redirected elsewhere.
     */
    protected boolean doFacebookAuth (HttpServletRequest req, HttpServletResponse rsp,
                                      String indexUrl) throws IOException
    {
        return doFacebookAuth(req, rsp, indexUrl, false, false).isSwizzled();
    }

    /**
     * Ensures a user is authenticated before sending them on to indexUrl. See {@link Swizzler} for
     * details.
     *
     * @param indexUrl where to send them once authenticated.
     * @param allowGuests if users may use the app before accepting it. If false, they're sent to
     * the app add page before being allowed through
     * @param nakedAppUrl if parameters should be put into {@link AppCodes#PARAMETER_COOKIE} rather
     * than being left on indexUrl.
     *
     * @return - The Swizzler used for this authentication. Query its methods to find out where the
     * auth is in the process.
     */
    protected Swizzler doFacebookAuth (HttpServletRequest req, HttpServletResponse rsp,
                                       String indexUrl, boolean allowGuests,
                                       boolean nakedAppUrl) throws IOException
    {
        return new Swizzler(req, rsp, _fbconf, _servletLogic, indexUrl, allowGuests, nakedAppUrl);
    }

    @Inject protected FacebookConfig _fbconf;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy