001/*
002 * (C) Copyright 2006-2008 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.platform.oauth.tokens;
021
022import java.util.List;
023
024
025/**
026 * Service interface for managing {@link OAuthToken} used both : - in the OAuth the Filter (Server side Tokens) : where
027 * Nuxeo is the provider - in Shindig (Client side Tokens) ; where Nuxeo is the consumer This service provides a center
028 * access point for all Token related actions.
029 *
030 * @author tiry
031 */
032public interface OAuthTokenStore {
033
034    // Request token
035
036    /**
037     * Creates a new REQUEST Token (transient)
038     */
039    OAuthToken createRequestToken(String consumerKey, String callBack);
040
041    /**
042     * Generates a verification code and attache it to the REQUEST Token.
043     */
044    OAuthToken addVerifierToRequestToken(String token, Long duration);
045
046    /**
047     * Retrieves a REQUEST Token given a Token string (extracted from the Request).
048     */
049    OAuthToken getRequestToken(String token);
050
051    /**
052     * Deletes a REQUEST Token.
053     */
054    void removeRequestToken(String token);
055
056    // Access token
057
058    /**
059     * Exchanges the REQUEST Token witha Real ACCESS Token (persistent) Token/TocketSecret Strings are regerated during
060     * the exchange.
061     */
062    OAuthToken createAccessTokenFromRequestToken(OAuthToken requestToken);
063
064    /**
065     * Retrieves an ACCESS from the store.
066     */
067    OAuthToken getAccessToken(String token);
068
069    /**
070     * Deletes an ACCESS Token from the storage.
071     */
072    void removeAccessToken(String token);
073
074    /**
075     * Lists ACCESS Token associated to a User.
076     */
077    List<OAuthToken> listAccessTokenForUser(String login);
078
079    /**
080     * Lists ACCESS Token associated to a Consumer application.
081     */
082    List<OAuthToken> listAccessTokenForConsumer(String consumerKey);
083
084    // Client Token
085
086    /**
087     * Stores a Access token generated fro Shindig client.
088     */
089    void storeClientAccessToken(String consumerKey, String callBack, String token, String tokenSecret, String appId,
090            String owner);
091
092    /**
093     * Get a Access token for the Shindig Client.
094     */
095    NuxeoOAuthToken getClientAccessToken(String appId, String owner);
096
097    /**
098     * Deletes a Client side Access Token.
099     */
100    void removeClientAccessToken(String appId, String owner);
101
102}