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.Calendar;
023
024import org.nuxeo.ecm.platform.oauth.consumers.OAuthConsumerRegistry;
025
026/**
027 * Represents Token data as manipulated in OAuth during the 3 legged authentication. The same interface is used for
028 * Request Token and Access Token.
029 *
030 * @author tiry
031 */
032public interface OAuthToken {
033
034    enum Type {
035        REQUEST, ACCESS
036    }
037
038    /**
039     * Returns consumer application identifier.
040     */
041    String getAppId();
042
043    /**
044     * Returns consumer call back url (may be used to override what is provided in the {@link OAuthConsumerRegistry}.
045     */
046    String getCallbackUrl();
047
048    /**
049     * Returns Nuxeo Login as determined during the authorize phase.
050     */
051    String getNuxeoLogin();
052
053    /**
054     * Returns OAuth token.
055     */
056    String getToken();
057
058    /**
059     * Returns secret associated to the Token.
060     */
061    String getTokenSecret();
062
063    /**
064     * Gets the Consumer Key.
065     */
066    String getConsumerKey();
067
068    /**
069     * Gets the type of token: REQUEST / ACCESS.
070     */
071    Type getType();
072
073    /**
074     * Gets creation date of the Token.
075     */
076    Calendar getCreationDate();
077
078    /**
079     * Generic getter (not used for now).
080     */
081    String getValue(String keyName);
082
083    /**
084     * Generic setter (not used for now).
085     */
086    void setValue(String keyName, String value);
087
088    /**
089     * Gets the verifier code.
090     */
091    String getVerifier();
092
093    /**
094     * Checks is token is expired.
095     */
096    boolean isExpired();
097
098    /**
099     * Setter for the Login.
100     */
101    void setNuxeoLogin(String login);
102
103}