Files
open-keychain/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/OpenPgpSignatureResult.java

111 lines
3.3 KiB
Java
Raw Normal View History

/*
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
*/
2013-09-10 23:19:34 +02:00
package org.openintents.openpgp;
import android.os.Parcel;
import android.os.Parcelable;
2013-09-10 23:19:34 +02:00
public class OpenPgpSignatureResult implements Parcelable {
2013-10-02 19:08:33 +02:00
// generic error on signature verification
2013-09-14 02:08:06 +02:00
public static final int SIGNATURE_ERROR = 0;
2014-02-14 17:01:17 +01:00
// successfully verified signature, with certified public key
public static final int SIGNATURE_SUCCESS_CERTIFIED = 1;
2013-10-02 19:08:33 +02:00
// no public key was found for this signature verification
2013-10-05 18:35:16 +02:00
// you can retrieve the key with
// getKeys(new String[] {String.valueOf(signatureResult.getKeyId)}, true, callback)
2013-10-02 19:08:33 +02:00
public static final int SIGNATURE_UNKNOWN_PUB_KEY = 2;
2014-02-14 17:01:17 +01:00
// successfully verified signature, but with certified public key
public static final int SIGNATURE_SUCCESS_UNCERTIFIED = 3;
2013-10-05 18:35:16 +02:00
int status;
2013-09-14 02:08:06 +02:00
boolean signatureOnly;
2013-10-05 18:35:16 +02:00
String userId;
long keyId;
2013-09-14 02:08:06 +02:00
2013-10-05 18:35:16 +02:00
public int getStatus() {
return status;
2013-09-14 02:08:06 +02:00
}
public boolean isSignatureOnly() {
return signatureOnly;
}
2013-10-05 18:35:16 +02:00
public String getUserId() {
return userId;
}
public long getKeyId() {
return keyId;
}
2013-09-10 23:19:34 +02:00
public OpenPgpSignatureResult() {
}
2013-10-05 18:35:16 +02:00
public OpenPgpSignatureResult(int signatureStatus, String signatureUserId,
boolean signatureOnly, long keyId) {
this.status = signatureStatus;
2013-09-14 02:08:06 +02:00
this.signatureOnly = signatureOnly;
2013-10-05 18:35:16 +02:00
this.userId = signatureUserId;
this.keyId = keyId;
}
2013-09-10 23:19:34 +02:00
public OpenPgpSignatureResult(OpenPgpSignatureResult b) {
2013-10-05 18:35:16 +02:00
this.status = b.status;
this.userId = b.userId;
2013-09-14 02:08:06 +02:00
this.signatureOnly = b.signatureOnly;
2013-10-05 18:35:16 +02:00
this.keyId = b.keyId;
}
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel dest, int flags) {
2013-10-05 18:35:16 +02:00
dest.writeInt(status);
2013-09-14 02:08:06 +02:00
dest.writeByte((byte) (signatureOnly ? 1 : 0));
2013-10-05 18:35:16 +02:00
dest.writeString(userId);
dest.writeLong(keyId);
}
2013-09-10 23:19:34 +02:00
public static final Creator<OpenPgpSignatureResult> CREATOR = new Creator<OpenPgpSignatureResult>() {
public OpenPgpSignatureResult createFromParcel(final Parcel source) {
OpenPgpSignatureResult vr = new OpenPgpSignatureResult();
2013-10-05 18:35:16 +02:00
vr.status = source.readInt();
2013-09-14 02:08:06 +02:00
vr.signatureOnly = source.readByte() == 1;
2013-10-05 18:35:16 +02:00
vr.userId = source.readString();
vr.keyId = source.readLong();
return vr;
}
2013-09-10 23:19:34 +02:00
public OpenPgpSignatureResult[] newArray(final int size) {
return new OpenPgpSignatureResult[size];
}
};
2013-09-09 22:38:09 +02:00
@Override
public String toString() {
String out = new String();
2013-10-05 18:35:16 +02:00
out += "\nstatus: " + status;
out += "\nuserId: " + userId;
2013-09-14 02:08:06 +02:00
out += "\nsignatureOnly: " + signatureOnly;
2013-10-05 18:35:16 +02:00
out += "\nkeyId: " + keyId;
2013-09-09 22:38:09 +02:00
return out;
}
}