blob: ed21898d6812a2646b4551241858253e00eba7ea [file] [log] [blame]
Takeshi Hagikurad1898d32015-05-21 14:51:38 +09001<?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 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>Confirm Credential</name>
24 <group>security</group>
25 <package>com.example.android.confirmcredential</package>
26
Trevor Johns415e5ce2015-05-27 12:21:44 -070027 <minSdk>"MNC"</minSdk>
28 <targetSdkVersion>"MNC"</targetSdkVersion>
Takeshi Hagikurad1898d32015-05-21 14:51:38 +090029 <compileSdkVersion>"android-MNC"</compileSdkVersion>
30
31 <strings>
32 <intro>
33 <![CDATA[
34This sample demonstrates how you can use device credentials (PIN, Pattern, Password) in your app
35to authenticate the user before they are trying to complete some actions.
36 ]]>
37 </intro>
38 </strings>
39
40 <!-- The basic templates have already been enabled. Uncomment more as desired. -->
41 <template src="base" />
42
43 <metadata>
44 <!-- Values: {DRAFT | PUBLISHED | INTERNAL | DEPRECATED | SUPERCEDED} -->
45 <status>DRAFT</status>
46 <categories>Security</categories>
47 <technologies>Android</technologies>
48 <languages>Java</languages>
49 <solutions>Mobile</solutions>
50 <!-- Values: {BEGINNER | INTERMEDIATE | ADVANCED | EXPERT} -->
51 <level>INTERMEDIATE</level>
52 <!-- Dimensions: 512x512, PNG fomrat -->
53 <icon>screenshots/big-icon.png</icon>
54 <!-- Path to screenshots. Use <img> tags for each. -->
55 <screenshots>
56 <img>screenshots/1-purchase.png</img>
57 <img>screenshots/2-show-confirm-credential.png</img>
58 <img>screenshots/3-already-authenticated.png</img>
59 </screenshots>
60 <api_refs>
61 <android>android.app.KeyguardManager.createConfirmDeviceCredentialIntent</android>
62 <android>android.security.KeyGenParameterSpec</android>
63 <android>java.security.KeyStore</android>
64 <android>javax.crypto.Cipher</android>
65 <android>javax.crypto.KeyGenerator</android>
66 </api_refs>
67
68 <description>
69 <![CDATA[
70A sample that demonstrates how to use device credentials (PIN, Pattern, Password) in your app
71 ]]>
72 </description>
73
74 <intro>
75 <![CDATA[
76This sample demonstrates how you can use device credentials (PIN, Pattern, Password) in your app
77to authenticate the user before they are trying to complete some actions.
78
79First you need to create a symmetric key in the Android Key Store using [KeyGenerator][1]
80which can be only be used after the user has authenticated after the user is authenticated
81with their device credentials and pass [KeyGenParameterSpec][2].
82
83By setting an integer value to the
84[KeyGeneratorSpec.Builder.setUserAuthenticationValidityDurationSeconds][3], you can consider the
85user as authenticated if the user has been authenticated with the device credentials
86within the last x seconds.
87
88Then by calling [KeyguardManager.createConfirmDeviceCredentialIntent][4], you can show a screen
89to confirm device credentials to the user.
90
91[1]: https://developer.android.com/reference/javax/crypto/KeyGenerator.html
92[2]: https://developer.android.com/reference/android/security/KeyGenParameterSpec.html
93[3]: https://developer.android.com/reference/android/security/KeyGenParameterSpec.Builder#setUserAuthenticationValidityDurationSeconds().html
94[4]: https://developer.android.com/reference/android/app/KeyguardManager.createConfirmDeviceCredentialIntent().html
95 ]]>
96 </intro>
97 </metadata>
98</sample>