mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
copyright header correction, style fixes
This commit is contained in:
parent
a234d09f91
commit
a9172e809f
@ -1,18 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2012-2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
* Copyright (C) 2013-2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||||
* Copyright (C) 2011 Senecaso
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* you may not use this file except in compliance with the License.
|
* it under the terms of the GNU General Public License as published by
|
||||||
* You may obtain a copy of the License at
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* You should have received a copy of the GNU General Public License
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
@ -53,14 +53,11 @@ import org.sufficientlysecure.keychain.util.Log;
|
|||||||
import java.security.SignatureException;
|
import java.security.SignatureException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
|
||||||
* Swag
|
|
||||||
*/
|
|
||||||
public class ViewCertActivity extends ActionBarActivity
|
public class ViewCertActivity extends ActionBarActivity
|
||||||
implements LoaderManager.LoaderCallbacks<Cursor> {
|
implements LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
|
|
||||||
// These are the rows that we will retrieve.
|
// These are the rows that we will retrieve.
|
||||||
static final String[] PROJECTION = new String[] {
|
static final String[] PROJECTION = new String[]{
|
||||||
Certs.MASTER_KEY_ID,
|
Certs.MASTER_KEY_ID,
|
||||||
Certs.USER_ID,
|
Certs.USER_ID,
|
||||||
Certs.TYPE,
|
Certs.TYPE,
|
||||||
@ -115,7 +112,6 @@ public class ViewCertActivity extends ActionBarActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSupportLoaderManager().initLoader(0, null, this);
|
getSupportLoaderManager().initLoader(0, null, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -127,7 +123,7 @@ public class ViewCertActivity extends ActionBarActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||||
if(data.moveToFirst()) {
|
if (data.moveToFirst()) {
|
||||||
String signeeKey = "0x" + PgpKeyHelper.convertKeyIdToHex(data.getLong(INDEX_MASTER_KEY_ID));
|
String signeeKey = "0x" + PgpKeyHelper.convertKeyIdToHex(data.getLong(INDEX_MASTER_KEY_ID));
|
||||||
mSigneeKey.setText(signeeKey);
|
mSigneeKey.setText(signeeKey);
|
||||||
|
|
||||||
@ -142,32 +138,38 @@ public class ViewCertActivity extends ActionBarActivity
|
|||||||
mSignerKey.setText(signerKey);
|
mSignerKey.setText(signerKey);
|
||||||
|
|
||||||
String signerUid = data.getString(INDEX_SIGNER_UID);
|
String signerUid = data.getString(INDEX_SIGNER_UID);
|
||||||
if(signerUid != null)
|
if (signerUid != null) {
|
||||||
mSignerUid.setText(signerUid);
|
mSignerUid.setText(signerUid);
|
||||||
else
|
} else {
|
||||||
mSignerUid.setText(R.string.unknown_uid);
|
mSignerUid.setText(R.string.unknown_uid);
|
||||||
|
}
|
||||||
|
|
||||||
PGPSignature sig = PgpConversionHelper.BytesToPGPSignature(data.getBlob(INDEX_DATA));
|
PGPSignature sig = PgpConversionHelper.BytesToPGPSignature(data.getBlob(INDEX_DATA));
|
||||||
PGPKeyRing signeeRing = ProviderHelper.getPGPKeyRing(this,
|
PGPKeyRing signeeRing = ProviderHelper.getPGPKeyRing(this,
|
||||||
KeychainContract.KeyRingData.buildPublicKeyRingUri(Long.toString(data.getLong(INDEX_MASTER_KEY_ID))));
|
KeychainContract.KeyRingData.buildPublicKeyRingUri(
|
||||||
|
Long.toString(data.getLong(INDEX_MASTER_KEY_ID))));
|
||||||
PGPKeyRing signerRing = ProviderHelper.getPGPKeyRing(this,
|
PGPKeyRing signerRing = ProviderHelper.getPGPKeyRing(this,
|
||||||
KeychainContract.KeyRingData.buildPublicKeyRingUri(Long.toString(sig.getKeyID())));
|
KeychainContract.KeyRingData.buildPublicKeyRingUri(
|
||||||
if(signerRing != null) try {
|
Long.toString(sig.getKeyID())));
|
||||||
sig.init(new JcaPGPContentVerifierBuilderProvider().setProvider(
|
|
||||||
Constants.BOUNCY_CASTLE_PROVIDER_NAME), signeeRing.getPublicKey());
|
if (signerRing != null) {
|
||||||
if (sig.verifyCertification(signeeUid, signerRing.getPublicKey())) {
|
try {
|
||||||
mStatus.setText("ok");
|
sig.init(new JcaPGPContentVerifierBuilderProvider().setProvider(
|
||||||
mStatus.setTextColor(getResources().getColor(R.color.bbutton_success));
|
Constants.BOUNCY_CASTLE_PROVIDER_NAME), signeeRing.getPublicKey());
|
||||||
} else {
|
if (sig.verifyCertification(signeeUid, signerRing.getPublicKey())) {
|
||||||
mStatus.setText("failed!");
|
mStatus.setText("ok");
|
||||||
|
mStatus.setTextColor(getResources().getColor(R.color.bbutton_success));
|
||||||
|
} else {
|
||||||
|
mStatus.setText("failed!");
|
||||||
|
mStatus.setTextColor(getResources().getColor(R.color.alert));
|
||||||
|
}
|
||||||
|
} catch (SignatureException e) {
|
||||||
|
mStatus.setText("error!");
|
||||||
|
mStatus.setTextColor(getResources().getColor(R.color.alert));
|
||||||
|
} catch (PGPException e) {
|
||||||
|
mStatus.setText("error!");
|
||||||
mStatus.setTextColor(getResources().getColor(R.color.alert));
|
mStatus.setTextColor(getResources().getColor(R.color.alert));
|
||||||
}
|
}
|
||||||
} catch(SignatureException e) {
|
|
||||||
mStatus.setText("error!");
|
|
||||||
mStatus.setTextColor(getResources().getColor(R.color.alert));
|
|
||||||
} catch(PGPException e) {
|
|
||||||
mStatus.setText("error!");
|
|
||||||
mStatus.setTextColor(getResources().getColor(R.color.alert));
|
|
||||||
} else {
|
} else {
|
||||||
mStatus.setText("key unavailable");
|
mStatus.setText("key unavailable");
|
||||||
mStatus.setTextColor(getResources().getColor(R.color.black));
|
mStatus.setTextColor(getResources().getColor(R.color.black));
|
||||||
@ -177,22 +179,26 @@ public class ViewCertActivity extends ActionBarActivity
|
|||||||
mAlgorithm.setText(algorithmStr);
|
mAlgorithm.setText(algorithmStr);
|
||||||
|
|
||||||
mRowReason.setVisibility(View.GONE);
|
mRowReason.setVisibility(View.GONE);
|
||||||
switch(data.getInt(INDEX_TYPE)) {
|
switch (data.getInt(INDEX_TYPE)) {
|
||||||
case PGPSignature.DEFAULT_CERTIFICATION:
|
case PGPSignature.DEFAULT_CERTIFICATION:
|
||||||
mType.setText(R.string.cert_default); break;
|
mType.setText(R.string.cert_default);
|
||||||
|
break;
|
||||||
case PGPSignature.NO_CERTIFICATION:
|
case PGPSignature.NO_CERTIFICATION:
|
||||||
mType.setText(R.string.cert_none); break;
|
mType.setText(R.string.cert_none);
|
||||||
|
break;
|
||||||
case PGPSignature.CASUAL_CERTIFICATION:
|
case PGPSignature.CASUAL_CERTIFICATION:
|
||||||
mType.setText(R.string.cert_casual); break;
|
mType.setText(R.string.cert_casual);
|
||||||
|
break;
|
||||||
case PGPSignature.POSITIVE_CERTIFICATION:
|
case PGPSignature.POSITIVE_CERTIFICATION:
|
||||||
mType.setText(R.string.cert_positive); break;
|
mType.setText(R.string.cert_positive);
|
||||||
|
break;
|
||||||
case PGPSignature.CERTIFICATION_REVOCATION: {
|
case PGPSignature.CERTIFICATION_REVOCATION: {
|
||||||
mType.setText(R.string.cert_revoke);
|
mType.setText(R.string.cert_revoke);
|
||||||
if(sig.getHashedSubPackets().hasSubpacket(SignatureSubpacketTags.REVOCATION_REASON)) {
|
if (sig.getHashedSubPackets().hasSubpacket(SignatureSubpacketTags.REVOCATION_REASON)) {
|
||||||
SignatureSubpacket p = sig.getHashedSubPackets().getSubpacket(
|
SignatureSubpacket p = sig.getHashedSubPackets().getSubpacket(
|
||||||
SignatureSubpacketTags.REVOCATION_REASON);
|
SignatureSubpacketTags.REVOCATION_REASON);
|
||||||
// For some reason, this is missing in SignatureSubpacketInputStream:146
|
// For some reason, this is missing in SignatureSubpacketInputStream:146
|
||||||
if(!(p instanceof RevocationReason)) {
|
if (!(p instanceof RevocationReason)) {
|
||||||
p = new RevocationReason(false, p.getData());
|
p = new RevocationReason(false, p.getData());
|
||||||
}
|
}
|
||||||
String reason = ((RevocationReason) p).getRevocationDescription();
|
String reason = ((RevocationReason) p).getRevocationDescription();
|
||||||
@ -233,7 +239,7 @@ public class ViewCertActivity extends ActionBarActivity
|
|||||||
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(Long.toString(mSignerKeyId))
|
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(Long.toString(mSignerKeyId))
|
||||||
);
|
);
|
||||||
// TODO notify user of this, maybe offer download?
|
// TODO notify user of this, maybe offer download?
|
||||||
if(mSignerKeyId == 0L)
|
if (mSignerKeyId == 0L)
|
||||||
return true;
|
return true;
|
||||||
viewIntent.setData(KeyRings.buildGenericKeyRingUri(
|
viewIntent.setData(KeyRings.buildGenericKeyRingUri(
|
||||||
Long.toString(signerMasterKeyId))
|
Long.toString(signerMasterKeyId))
|
||||||
|
@ -31,8 +31,6 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.Spinner;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.spongycastle.openpgp.PGPSignature;
|
import org.spongycastle.openpgp.PGPSignature;
|
||||||
@ -118,7 +116,6 @@ public class ViewKeyCertsFragment extends Fragment
|
|||||||
mStickyList.setAdapter(mAdapter);
|
mStickyList.setAdapter(mAdapter);
|
||||||
|
|
||||||
getLoaderManager().initLoader(0, null, this);
|
getLoaderManager().initLoader(0, null, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -193,7 +190,6 @@ public class ViewKeyCertsFragment extends Fragment
|
|||||||
*/
|
*/
|
||||||
private void initIndex(Cursor cursor) {
|
private void initIndex(Cursor cursor) {
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
|
|
||||||
mIndexMasterKeyId = cursor.getColumnIndexOrThrow(Certs.MASTER_KEY_ID);
|
mIndexMasterKeyId = cursor.getColumnIndexOrThrow(Certs.MASTER_KEY_ID);
|
||||||
mIndexUserId = cursor.getColumnIndexOrThrow(Certs.USER_ID);
|
mIndexUserId = cursor.getColumnIndexOrThrow(Certs.USER_ID);
|
||||||
mIndexRank = cursor.getColumnIndexOrThrow(Certs.RANK);
|
mIndexRank = cursor.getColumnIndexOrThrow(Certs.RANK);
|
||||||
@ -239,7 +235,6 @@ public class ViewKeyCertsFragment extends Fragment
|
|||||||
view.setTag(R.id.tag_mki, cursor.getLong(mIndexMasterKeyId));
|
view.setTag(R.id.tag_mki, cursor.getLong(mIndexMasterKeyId));
|
||||||
view.setTag(R.id.tag_rank, cursor.getLong(mIndexRank));
|
view.setTag(R.id.tag_rank, cursor.getLong(mIndexRank));
|
||||||
view.setTag(R.id.tag_certifierId, cursor.getLong(mIndexSignerKeyId));
|
view.setTag(R.id.tag_certifierId, cursor.getLong(mIndexSignerKeyId));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user