mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-24 01:32:16 -05:00
small fixes to user attribute handling
This commit is contained in:
parent
bbc9d90c3e
commit
73feaa974c
@ -507,6 +507,7 @@ public abstract class OperationResult implements Parcelable {
|
|||||||
MSG_MF_UID_PRIMARY (LogLevel.INFO, R.string.msg_mf_uid_primary),
|
MSG_MF_UID_PRIMARY (LogLevel.INFO, R.string.msg_mf_uid_primary),
|
||||||
MSG_MF_UID_REVOKE (LogLevel.INFO, R.string.msg_mf_uid_revoke),
|
MSG_MF_UID_REVOKE (LogLevel.INFO, R.string.msg_mf_uid_revoke),
|
||||||
MSG_MF_UID_ERROR_EMPTY (LogLevel.ERROR, R.string.msg_mf_uid_error_empty),
|
MSG_MF_UID_ERROR_EMPTY (LogLevel.ERROR, R.string.msg_mf_uid_error_empty),
|
||||||
|
MSG_MF_UAT_ERROR_EMPTY (LogLevel.ERROR, R.string.msg_mf_uat_error_empty),
|
||||||
MSG_MF_UAT_ADD_IMAGE (LogLevel.INFO, R.string.msg_mf_uat_add_image),
|
MSG_MF_UAT_ADD_IMAGE (LogLevel.INFO, R.string.msg_mf_uat_add_image),
|
||||||
MSG_MF_UAT_ADD_UNKNOWN (LogLevel.INFO, R.string.msg_mf_uat_add_unknown),
|
MSG_MF_UAT_ADD_UNKNOWN (LogLevel.INFO, R.string.msg_mf_uat_add_unknown),
|
||||||
MSG_MF_UNLOCK_ERROR (LogLevel.ERROR, R.string.msg_mf_unlock_error),
|
MSG_MF_UNLOCK_ERROR (LogLevel.ERROR, R.string.msg_mf_unlock_error),
|
||||||
|
@ -531,6 +531,10 @@ public class PgpKeyOperation {
|
|||||||
WrappedUserAttribute attribute = saveParcel.mAddUserAttribute.get(i);
|
WrappedUserAttribute attribute = saveParcel.mAddUserAttribute.get(i);
|
||||||
|
|
||||||
switch (attribute.getType()) {
|
switch (attribute.getType()) {
|
||||||
|
// the 'none' type must not succeed
|
||||||
|
case WrappedUserAttribute.UAT_NONE:
|
||||||
|
log.add(LogType.MSG_MF_UAT_ERROR_EMPTY, indent);
|
||||||
|
return new PgpEditKeyResult(PgpEditKeyResult.RESULT_ERROR, log, null);
|
||||||
case WrappedUserAttribute.UAT_IMAGE:
|
case WrappedUserAttribute.UAT_IMAGE:
|
||||||
log.add(LogType.MSG_MF_UAT_ADD_IMAGE, indent);
|
log.add(LogType.MSG_MF_UAT_ADD_IMAGE, indent);
|
||||||
break;
|
break;
|
||||||
|
@ -22,6 +22,7 @@ import org.spongycastle.bcpg.BCPGOutputStream;
|
|||||||
import org.spongycastle.bcpg.Packet;
|
import org.spongycastle.bcpg.Packet;
|
||||||
import org.spongycastle.bcpg.UserAttributePacket;
|
import org.spongycastle.bcpg.UserAttributePacket;
|
||||||
import org.spongycastle.bcpg.UserAttributeSubpacket;
|
import org.spongycastle.bcpg.UserAttributeSubpacket;
|
||||||
|
import org.spongycastle.bcpg.UserAttributeSubpacketInputStream;
|
||||||
import org.spongycastle.bcpg.UserAttributeSubpacketTags;
|
import org.spongycastle.bcpg.UserAttributeSubpacketTags;
|
||||||
import org.spongycastle.openpgp.PGPUserAttributeSubpacketVector;
|
import org.spongycastle.openpgp.PGPUserAttributeSubpacketVector;
|
||||||
|
|
||||||
@ -30,6 +31,8 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectStreamException;
|
import java.io.ObjectStreamException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class WrappedUserAttribute implements Serializable {
|
public class WrappedUserAttribute implements Serializable {
|
||||||
|
|
||||||
@ -72,9 +75,17 @@ public class WrappedUserAttribute implements Serializable {
|
|||||||
return out.toByteArray();
|
return out.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WrappedUserAttribute fromData (byte[] data) {
|
public static WrappedUserAttribute fromData (byte[] data) throws IOException {
|
||||||
// TODO
|
UserAttributeSubpacketInputStream in =
|
||||||
return null;
|
new UserAttributeSubpacketInputStream(new ByteArrayInputStream(data));
|
||||||
|
ArrayList<UserAttributeSubpacket> list = new ArrayList<UserAttributeSubpacket>();
|
||||||
|
while (in.available() > 0) {
|
||||||
|
list.add(in.readPacket());
|
||||||
|
}
|
||||||
|
UserAttributeSubpacket[] result = new UserAttributeSubpacket[list.size()];
|
||||||
|
list.toArray(result);
|
||||||
|
return new WrappedUserAttribute(
|
||||||
|
new PGPUserAttributeSubpacketVector(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Writes this object to an ObjectOutputStream. */
|
/** Writes this object to an ObjectOutputStream. */
|
||||||
@ -102,4 +113,12 @@ public class WrappedUserAttribute implements Serializable {
|
|||||||
private void readObjectNoData() throws ObjectStreamException {
|
private void readObjectNoData() throws ObjectStreamException {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (!WrappedUserAttribute.class.isInstance(o)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return mVector.equals(((WrappedUserAttribute) o).mVector);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -857,6 +857,7 @@
|
|||||||
<string name="msg_mf_uid_primary">"Changing primary user ID to %s"</string>
|
<string name="msg_mf_uid_primary">"Changing primary user ID to %s"</string>
|
||||||
<string name="msg_mf_uid_revoke">"Revoking user ID %s"</string>
|
<string name="msg_mf_uid_revoke">"Revoking user ID %s"</string>
|
||||||
<string name="msg_mf_uid_error_empty">"User ID must not be empty!"</string>
|
<string name="msg_mf_uid_error_empty">"User ID must not be empty!"</string>
|
||||||
|
<string name="msg_mf_uat_error_empty">"User attribute must not be empty!"</string>
|
||||||
<string name="msg_mf_uat_add_image">"Adding user attribute of type image"</string>
|
<string name="msg_mf_uat_add_image">"Adding user attribute of type image"</string>
|
||||||
<string name="msg_mf_uat_add_unknown">"Adding user attribute of unknown type"</string>
|
<string name="msg_mf_uat_add_unknown">"Adding user attribute of unknown type"</string>
|
||||||
<string name="msg_mf_unlock_error">"Error unlocking keyring!"</string>
|
<string name="msg_mf_unlock_error">"Error unlocking keyring!"</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user