001/*
002 * (C) Copyright 2015 Nuxeo SA (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-2.1.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 *      Nelson Silva
016 */
017package org.nuxeo.ecm.platform.oauth2.providers;
018
019import com.google.api.client.auth.oauth2.Credential;
020
021import javax.servlet.http.HttpServletRequest;
022import java.util.List;
023
024/**
025 * @since 7.3
026 */
027public interface OAuth2ServiceProvider {
028
029    /**
030     * Returns the authorization URL
031     */
032    String getAuthorizationUrl(HttpServletRequest request);
033
034    /**
035     * Handles the authorization response and stores the token(s)
036     */
037    Credential handleAuthorizationCallback(HttpServletRequest request);
038
039    /**
040     * Loads a credential from the token store
041     */
042    Credential loadCredential(String user);
043
044    void setId(Long id);
045
046    void setAuthorizationServerURL(String authorizationServerURL);
047
048    void setTokenServerURL(String tokenServerURL);
049
050    void setServiceName(String serviceName);
051
052    void setClientId(String clientId);
053
054    void setClientSecret(String clientSecret);
055
056    void setScopes(String... strings);
057
058    String getServiceName();
059
060    Long getId();
061
062    String getTokenServerURL();
063
064    String getClientId();
065
066    String getClientSecret();
067
068    List<String> getScopes();
069
070    String getAuthorizationServerURL();
071
072    boolean isEnabled();
073
074    void setEnabled(Boolean enabled);
075
076    /**
077     * @since 7.4
078     */
079    boolean isProviderAvailable();
080}