aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseChangeParcel.java
blob: 8b08aa11525292d89334fff3f9859bf5ad4b2206 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package org.sufficientlysecure.keychain.service;

import android.os.Parcel;
import android.os.Parcelable;

public class PassphraseChangeParcel implements Parcelable {

    // the master key id to be edited.
    public Long mMasterKeyId;
    // the first sub key id that is not stripped.
    public Long mValidSubkeyId;
    // the key fingerprint, for safety.
    public byte[] mFingerprint;

    public ChangeUnlockParcel mNewUnlock;


    public PassphraseChangeParcel(long masterKeyId, byte[] fingerprint) {
        mMasterKeyId = masterKeyId;
        mFingerprint = fingerprint;
    }

    public PassphraseChangeParcel(Parcel source) {
        mValidSubkeyId = source.readInt() != 0 ? source.readLong() : null;
        mMasterKeyId = source.readLong();
        mFingerprint = source.createByteArray();

        mNewUnlock = source.readParcelable(getClass().getClassLoader());
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel destination, int flags) {
        destination.writeInt(mValidSubkeyId == null ? 0 : 1);
        if (mValidSubkeyId != null) {
            destination.writeLong(mValidSubkeyId);
        }
        destination.writeLong(mMasterKeyId);
        destination.writeByteArray(mFingerprint);
        destination.writeParcelable(mNewUnlock, flags);
    }

    public static final Creator<PassphraseChangeParcel> CREATOR = new Creator<PassphraseChangeParcel>() {
        public PassphraseChangeParcel createFromParcel(final Parcel source) {
            return new PassphraseChangeParcel(source);
        }

        public PassphraseChangeParcel[] newArray(final int size) {
            return new PassphraseChangeParcel[size];
        }
    };

    public String toString() {
        String out = "mMasterKeyId: " + mMasterKeyId + "\n";
        out += "mNewUnlock: " + mNewUnlock + "\n";

        return out;
    }
}