• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3 Copyright 2015 The Android Open Source Project
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9     http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16-->
17<!-- TODO(thagikura) Add tests for Activity and Fragment once InstrumentationTests can be run
18     on an emulator or a device.
19     At this moment, due to the different API between the image and the SDK, they can't be launched.
20     E.g. Skipping device 'Nexus 5 - MNC', due to different API preview 'MNC' and 'android-MNC'
21     -->
22<sample>
23    <name>Fingerprint Dialog Sample</name>
24    <group>security</group>
25    <package>com.example.android.fingerprintdialog</package>
26
27    <minSdk>23</minSdk>
28    <targetSdkVersion>23</targetSdkVersion>
29    <compileSdkVersion>23</compileSdkVersion>
30
31    <dependency>com.squareup.dagger:dagger:1.2.2</dependency>
32    <dependency>com.squareup.dagger:dagger-compiler:1.2.2</dependency>
33
34    <!-- TODO(thagikura) These dependencies should be created as testCompile instead of compile but
35         the template system doesn't allow androidTestCompile dependencies. Change it once fixed.
36    -->
37    <dependency>junit:junit:4.12</dependency>
38    <dependency>org.mockito:mockito-core:1.10.19</dependency>
39
40    <strings>
41        <intro>
42            <![CDATA[
43This sample demonstrates how you can use registered fingerprints to authenticate the user
44before proceeding some actions such as purchasing an item.
45            ]]>
46        </intro>
47    </strings>
48
49    <template src="base" />
50
51    <metadata>
52        <!-- Values: {DRAFT | PUBLISHED | INTERNAL | DEPRECATED | SUPERCEDED} -->
53        <status>DRAFT</status>
54        <categories>security</categories>
55        <technologies>Android</technologies>
56        <languages>Java</languages>
57        <solutions>Mobile</solutions>
58        <level>INTERMEDIATE</level>
59        <icon>screenshots/big-icon.png</icon>
60        <screenshots>
61            <img>screenshots/1-purchase-screen.png</img>
62            <img>screenshots/2-fingerprint-dialog.png</img>
63            <img>screenshots/3-fingerprint-authenticated.png</img>
64            <img>screenshots/4-new-fingerprint-enrolled.png</img>
65        </screenshots>
66
67        <api_refs>
68            <android>android.hardware.fingerprint.FingerprintManager</android>
69            <android>android.hardware.fingerprint.FingerprintManager.AuthenticationCallback</android>
70            <android>android.hardware.fingerprint.FingerprintManager.CryptoObject</android>
71            <android>android.security.KeyGenParameterSpec</android>
72            <android>java.security.KeyStore</android>
73            <android>javax.crypto.Cipher</android>
74            <android>javax.crypto.KeyGenerator</android>
75        </api_refs>
76
77        <description>
78<![CDATA[
79A sample that demonstrates to use registered fingerprints to authenticate the user in your app
80]]>
81        </description>
82
83        <intro>
84<![CDATA[
85This sample demonstrates how you can use registered fingerprints in your app to authenticate the user
86before proceeding some actions such as purchasing an item.
87
88First you need to create a symmetric key in the Android Key Store using [KeyGenerator][1]
89which can be only be used after the user has authenticated with fingerprint and pass
90a [KeyGeneratorSpec][2].
91
92By setting [KeyGeneratorSpec.Builder.setUserAuthenticationRequired][3] to true, you can permit the
93use of the key only after the user authenticate it including when authenticated with the user's
94fingerprint.
95
96Then start listening to a fingerprint on the fingerprint sensor by calling
97[FingerprintManager.authenticate][4] with a [Cipher][5] initialized with the symmetric key created.
98Or alternatively you can fall back to server-side verified password as an authenticator.
99
100Once the fingerprint (or password) is verified, the
101[FingerprintManager.AuthenticationCallback#onAuthenticationSucceeded()][6] callback is called.
102
103[1]: https://developer.android.com/reference/javax/crypto/KeyGenerator.html
104[2]: https://developer.android.com/reference/android/security/KeyGenParameterSpec.html
105[3]: https://developer.android.com/reference/android/security/KeyGenParameterSpec.Builder#setUserAuthenticationRequired().html
106[4]: https://developer.android.com/reference/android/hardware/FingerprintManager#authenticate().html
107[5]: https://developer.android.com/reference/javax/crypto/Cipher.html
108[6]: https://developer.android.com/reference/android/hardware/FingerprintManager.AuthenticationCallback#onAuthenticationSucceeded().html
109]]>
110        </intro>
111    </metadata>
112</sample>
113