Ignore:
Timestamp:
07/24/19 11:23:45 (5 years ago)
Author:
bln4
Message:

Renamed Frame.getItems() to Frame.getSortedItems() to better represent its functionality.

-> org.apollo.ApolloGestureActions
-> org.apollo.ApolloSystem
-> org.expeditee.actions.Actions
-> org.expeditee.actions.Debug
-> org.expeditee.actions.ExploratorySearchActions
-> org.expeditee.actions.JfxBrowserActions
-> org.expeditee.actions.Misc
-> org.expeditee.actions.Navigation
-> org.expeditee.actions.ScriptBase
-> org.expeditee.actions.Simple
-> org.expeditee.agents.ComputeTree
-> org.expeditee.agents.CopyTree
-> org.expeditee.agents.DisplayComet
-> org.expeditee.agents.DisplayTree
-> org.expeditee.agents.DisplayTreeLeaves
-> org.expeditee.agents.GraphFramesetLinks
-> org.expeditee.agents.TreeProcessor
-> org.expeditee.gio.gesture.StandardGestureActions
-> org.expeditee.gui.DisplayController
-> org.expeditee.gui.FrameCreator
-> org.expeditee.gui.FrameIO
-> org.expeditee.io.DefaultTreeWriter
-> org.expeditee.io.JavaWriter
-> org.expeditee.io.PDF2Writer
-> org.expeditee.io.TXTWriter
-> org.expeditee.io.WebParser
-> org.expeditee.io.flowlayout.XGroupItem
-> org.expeditee.items.Dot
-> org.expeditee.items.Item
-> org.expeditee.items.ItemUtils
-> org.expeditee.network.FrameShare
-> org.expeditee.stats.TreeStats


Created ItemsList class to wrap ArrayList<Item>. Frames now use this new class to store its body list (used for display) as well as its primaryBody and surrogateBody.

-> org.expeditee.agents.Format
-> org.expeditee.agents.HFormat
-> org.expeditee.gio.gesture.StandardGestureActions
-> org.expeditee.gui.Frame
-> org.expeditee.gui.FrameUtils


Refactorted Frame.setResort(bool) to Frame.invalidateSorted() to better function how it is intended to with a more accurate name.

-> org.expeditee.agents.Sort


When writing out .exp files and getting attributes to respond to LEFT + RIGHT click, boolean items are by default true. This has always been the case. An ammendment to this is that defaults can now be established.
Also added 'EnterClick' functionality. If cursored over a item with this property and you press enter, it acts as if you have clicked on it instead.

-> org.expeditee.assets.resources-public.framesets.authentication.1.exp to 6.exp
-> org.expeditee.gio.gesture.StandardGestureActions
-> org.expeditee.gio.input.KBMInputEvent
-> org.expeditee.gio.javafx.JavaFXConversions
-> org.expeditee.gio.swing.SwingConversions
-> org.expeditee.gui.AttributeUtils
-> org.expeditee.io.Conversion
-> org.expeditee.io.DefaultFrameWriter
-> org.expeditee.items.Item


Fixed a bug caused by calling Math.abs on Integer.MIN_VALUE returning unexpected result. Due to zero being a thing, you cannot represent Math.abs(Integer.MIN_VALUE) in a Integer object. The solution is to use Integer.MIN_VALUE + 1 instead of Integer.MIN_VALUE.

-> org.expeditee.core.bounds.CombinationBounds
-> org.expeditee.io.flowlayout.DimensionExtent


Recoded the contains function in EllipticalBounds so that intersection tests containing circles work correctly.

-> org.expeditee.core.bounds.EllipticalBounds


Added toString() to PolygonBounds to allow for useful printing during debugging.

-> org.expeditee.core.bounds.PolygonBounds

Implemented Surrogate Mode!

-> org.expeditee.encryption.io.EncryptedExpReader
-> org.expeditee.encryption.io.EncryptedExpWriter
-> org.expeditee.encryption.items.surrogates.EncryptionDetail
-> org.expeditee.encryption.items.surrogates.Label
-> org.expeditee.gui.FrameUtils
-> org.expeditee.gui.ItemsList
-> org.expeditee.items.Item
-> org.expeditee.items.Text


???? Use Integer.MAX_VALUE cast to a float instead of Float.MAX_VALUE. This fixed some bug which I cannot remember.

-> org.expeditee.gio.TextLayoutManager
-> org.expeditee.gio.swing.SwingTextLayoutManager


Improved solution for dealing with the F10 key taking focus away from Expeditee due to it being a assessibility key.

-> org.expeditee.gio.swing.SwingInputManager


Renamed variable visibleItems in FrameGraphics.paintFrame to itemsToPaintCanditates to better represent functional intent.

-> org.expeditee.gui.FrameGraphics


Improved checking for if personal resources exist before recreating them

-> org.expeditee.gui.FrameIO


Repeated messages to message bay now have a visual feedback instead of just a beep. This visual feedback is in the form of a count of the amount of times it has repeated.

-> org.expeditee.gui.MessageBay


Updated comment on the Vector class to explain what vectors are.

-> org.expeditee.gui.Vector


Added constants to represent all of the property keys in DefaultFrameReader and DefaultFrameWriter.

-> org.expeditee.io.DefaultFrameReader
-> org.expeditee.io.DefaultFrameWriter


Updated the KeyList setting to be more heirarcial with how users will store their Secrets.

-> org.expeditee.settings.identity.secrets.KeyList

File:
1 edited

Legend:

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

    r1414 r1415  
    2424import javax.crypto.spec.SecretKeySpec;
    2525
     26import org.expeditee.core.Point;
    2627import org.expeditee.encryption.CryptographyConstants;
    2728import org.expeditee.encryption.items.surrogates.EncryptionDetail;
     
    3334import org.expeditee.io.DefaultFrameWriter;
    3435import org.expeditee.io.ExpReader;
     36import org.expeditee.items.Constraint;
    3537import org.expeditee.items.Item;
    3638import org.expeditee.items.Text;
     
    4446        private SecretKey personalKey;
    4547        private boolean accessDenied = false;
     48        private boolean _readingSurrogates;
     49        private static final Predicate<String> endOfSection = s -> s.equals(EncryptedExpWriter.TERMINATOR + "") || s.equals(EncryptedExpWriter.TERMINATOR_WITH_CONTINUATION);
    4650
    4751        public static boolean isEncryptedExpediteeFile(final String path) throws IOException {
    48                 final BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(path), "UTF-8"));
    49                 final String firstLine = in.readLine();
     52                BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(path), "UTF-8"));
     53                String firstLine = in.readLine();
    5054                in.close();
     55                if (firstLine == null) return false;
    5156                return firstLine.startsWith(ENCRYPTED_EXP_FLAG);
    5257        }
     
    8792                if (accessDenied) { return null; }
    8893               
     94                _readingSurrogates = false;
    8995                _reader = reader;
    9096                String next = "";
     
    106112                        next = readTheConstraints();
    107113                       
     114                        if (next.equals(EncryptedExpWriter.TERMINATOR_WITH_CONTINUATION)) {
     115                                // Read the surrogates
     116                                _readingSurrogates = true;
     117                                next = readTheItems(newFrame, delayedActions);
     118                                _readingSurrogates = false;
     119                        }
     120                       
    108121                        for(DelayedAction action: delayedActions) {
    109122                                action.exec();
     
    124137        }
    125138       
    126 //      @Override
    127 //      protected String readTheItems(Frame newFrame, List<DelayedAction> delayedActions) throws IOException {
    128 //              String next = null;
    129 //              Item currentItem = null;
    130 //             
    131 //              Predicate<String> endOfSection = s -> s.equals(EncryptedExpWriter.TERMINATOR + "") || s.equals(EncryptedExpWriter.TERMINATOR_WITH_CONTINUATION);
    132 //              while (_reader.ready() && !endOfSection.test(next = _reader.readLine())) {
    133 //                      if (!isValidLine(next)) {
    134 //                              continue;
    135 //                      }
    136 //                     
    137 //                      String tag = getTagEnc(next);
    138 //                      if (next.startsWith(DefaultFrameWriter.TYPE_AND_ID_STR + " ")) {
    139 //                              currentItem = newItem(next);
    140 //                              _linePoints.put(currentItem.getID(), currentItem);
    141 //                              newFrame.addItem(currentItem);
    142 //                              currentItem.setEncryptionDetailForTag(tag + "", EncryptionDetail.UnencryptedOnSave);
    143 //                      } else if (next.startsWith("SurrogateFor")) {
    144 //                              int parentID = Integer.parseInt(next.split(" ")[1]);
    145 //                              newFrame.getItemWithID(parentID).addToSurrogates(currentItem);
    146 //                              newFrame.addToSurrogates(currentItem);
    147 //                      } else if (currentItem != null && actionShouldBeDelayed(tag.charAt(0))) {
    148 //                              delayedActions.add(new DelayedAction(currentItem, next));
    149 //                      } else if (currentItem != null) {
    150 //                              processBodyLine(currentItem, next);
    151 //                      } else {
    152 //                              System.err.println("Error while reading in frame (ExpReader): Found body line but no current item to apply it to.");
    153 //                      }
    154 //              }
    155 //                             
    156 //              if (next.equals(EncryptedExpWriter.TERMINATOR_WITH_CONTINUATION)) {
    157 //                      next = readTheItems(newFrame, delayedActions);
    158 //              }
    159 //             
    160 //              return next;
    161 //      }
    162        
    163139        protected String readTheItems(Frame newFrame, List<DelayedAction> delayedActions) throws IOException {
    164                 // Read the primary item.
    165                 BiConsumer<Item, String> addToBody = (item, line) -> newFrame.addItem(item);
    166                 String next = readLineAfterLine(false, addToBody, delayedActions);
    167                
    168                 // Read the surrogate items.
    169                 if (next.equals(EncryptedExpWriter.TERMINATOR_WITH_CONTINUATION)) {
    170                         BiConsumer<Item, String> addToSurrogates = (item, line) -> {
    171                                 int parentID = Integer.parseInt(line.split(" ")[1]);
    172                                 newFrame.getItemWithID(parentID).addToSurrogates(item);
    173                                 newFrame.addToSurrogates(item);
    174                         };
    175                         next = readLineAfterLine(true, addToSurrogates, delayedActions);
     140                BiConsumer<Item, String> primaryAdd = (item, line) -> newFrame.addItem(item);
     141                BiConsumer<Item, String> surrogateAdd = (item, line) -> {
     142                        int parentID = Integer.parseInt(line.split(" ")[1]);
     143                        Item parent = newFrame.getItemWithID(parentID);
     144                        newFrame.addToSurrogatesOnLoad(item, parent);
     145                };
     146               
     147                if (_readingSurrogates) {
     148                        return readLineAfterLine(true, surrogateAdd, delayedActions);
     149                } else {
     150                        return readLineAfterLine(false, primaryAdd, delayedActions);
     151                }
     152        }
     153       
     154        @Override
     155        protected String readTheConstraints() throws IOException, Exception {
     156                String next = null;
     157                while (_reader.ready() && !endOfSection.test(next = _reader.readLine())) {
     158                        if (isValidLine(next)) {
     159                                Point idtype = separateValues(next.substring(2));
     160                                // The next line must be the endpoints
     161                                if (!_reader.ready()) {
     162                                        throw new Exception("Unexpected end of file");
     163                                }
     164                                next = _reader.readLine();
     165                                Point startend = separateValues(next.substring(2));
     166
     167                                Item a = _linePoints.get(startend.getX());
     168                                Item b = _linePoints.get(startend.getY());
     169
     170                                new Constraint(a, b, idtype.getX(), idtype.getY());
     171                        }
    176172                }
    177173                return next;
     
    182178                Item currentItem = null;
    183179               
    184                 Predicate<String> endOfSection = s -> s.equals(EncryptedExpWriter.TERMINATOR + "") || s.equals(EncryptedExpWriter.TERMINATOR_WITH_CONTINUATION);
    185180                while (_reader.ready() && !endOfSection.test(next = _reader.readLine())) {
    186181                        if (!isValidLine(next)) {
     
    195190                                        storeResult.accept(currentItem, next);
    196191                                }
    197                                 currentItem.setEncryptionDetailForTag(tag + "", EncryptionDetail.UnencryptedOnSave);
     192                                EncryptionDetail unencryptedOnSave = new EncryptionDetail(EncryptionDetail.Type.UnencryptedOnSave);
     193                                currentItem.setEncryptionDetailForTag(tag + "", unencryptedOnSave);
    198194                        } else if (next.startsWith("SurrogateFor")) {
    199195                                if (isSurrogate) {
     
    212208        }
    213209       
    214 //      private String readLineAfterLine(Consumer<Item> storeResult, List<DelayedAction> delayedActions) throws IOException {
    215 //              String next = null;
    216 //              Item currentItem = null;
    217 //             
    218 //              Predicate<String> endOfSection = s -> {
    219 //                      return s.equals(EncryptedExpWriter.TERMINATOR + "") || s.equals(EncryptedExpWriter.TERMINATOR_WITH_CONTINUATION);
    220 //              };
    221 //              while (_reader.ready() && !endOfSection.test(next = _reader.readLine())) {
    222 //                      if (!isValidLine(next)) {
    223 //                              continue;
    224 //                      }
    225 //                     
    226 //                      String tag = getTagEnc(next);
    227 //                      if (next.startsWith(DefaultFrameWriter.TYPE_AND_ID_STR + " ")) {
    228 //                              currentItem = newItem(next);
    229 //                              _linePoints.put(currentItem.getID(), currentItem);
    230 //                              currentItem.setEncryptionDetailForTag(tag + "", EncryptionDetail.UnencryptedOnSave);
    231 //                              storeResult.accept(currentItem);
    232 //                      } else if (next.startsWith("SurrogateFor")) {
    233 //                              int parentID = Integer.parseInt(next.split(" ")[1]);
    234 //                              newFrame.getItemWithID(parentID).addToSurrogates(currentItem);
    235 //                              new Delayed
    236 //                      }
    237 //              }
    238 //             
    239 //              return next;
    240 //      }
    241        
    242210        @Override
    243211        protected void processBodyLine(Item item, String line) {
     
    245213                String tag = getTagEnc(line);
    246214                String value = getValue(line);
    247                
    248                 if (item.isSurrogate() && item.isTagInherited(tag)) {
     215                boolean isEncryptedLine = isEncryptedLine(line);
     216               
     217                if (item.isSurrogate() && isEncryptedLine) {
     218                        // Surrogates should never have encrypted body lines.
    249219                        return;
    250220                }
    251221               
    252222                // Attempt to decrypt the line if necessary.
    253                 if (isEncryptedLine(line)) {
    254                         LabelResult res = Label.resolveKey(item.getEncryptionLabel());
     223                if (isEncryptedLine) {
     224                        LabelResult res = Label.getLabel(item.getEncryptionLabel());
    255225                        if (res == LabelResult.SuccessResolveLabelToKey) {
    256                                 item.setEncryptionDetailForTag(tag, EncryptionDetail.ReencryptOnSave);
     226                                EncryptionDetail reencryptOnSave = new EncryptionDetail(EncryptionDetail.Type.ReencryptOnSave);
     227                                item.setEncryptionDetailForTag(tag, reencryptOnSave);
    257228                                SecretKey key = new SecretKeySpec(res.key, SymmetricAlgorithm);
    258229                                byte[] decryptedBytes = DecryptSymmetric(Base64.getDecoder().decode(value), key);
    259230                                value = new String(decryptedBytes);                             
    260231                        } else {
    261                                 EncryptionDetail encryptionDetail = EncryptionDetail.UseUndecipheredValueOnSave.setUndecipheredValue(getValue(line));
    262                                 item.setEncryptionDetailForTag(tag, encryptionDetail);
     232                                EncryptionDetail undecipheredValueOnSave = new EncryptionDetail(EncryptionDetail.Type.UseUndecipheredValueOnSave);
     233                                undecipheredValueOnSave.setUndecipheredValue(getValue(line));
     234                                item.setEncryptionDetailForTag(tag, undecipheredValueOnSave);
    263235                                return;
    264236                        }
    265237                } else {
    266                         item.setEncryptionDetailForTag(tag, EncryptionDetail.UnencryptedOnSave);
     238                        EncryptionDetail unencryptedOnSave = new EncryptionDetail(EncryptionDetail.Type.UnencryptedOnSave);
     239                        item.setEncryptionDetailForTag(tag, unencryptedOnSave);
     240                        if (item.isSurrogate()) {
     241                                item.setTagNotInherited(tag);
     242                        }
    267243                }
    268244               
     
    394370               
    395371                private SecretKeySpec resolveLabel(String label) {
    396                         LabelResult res = Label.resolveKey(label);
     372                        LabelResult res = Label.getLabel(label);
    397373                        if (res == LabelResult.SuccessResolveLabelToKey) {
    398374                                byte[] keyBytes = res.key;
Note: See TracChangeset for help on using the changeset viewer.