1 /* 2 * Copyright (C) 2015 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.example.android.asymmetricfingerprintdialog.server; 18 19 import java.security.PublicKey; 20 21 /** 22 * An interface that defines the methods required for the store backend. 23 */ 24 public interface StoreBackend { 25 26 /** 27 * Verifies the authenticity of the provided transaction by confirming that it was signed with 28 * the private key enrolled for the userId. 29 * 30 * @param transaction the contents of the purchase transaction, its contents are 31 * signed 32 * by the 33 * private key in the client side. 34 * @param transactionSignature the signature of the transaction's contents. 35 * @return true if the signedSignature was verified, false otherwise. If this method returns 36 * true, the server can consider the transaction is successful. 37 */ verify(Transaction transaction, byte[] transactionSignature)38 boolean verify(Transaction transaction, byte[] transactionSignature); 39 40 /** 41 * Verifies the authenticity of the provided transaction by password. 42 * 43 * @param transaction the contents of the purchase transaction, its contents are signed by the 44 * private key in the client side. 45 * @param password the password for the user associated with the {@code transaction}. 46 * @return true if the password is verified. 47 */ verify(Transaction transaction, String password)48 boolean verify(Transaction transaction, String password); 49 50 /** 51 * Enrolls a public key associated with the userId 52 * 53 * @param userId the unique ID of the user within the app including server side 54 * implementation 55 * @param password the password for the user for the server side 56 * @param publicKey the public key object to verify the signature from the user 57 * @return true if the enrollment was successful, false otherwise 58 */ enroll(String userId, String password, PublicKey publicKey)59 boolean enroll(String userId, String password, PublicKey publicKey); 60 } 61