001/*
002 * (C) Copyright 2006-2008 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nuxeo - initial API and implementation
018 *
019 * $Id$
020 */
021
022package org.nuxeo.ecm.platform.oauth.tokens;
023
024import java.util.List;
025
026
027/**
028 * Service interface for managing {@link OAuthToken} used both : - in the OAuth the Filter (Server side Tokens) : where
029 * Nuxeo is the provider - in Shindig (Client side Tokens) ; where Nuxeo is the consumer This service provides a center
030 * access point for all Token related actions.
031 *
032 * @author tiry
033 */
034public interface OAuthTokenStore {
035
036    // Request token
037
038    /**
039     * Creates a new REQUEST Token (transient)
040     */
041    OAuthToken createRequestToken(String consumerKey, String callBack);
042
043    /**
044     * Generates a verification code and attache it to the REQUEST Token.
045     */
046    OAuthToken addVerifierToRequestToken(String token, Long duration);
047
048    /**
049     * Retrieves a REQUEST Token given a Token string (extracted from the Request).
050     */
051    OAuthToken getRequestToken(String token);
052
053    /**
054     * Deletes a REQUEST Token.
055     */
056    void removeRequestToken(String token);
057
058    // Access token
059
060    /**
061     * Exchanges the REQUEST Token witha Real ACCESS Token (persistent) Token/TocketSecret Strings are regerated during
062     * the exchange.
063     */
064    OAuthToken createAccessTokenFromRequestToken(OAuthToken requestToken);
065
066    /**
067     * Retrieves an ACCESS from the store.
068     */
069    OAuthToken getAccessToken(String token);
070
071    /**
072     * Deletes an ACCESS Token from the storage.
073     */
074    void removeAccessToken(String token);
075
076    /**
077     * Lists ACCESS Token associated to a User.
078     */
079    List<OAuthToken> listAccessTokenForUser(String login);
080
081    /**
082     * Lists ACCESS Token associated to a Consumer application.
083     */
084    List<OAuthToken> listAccessTokenForConsumer(String consumerKey);
085
086    // Client Token
087
088    /**
089     * Stores a Access token generated fro Shindig client.
090     */
091    void storeClientAccessToken(String consumerKey, String callBack, String token, String tokenSecret, String appId,
092            String owner);
093
094    /**
095     * Get a Access token for the Shindig Client.
096     */
097    NuxeoOAuthToken getClientAccessToken(String appId, String owner);
098
099    /**
100     * Deletes a Client side Access Token.
101     */
102    void removeClientAccessToken(String appId, String owner);
103
104}