Skip to content

Commit 45736fc

Browse files
krutonAndroid Git Automerger
authored andcommitted
am 8d581db: am 0190c7d: Merge "Add Android KeyStore API demo" into jb-mr2-dev
* commit '8d581dbfc54d15ae4001c9c8fb9aeb0bd478ef35': Add Android KeyStore API demo
2 parents 82465ad + 8d581db commit 45736fc

File tree

4 files changed

+742
-0
lines changed

4 files changed

+742
-0
lines changed

samples/ApiDemos/AndroidManifest.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2907,6 +2907,13 @@
29072907
</intent-filter>
29082908
</activity>
29092909

2910+
<activity android:name=".security.KeyStoreUsage" android:label="Security/KeyStore"
2911+
android:windowSoftInputMode="adjustPan">
2912+
<intent-filter>
2913+
<action android:name="android.intent.action.MAIN" />
2914+
<category android:name="android.intent.category.SAMPLE_CODE" />
2915+
</intent-filter>
2916+
</activity>
29102917
</application>
29112918

29122919
<instrumentation android:name=".app.LocalSampleInstrumentation"
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2013 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+
18+
<!--
19+
Layout for using the AndroidKeyStore provider.
20+
See src/com/android/sdk/security/AndroidKeyStoreUsage.java
21+
-->
22+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
23+
android:id="@+id/LinearLayout1"
24+
android:layout_width="match_parent"
25+
android:layout_height="match_parent"
26+
android:orientation="vertical"
27+
android:padding="6dip" >
28+
29+
<RelativeLayout
30+
android:id="@+id/entries_list_group"
31+
android:layout_width="fill_parent"
32+
android:layout_height="0dp"
33+
android:layout_marginBottom="12dp"
34+
android:layout_weight="1" >
35+
36+
<TextView
37+
android:id="@+id/entries_list_label"
38+
android:layout_width="wrap_content"
39+
android:layout_height="wrap_content"
40+
android:layout_marginLeft="12dp"
41+
android:layout_marginTop="12dp"
42+
android:text="@string/keystore_entries_list" />
43+
44+
<ListView
45+
android:id="@+id/entries_list"
46+
android:layout_width="fill_parent"
47+
android:layout_height="wrap_content"
48+
android:layout_alignLeft="@+id/entries_list_label"
49+
android:layout_below="@+id/entries_list_label"
50+
android:layout_marginBottom="12dp"
51+
android:choiceMode="singleChoice" >
52+
53+
<requestFocus />
54+
</ListView>
55+
56+
</RelativeLayout>
57+
58+
<RelativeLayout
59+
android:id="@+id/sign_group"
60+
android:layout_width="wrap_content"
61+
android:layout_height="wrap_content"
62+
android:layout_marginBottom="12dp"
63+
android:layout_marginTop="12dp" >
64+
65+
<TextView
66+
android:id="@+id/key_ops_header"
67+
android:layout_width="wrap_content"
68+
android:layout_height="wrap_content"
69+
android:layout_alignParentLeft="true"
70+
android:layout_alignParentTop="true"
71+
android:layout_marginBottom="6dp"
72+
android:text="@string/keystore_key_ops_header"
73+
android:textAppearance="?android:attr/textAppearanceMedium" />
74+
75+
<TextView
76+
android:id="@+id/plaintext_label"
77+
android:layout_width="wrap_content"
78+
android:layout_height="wrap_content"
79+
android:layout_alignLeft="@id/key_ops_header"
80+
android:layout_below="@id/key_ops_header"
81+
android:layout_marginLeft="6dp"
82+
android:text="@string/keystore_plaintext" />
83+
84+
<EditText
85+
android:id="@+id/plaintext"
86+
android:layout_width="fill_parent"
87+
android:layout_height="wrap_content"
88+
android:layout_alignBaseline="@+id/plaintext_label"
89+
android:layout_alignParentRight="true"
90+
android:layout_below="@+id/key_ops_header"
91+
android:layout_toRightOf="@id/plaintext_label"
92+
android:ems="10"
93+
android:maxLines="1" />
94+
95+
<TextView
96+
android:id="@+id/ciphertext_label"
97+
android:layout_width="wrap_content"
98+
android:layout_height="wrap_content"
99+
android:layout_alignLeft="@id/plaintext_label"
100+
android:layout_below="@+id/plaintext"
101+
android:text="@string/keystore_ciphertext" />
102+
103+
<EditText
104+
android:id="@+id/ciphertext"
105+
android:layout_width="fill_parent"
106+
android:layout_height="wrap_content"
107+
android:layout_alignBaseline="@+id/ciphertext_label"
108+
android:layout_alignParentRight="true"
109+
android:layout_below="@+id/plaintext"
110+
android:layout_toRightOf="@id/ciphertext_label"
111+
android:maxLines="1" />
112+
113+
<LinearLayout
114+
android:layout_width="fill_parent"
115+
android:layout_height="wrap_content"
116+
android:layout_alignLeft="@id/plaintext_label"
117+
android:layout_below="@+id/ciphertext" >
118+
119+
<Button
120+
android:id="@+id/sign_button"
121+
android:layout_width="wrap_content"
122+
android:layout_height="wrap_content"
123+
android:layout_weight="1"
124+
android:enabled="false"
125+
android:text="@string/keystore_sign" />
126+
127+
<Button
128+
android:id="@+id/verify_button"
129+
android:layout_width="wrap_content"
130+
android:layout_height="wrap_content"
131+
android:layout_weight="1"
132+
android:enabled="false"
133+
android:text="@string/keystore_verify" />
134+
135+
<Button
136+
android:id="@+id/delete_button"
137+
android:layout_width="wrap_content"
138+
android:layout_height="wrap_content"
139+
android:layout_weight="1"
140+
android:enabled="false"
141+
android:text="@string/keystore_delete" />
142+
143+
</LinearLayout>
144+
</RelativeLayout>
145+
146+
<RelativeLayout
147+
android:id="@+id/generate_group"
148+
android:layout_width="fill_parent"
149+
android:layout_height="wrap_content"
150+
android:layout_gravity="bottom"
151+
android:layout_marginTop="12dp" >
152+
153+
<TextView
154+
android:id="@+id/generating_header"
155+
android:layout_width="wrap_content"
156+
android:layout_height="wrap_content"
157+
android:layout_alignParentLeft="true"
158+
android:layout_alignParentTop="true"
159+
android:text="@string/keystore_generating_header"
160+
android:layout_marginBottom="6dp"
161+
android:textAppearance="?android:attr/textAppearanceMedium" />
162+
163+
<TextView
164+
android:id="@+id/entry_name_label"
165+
android:layout_width="wrap_content"
166+
android:layout_height="wrap_content"
167+
android:layout_below="@+id/generating_header"
168+
android:layout_marginBottom="12dp"
169+
android:layout_marginLeft="6dp"
170+
android:layout_alignLeft="@id/generating_header"
171+
android:text="@string/keystore_entry_alias" />
172+
173+
<Button
174+
android:id="@+id/generate_button"
175+
android:layout_width="wrap_content"
176+
android:layout_height="wrap_content"
177+
android:layout_alignLeft="@id/entry_name_label"
178+
android:layout_below="@+id/entry_name"
179+
android:text="@string/keystore_generate" />
180+
181+
<EditText
182+
android:id="@+id/entry_name"
183+
android:layout_width="wrap_content"
184+
android:layout_height="wrap_content"
185+
android:layout_alignBaseline="@+id/entry_name_label"
186+
android:layout_alignParentRight="true"
187+
android:layout_marginBottom="12dp"
188+
android:layout_toRightOf="@+id/entry_name_label"
189+
android:ems="10" />
190+
</RelativeLayout>
191+
192+
</LinearLayout>

samples/ApiDemos/res/values/strings.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,4 +1464,21 @@
14641464
<string name="task_complete">is complete</string>
14651465
<string name="task_not_complete">is not complete</string>
14661466

1467+
<!-- =========================== -->
1468+
<!-- Security API demo strings -->
1469+
<!-- =========================== --> <skip />
1470+
1471+
<string name="keystore_entries_list">List of entries:</string>
1472+
1473+
<string name="keystore_key_ops_header">Key operations</string>
1474+
<string name="keystore_plaintext">Plaintext:</string>
1475+
<string name="keystore_ciphertext">Ciphertext:</string>
1476+
<string name="keystore_sign">Sign</string>
1477+
<string name="keystore_verify">Verify</string>
1478+
<string name="keystore_delete">Delete</string>
1479+
1480+
<string name="keystore_generating_header">Generating</string>
1481+
<string name="keystore_entry_alias">Entry alias:</string>
1482+
<string name="keystore_generate">Generate</string>
1483+
<string name="keystore_no_alias_error">Must supply an alias</string>
14671484
</resources>

0 commit comments

Comments
 (0)