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 android.security.cts.cve_2021_0685; 18 19 import android.accounts.AbstractAccountAuthenticator; 20 import android.accounts.Account; 21 import android.accounts.AccountAuthenticatorResponse; 22 import android.accounts.NetworkErrorException; 23 import android.app.Service; 24 import android.content.Context; 25 import android.content.Intent; 26 import android.os.Bundle; 27 import android.os.IBinder; 28 29 public class PocAuthService extends Service { 30 31 public static Bundle mAddAccountResponse; 32 33 @Override onBind(Intent intent)34 public IBinder onBind(Intent intent) { 35 return new Authenticator(this).getIBinder(); 36 } 37 38 private static class Authenticator extends AbstractAccountAuthenticator { 39 @Override addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options)40 public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, 41 String authTokenType, String[] requiredFeatures, Bundle options) 42 throws NetworkErrorException { 43 return mAddAccountResponse; 44 } 45 Authenticator(Context context)46 Authenticator(Context context) { 47 super(context); 48 } 49 50 @Override editProperties(AccountAuthenticatorResponse response, String accountType)51 public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) { 52 return null; 53 } 54 55 @Override confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options)56 public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, 57 Bundle options) throws NetworkErrorException { 58 return null; 59 } 60 61 @Override getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options)62 public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, 63 String authTokenType, Bundle options) throws NetworkErrorException { 64 return null; 65 } 66 67 @Override getAuthTokenLabel(String authTokenType)68 public String getAuthTokenLabel(String authTokenType) { 69 return null; 70 } 71 72 @Override updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options)73 public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, 74 String authTokenType, Bundle options) throws NetworkErrorException { 75 return null; 76 } 77 78 @Override hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features)79 public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, 80 String[] features) throws NetworkErrorException { 81 return null; 82 } 83 } 84 } 85