001/*
002 * (C) Copyright 2015 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 *      Nelson Silva
018 */
019package org.nuxeo.ecm.platform.oauth2.providers;
020
021import com.google.api.client.auth.oauth2.Credential;
022
023import javax.servlet.http.HttpServletRequest;
024import java.util.List;
025
026/**
027 * @since 7.3
028 */
029public interface OAuth2ServiceProvider {
030
031    /**
032     * Returns the authorization URL
033     */
034    String getAuthorizationUrl(HttpServletRequest request);
035
036    /**
037     * Returns the authorization URL
038     *
039     * @since 9.2
040     */
041    String getAuthorizationUrl(String serverURL);
042
043    /**
044     * Handles the authorization response and stores the token(s)
045     */
046    Credential handleAuthorizationCallback(HttpServletRequest request);
047
048    /**
049     * Loads a credential from the token store
050     */
051    Credential loadCredential(String user);
052
053    void setId(Long id);
054
055    /**
056     * @since 9.2
057     */
058    void setDescription(String description);
059
060    void setAuthorizationServerURL(String authorizationServerURL);
061
062    void setTokenServerURL(String tokenServerURL);
063
064    /**
065     * @since 9.2
066     */
067    void setUserAuthorizationURL(String userAuthorizationURL);
068
069    void setServiceName(String serviceName);
070
071    void setClientId(String clientId);
072
073    void setClientSecret(String clientSecret);
074
075    void setScopes(String... strings);
076
077    String getServiceName();
078
079    Long getId();
080
081    /**
082     * @since 9.2
083     */
084    String getDescription();
085
086    String getTokenServerURL();
087
088    /**
089     * @since 9.2
090     */
091    String getUserAuthorizationURL();
092
093    String getClientId();
094
095    String getClientSecret();
096
097    List<String> getScopes();
098
099    String getAuthorizationServerURL();
100
101    boolean isEnabled();
102
103    void setEnabled(Boolean enabled);
104
105    /**
106     * @since 7.4
107     */
108    boolean isProviderAvailable();
109}