1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.tradefed.auth; 18 19 import java.io.IOException; 20 import java.util.Collection; 21 import java.util.Map; 22 23 import com.google.api.client.auth.oauth2.Credential; 24 import com.google.auth.Credentials; 25 26 /** 27 * An interface for credential factory to create oauth2 {@link Credential}. Also provide information 28 * about the credentials. 29 */ 30 public interface ICredentialFactory { 31 32 /** 33 * Creates a {@link Credential} for the given scopes. 34 * 35 * @param scopes a list of API scopes. 36 * @return an oauth2 {@link Credential} 37 * @throws IOException 38 */ createCredential(Collection<String> scopes)39 public Credentials createCredential(Collection<String> scopes) throws IOException; 40 41 /** 42 * Get information about the credential factory's meta data, e.g. key file path, email, etc. 43 * 44 * @return a {@link Map} with information key to value. 45 */ getInfo()46 public Map<String, String> getInfo(); 47 } 48