Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2bbfea5

Browse files
committed
support issuing new client certificates
1 parent 5a88945 commit 2bbfea5

File tree

13 files changed

+182
-4
lines changed

13 files changed

+182
-4
lines changed

keys.app/AndroidManifest.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.lambdaworks.keys"
4-
android:versionCode="1"
5-
android:versionName="1.0.0">
6-
<uses-sdk android:targetSdkVersion="17" android:minSdkVersion="16"/>
4+
android:versionCode="2"
5+
android:versionName="1.0.1">
6+
<uses-sdk android:targetSdkVersion="18" android:minSdkVersion="16"/>
77

88
<uses-permission android:name="android.permission.INTERNET"/>
99
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
@@ -27,6 +27,8 @@
2727

2828
<activity android:name=".InitActivity"/>
2929
<activity android:name=".ReadyActivity"/>
30+
<activity android:name=".IssueActivity" />
31+
<activity android:name=".ManageActivity" android:parentActivityName=".KeysActivity"/>
3032
<activity android:name=".SettingsActivity" android:parentActivityName=".KeysActivity"/>
3133
<activity android:name=".WebViewActivity"/>
3234

keys.app/res/layout/cert.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
android:layout_width="fill_parent"
3131
android:layout_height="wrap_content"
3232
android:layout_alignParentBottom="true"
33-
android:orientation="horizontal"
33+
android:orientation="vertical"
3434
android:gravity="center">
3535
<Button android:id="@+id/ok"
3636
style="?android:attr/borderlessButtonStyle"

keys.app/res/layout/issue.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:id="@+id/issue"
5+
android:layout_width="fill_parent"
6+
android:layout_height="fill_parent"
7+
android:layout_marginTop="15dp"
8+
android:layout_marginLeft="15dp"
9+
android:layout_marginRight="15dp"
10+
android:layout_marginBottom="10dp"
11+
android:columnCount="2">
12+
<TextView
13+
android:id="@+id/text"
14+
android:layout_width="wrap_content"
15+
android:layout_height="wrap_content"
16+
android:paddingBottom="8dp"
17+
android:text="@string/certIssued"
18+
/>
19+
<fragment
20+
android:tag="cert"
21+
android:name="com.lambdaworks.keys.CertFragment"
22+
android:layout_below="@id/text"
23+
android:layout_width="fill_parent"
24+
android:layout_height="fill_parent"/>
25+
</RelativeLayout>
26+

keys.app/res/menu/main.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

33
<menu xmlns:android="http://schemas.android.com/apk/res/android">
4+
<item android:id="@+id/manage" android:title="@string/certs"/>
45
<item android:id="@+id/settings" android:title="@string/settings"/>
56
</menu>

keys.app/res/values/strings.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,18 @@
2020
<string name="sampleCert">
2121
-----BEGIN EC PARAMETERS-----\nBgUrgQQAIg==\n-----END EC PARAMETERS-----\n-----BEGIN PRIVATE KEY-----\nMIG2AgEAMBAGByqGSM49AgEGBSuBBAAiBIGeMIGbAgEBBDAJ3adw8P6wq9SL4BXK\nzvKc0gU6L15a8+zfHNgCs9elqj5jms1pzkIvgCjzGOfkyhmhZANiAARhdfA1Bf0I\nRQZQdCFBoz68rPWoG0Sb3iya+YuF7IL6HOVUlvNv+WdekYRvo0SZhDeZd1qSMqrA\nhg7MY6RKMK3HhTua3t4U4Loa6t4y3nc6k/5X3ECNI54kJg4h3Ku9nX0=\n-----END PRIVATE KEY-----\n-----BEGIN CERTIFICATE-----\nMIIBnTCCASOgAwIBAgIIELsXGyuMbfwwCgYIKoZIzj0EAwMwGTEXMBUGA1UEAxMO\nS2V5cyBDQS9TZXJ2ZXIwHhcNMTMwMzEwMDYwOT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SVvRCj\n-----END CERTIFICATE-----\n
2222
</string>
23+
<string name="certIssued">
24+
Certificate generation complete. The following X.509 client certificate may be used to
25+
access the keys server on this device.
26+
</string>
2327
<string name="password">Password</string>
2428
<string name="copy">Copy to SD Card</string>
2529
<string name="ok">OK</string>
2630
<string name="certCopied">Cert copied to %s</string>
2731
<string name="serverActive">Keys server active</string>
32+
<string name="certs">Certificates</string>
33+
<string name="issue">Issue Certificate</string>
34+
<string name="issueSummary">Issue new client certificate</string>
2835
<string name="certificate">Certificate</string>
2936
<string name="settings">Settings</string>
3037
<string name="source">https://github.com/wg/keys</string>
@@ -37,4 +44,5 @@
3744
</string>
3845
<string name="send">Send</string>
3946
<string name="initializing">Initializing database</string>
47+
<string name="generating">Generating certificate</string>
4048
</resources>

keys.app/res/xml/manage.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
4+
<PreferenceCategory android:key="certificates" android:title="@string/certs">
5+
<Preference android:key="issue" android:title="@string/issue" android:summary="@string/issueSummary"/>
6+
</PreferenceCategory>
7+
</PreferenceScreen>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (C) 2013 - Will Glozer. All rights reserved.
2+
3+
package com.lambdaworks.keys;
4+
5+
import android.app.Activity;
6+
import android.os.Bundle;
7+
import android.view.Menu;
8+
9+
public class IssueActivity extends Activity {
10+
public void onCreate(Bundle state) {
11+
super.onCreate(state);
12+
setContentView(R.layout.issue);
13+
setTitle(getString(R.string.certificate));
14+
15+
String cert = getIntent().getStringExtra("cert");
16+
CertFragment fragment = (CertFragment) getFragmentManager().findFragmentByTag("cert");
17+
fragment.setCert(cert);
18+
}
19+
}

keys.app/src/com/lambdaworks/keys/KeysActivity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ public boolean onCreateOptionsMenu(Menu menu) {
6363
@Override
6464
public boolean onOptionsItemSelected(MenuItem item) {
6565
switch (item.getItemId()) {
66+
case R.id.manage:
67+
startActivity(new Intent(this, ManageActivity.class));
68+
break;
6669
case R.id.settings:
6770
startActivity(new Intent(this, SettingsActivity.class));
6871
break;

keys.app/src/com/lambdaworks/keys/KeysCore.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ public static File databaseDir(Context context) {
1515
return new File(context.getFilesDir(), "db");
1616
}
1717

18+
public static String issueCert(Context context) {
19+
String path = databaseDir(context).getAbsolutePath();
20+
return issueCert(path);
21+
}
22+
1823
public static native String initialize(String path, long N, long r, long p);
1924
public static native NetworkInterface[] interfaces();
25+
public static native String issueCert(String path);
2026
public static native Version version();
2127
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (C) 2013 - Will Glozer. All rights reserved.
2+
3+
package com.lambdaworks.keys;
4+
5+
import android.app.Activity;
6+
import android.os.Bundle;
7+
8+
public class ManageActivity extends Activity {
9+
@Override
10+
public void onCreate(Bundle state) {
11+
super.onCreate(state);
12+
ManageFragment settings = new ManageFragment();
13+
getFragmentManager().beginTransaction().replace(android.R.id.content, settings).commit();
14+
}
15+
}

0 commit comments

Comments
 (0)