1 /* 2 * Copyright (C) 2017 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 package com.android.tradefed.util.keystore; 17 18 /** A keystore for dry-run where any keystore value is always properly replaced and found. */ 19 public class DryRunKeyStore implements IKeyStoreClient { 20 21 @Override isAvailable()22 public boolean isAvailable() { 23 return true; 24 } 25 26 @Override containsKey(String key)27 public boolean containsKey(String key) { 28 return true; 29 } 30 31 @Override fetchKey(String key)32 public String fetchKey(String key) { 33 return null; 34 } 35 36 /** 37 * Special callback for the dry run keystore to create value of expected type. 38 * 39 * @param key the key for the option, will be ignored. 40 * @param optionType the return type expected. 41 */ fetchKey(String key, String optionType)42 public String fetchKey(String key, String optionType) { 43 switch (optionType) { 44 case "boolean": 45 return "true"; 46 case "long": 47 case "int": 48 case "integer": 49 case "float": 50 case "double": 51 return "0"; 52 case "string": 53 return ""; 54 default: 55 return ""; 56 } 57 } 58 } 59