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 * Handles the authorization response and stores the token(s) 038 */ 039 Credential handleAuthorizationCallback(HttpServletRequest request); 040 041 /** 042 * Loads a credential from the token store 043 */ 044 Credential loadCredential(String user); 045 046 void setId(Long id); 047 048 void setAuthorizationServerURL(String authorizationServerURL); 049 050 void setTokenServerURL(String tokenServerURL); 051 052 void setServiceName(String serviceName); 053 054 void setClientId(String clientId); 055 056 void setClientSecret(String clientSecret); 057 058 void setScopes(String... strings); 059 060 String getServiceName(); 061 062 Long getId(); 063 064 String getTokenServerURL(); 065 066 String getClientId(); 067 068 String getClientSecret(); 069 070 List<String> getScopes(); 071 072 String getAuthorizationServerURL(); 073 074 boolean isEnabled(); 075 076 void setEnabled(Boolean enabled); 077 078 /** 079 * @since 7.4 080 */ 081 boolean isProviderAvailable(); 082}