Ignore:
Timestamp:
08/15/19 12:57:28 (5 years ago)
Author:
bln4
Message:

Recoding of the Labels class to improve surrogate mode functionality. Surrogate mode is now maintained when you navigate from one frame to another, even if that frame has a different set of labels. Completely different sets of labels cause Expeditee to exit surrogate mode with a message to the user.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/encryption/io/EncryptedExpWriter.java

    r1430 r1431  
    2424import org.expeditee.encryption.items.surrogates.EncryptionDetail;
    2525import org.expeditee.encryption.items.surrogates.EncryptionDetail.Type;
     26import org.expeditee.encryption.items.surrogates.Label.LabelResult;
    2627import org.expeditee.encryption.items.surrogates.Label;
    27 import org.expeditee.encryption.items.surrogates.Label.LabelResult;
     28import org.expeditee.encryption.items.surrogates.Label.LabelInfo;
    2829import org.expeditee.gui.Frame;
    2930import org.expeditee.gui.Frame.BodyType;
     
    6465                        }
    6566                } else {
    66                         LabelResult res = Label.getLabel(label);
    67                         if (res == LabelResult.SuccessResolveLabelToKey) {
     67                        LabelInfo res = Label.getLabel(label);
     68                        if (res.is(LabelResult.SuccessResolveLabelToKey)) {
    6869                                byte[] keyBytes = res.key;
    6970                                key = new SecretKeySpec(keyBytes, SymmetricAlgorithm);
    70                         } else if (res == LabelResult.ErrorUnableToFindLabel) {
     71                        } else if (res.is(LabelResult.ErrorUnableToFindLabel)) {
    7172                                MessageBay.errorMessage(res.toString() + encryptionLabel);
    7273                                key = null;
     
    195196                BinaryOperator<Boolean> trueExists = (a, b) -> a || b;
    196197                boolean surrogatesInherit = surrogateItems.stream().map(isTagInherited).collect(Collectors.reducing(trueExists)).orElseGet(() -> false);
    197                 boolean userHasKey = Label.getLabel(toWrite.getEncryptionLabel()) == LabelResult.SuccessResolveLabelToKey;
     198                boolean userHasKey = Label.getLabel(toWrite.getEncryptionLabel()).is(LabelResult.SuccessResolveLabelToKey);
    198199               
    199200                // If we have no surrogates that inherit this property from us, and we have the label required to encrypt it, then we should encrypt it.
     
    213214                Method toRun = tags.get(tag);
    214215                Class<?> declarer = toRun.getDeclaringClass();
    215                 LabelResult res = Label.getLabel(toWrite.getEncryptionLabel());
    216                 if (declarer.isAssignableFrom(toWrite.getClass()) && res == LabelResult.SuccessResolveLabelToKey) {
     216                LabelInfo res = Label.getLabel(toWrite.getEncryptionLabel());
     217                if (declarer.isAssignableFrom(toWrite.getClass()) && res.is(LabelResult.SuccessResolveLabelToKey)) {
    217218                        try {
    218219                                Object o = toRun.invoke(toWrite, new Object[] {});
Note: See TracChangeset for help on using the changeset viewer.