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.consumers;
023
024import java.util.List;
025
026/**
027 * Service interface for managing OAuth Service Consumers
028 *
029 * @author tiry
030 */
031public interface OAuthConsumerRegistry {
032
033    /**
034     * Get a Consumer from its consumerKey.
035     */
036    NuxeoOAuthConsumer getConsumer(String consumerKey);
037
038    /**
039     * Get a Consumer from its consumerKey.
040     * <p>
041     * The keyType param indicates if we need HMAC or RSA secret. This is needed because the default OAuthValidator
042     * implementation only uses 1 field for both Keys. If keyType is OAUth.RSA_SHA1, the consumerSecret field will be
043     * polupated with the RSA public key rather than the HMAC secret.
044     */
045    NuxeoOAuthConsumer getConsumer(String consumerKey, String keyType);
046
047    /**
048     * remove a Consumer
049     */
050    void deleteConsumer(String consumerKey);
051
052    /**
053     * List all registered Consumers
054     */
055    List<NuxeoOAuthConsumer> listConsumers();
056
057    /**
058     * Store a new Consumer
059     */
060    NuxeoOAuthConsumer storeConsumer(NuxeoOAuthConsumer consumer);
061}