Display SHA-1 fingerprints for repositories
The fingerprint is divided into four groups for readability but otherwise identical to what keytool displays.
This commit is contained in:
parent
33fa2debf9
commit
c76da4e35f
@ -11,7 +11,7 @@
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
@ -23,6 +23,13 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
|
||||
<TextView android:id="@+id/fingerprint"
|
||||
android:textSize="14sp"
|
||||
android:typeface="monospace"
|
||||
android:singleLine="false"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -19,20 +19,21 @@
|
||||
|
||||
package org.fdroid.fdroid;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Formatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.fdroid.fdroid.R;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ListActivity;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@ -83,11 +84,29 @@ public class ManageRepo extends ListActivity {
|
||||
} else {
|
||||
server_line.put("inuse", R.drawable.btn_check_off);
|
||||
}
|
||||
if (repo.pubkey != null) {
|
||||
try {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-1");
|
||||
digest.update(Hasher.unhex(repo.pubkey));
|
||||
byte[] fingerprint = digest.digest();
|
||||
Formatter formatter = new Formatter(new StringBuilder());
|
||||
formatter.format("%02X", fingerprint[0]);
|
||||
for (int i=1; i < fingerprint.length; i++) {
|
||||
formatter.format(i % 5 == 0 ? " %02X" : ":%02X",
|
||||
fingerprint[i]);
|
||||
}
|
||||
server_line.put("fingerprint", formatter.toString());
|
||||
} catch (Exception e) {
|
||||
Log.w("FDroid", "Unable to get certificate fingerprint.\n"
|
||||
+ Log.getStackTraceString(e));
|
||||
}
|
||||
}
|
||||
result.add(server_line);
|
||||
}
|
||||
SimpleAdapter show_out = new SimpleAdapter(this, result,
|
||||
R.layout.repolisticons, new String[] { "address", "inuse" },
|
||||
new int[] { R.id.uri, R.id.img });
|
||||
R.layout.repolisticons,
|
||||
new String[] { "address", "inuse", "fingerprint" },
|
||||
new int[] { R.id.uri, R.id.img, R.id.fingerprint });
|
||||
|
||||
setListAdapter(show_out);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user