- Timestamp:
- 08/14/19 14:22:44 (5 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/encryption/Actions.java
r1414 r1430 23 23 import org.expeditee.gui.Frame; 24 24 import org.expeditee.gui.FrameIO; 25 import org.expeditee.gui.MessageBay; 25 26 import org.expeditee.items.Item; 26 27 import org.expeditee.items.Text; … … 31 32 public class Actions implements CryptographyConstants { 32 33 33 public static void TestSurrogate(Item primary) { 34 System.out.println("Test surrogates: "); 34 public static void SetSurrogateFor(Text surrogate, Text action) { 35 Frame frame = DisplayController.getCurrentFrame(); 36 String[] split = action.getText().split(" "); 37 38 if (split.length >= 2) { 39 int primaryID = Integer.parseInt(split[1]); 40 Item itemWithID = frame.getItemWithID(primaryID); 41 if (itemWithID == null) { 42 MessageBay.displayMessage("No item with ID " + primaryID + " exists on this frame."); 43 return; 44 } else { 45 itemWithID.addToSurrogates(surrogate); 46 } 47 } else { 48 MessageBay.displayMessage("Usage: SetSurrogateFor Int, inject desired surrogate."); 49 } 35 50 } 36 51 -
trunk/src/org/expeditee/encryption/io/EncryptedExpWriter.java
r1420 r1430 194 194 Function<Item, Boolean> isTagInherited = surrogate -> surrogate.isTagInherited(tag + ""); 195 195 BinaryOperator<Boolean> trueExists = (a, b) -> a || b; 196 boolean surrogatesInherit = surrogateItems.stream().map(isTagInherited).collect(Collectors.reducing(trueExists)). get();196 boolean surrogatesInherit = surrogateItems.stream().map(isTagInherited).collect(Collectors.reducing(trueExists)).orElseGet(() -> false); 197 197 boolean userHasKey = Label.getLabel(toWrite.getEncryptionLabel()) == LabelResult.SuccessResolveLabelToKey; 198 198 199 // If we have no surrogates that inherit this property from us, and we have the label required to encrypt it, then we should en tryit.199 // 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. 200 200 if (!surrogatesInherit && userHasKey) { 201 201 EncryptionDetail reencryptOnSave = new EncryptionDetail(EncryptionDetail.Type.ReencryptOnSave); -
trunk/src/org/expeditee/encryption/items/surrogates/Label.java
r1415 r1430 54 54 55 55 public static List<String> getAccessibleLabelsNames(ItemsList itemsList) { 56 // TODO make copy of itemsList in here and then adjust callers so they do not need to make copy. 57 // Alternatively, filter instead of removeIf 56 58 Text[] userLabels = KeyList.UserLabels.get(); 57 59 Stream<String> accessibleUserWideLabels = Arrays.asList(userLabels).stream().map(label -> label.getText()); 58 60 59 Predicate<Item> is LabelWithoutEncryptionLabel = item -> item.getEncryptionLabel() == null || item.getEncryptionLabel().isEmpty();60 itemsList.removeIf(is LabelWithoutEncryptionLabel);61 Predicate<Item> isItemWithoutEncryptionLabel = item -> item.getEncryptionLabel() == null || item.getEncryptionLabel().isEmpty(); 62 itemsList.removeIf(isItemWithoutEncryptionLabel); 61 63 Stream<String> accessibleFrameLocalLabels = itemsList.underlying().stream().map(item -> item.getEncryptionLabel()).distinct(); 62 64 -
trunk/src/org/expeditee/gui/AttributeUtils.java
r1415 r1430 308 308 _Attrib.put("EncryptionLabel", Item.class.getMethod("getEncryptionLabel"), 309 309 Item.class.getMethod("setEncryptionLabel", pString)); 310 _Attrib.put("ID", Item.class.getMethod("getID"), 311 Item.class.getMethod("setIDFail", pInt)); 310 312 311 313 // Text Items -
trunk/src/org/expeditee/gui/DisplayController.java
r1415 r1430 1235 1235 1236 1236 Label.progressSurrogateMode(); 1237 Frame currentFrame = DisplayController.getCurrentFrame(); 1238 ItemsList primaryBody = currentFrame.getPrimaryBody(); 1239 ItemsList primaryBodyCopy = new ItemsList(primaryBody); 1240 List<String> accessibleLabelsNames = Label.getAccessibleLabelsNames(primaryBodyCopy); 1241 StringBuilder sb = new StringBuilder("Surrogate Mode currently accepts labels: "); 1242 for (String acceessibleLabel: accessibleLabelsNames) { 1243 sb.append(acceessibleLabel + ", "); 1244 } 1245 String message = sb.substring(0, sb.length() - 2); 1246 MessageBay.displayMessage(message); 1237 1247 1238 1248 getCurrentFrame().parse(); -
trunk/src/org/expeditee/gui/Frame.java
r1426 r1430 31 31 import java.util.List; 32 32 import java.util.Map; 33 import java.util.Set; 33 34 import java.util.Stack; 34 35 import java.util.stream.Collectors; … … 1020 1021 if (item.isSurrogate()) { 1021 1022 removeItem(item, recalculate, _surrogateItemsBody); 1023 Set<Item> primariesSurrogates = item.getPrimary().getSurrogates(); 1024 primariesSurrogates.remove(item); 1022 1025 } else { 1023 1026 removeItem(item, recalculate, _primaryItemsBody); -
trunk/src/org/expeditee/items/Item.java
r1429 r1430 1043 1043 * TODO: What does it mean to have a negative ID# (as used in TDFC)? cts16 1044 1044 */ 1045 public int getID() 1046 { 1045 public int getID() { 1047 1046 return _id; 1048 1047 } … … 2219 2218 } 2220 2219 } 2220 2221 /** 2222 * Function called when a user attempts to set the ID of a Item. Simply provides 2223 * feedback to the user telling them that they are not allowed to do this. This 2224 * function is provided so that users are able to get the ID of a item when 2225 * extracting properties. See {@link org.expeditee.gui.AttributeUtils}. 2226 * 2227 * @param newID The requested new ID that will be ignored. 2228 */ 2229 public void setIDFail(int newID) { 2230 MessageBay.displayMessage("A user cannot change the ID of an item."); 2231 } 2221 2232 2222 2233 /** … … 4156 4167 4157 4168 public void addToSurrogates(Item surrogate) { 4169 this.getParent().removeItem(surrogate); 4158 4170 this.surrogateItems.add(surrogate); 4159 4171 surrogate.setAsSurrogateFor(this); … … 4162 4174 EncryptionDetail reencryptOnSave = new EncryptionDetail(EncryptionDetail.Type.ReencryptOnSave); 4163 4175 EncryptionDetail unencryptedOnSave = new EncryptionDetail(EncryptionDetail.Type.UnencryptedOnSave); 4164 EncryptionDetail inheritanceCheckOnSave = new EncryptionDetail(EncryptionDetail.Type.InheritanceCheckOnSave);4165 4176 4166 4177 for (Character tag: DefaultFrameWriter.getItemCharTags().keySet()) { … … 4179 4190 4180 4191 for (String tag: DefaultFrameWriter.getItemStrTags().keySet()) { 4181 primaryPropertyEncryption.put(tag, inheritanceCheckOnSave.clone());4192 primaryPropertyEncryption.put(tag, unencryptedOnSave.clone()); 4182 4193 surrogate.surrogatePropertyInheritance.put(tag + "", true); 4183 4194 } … … 4231 4242 */ 4232 4243 protected boolean subjectToInheritanceCheckOnSave(String tag) { 4244 if (tag.equals(DefaultFrameWriter.TYPE_AND_ID_STR)) { 4245 return false; 4246 } 4233 4247 Item primary = getPrimary(); 4234 4248 if (primary == null) return false;
Note:
See TracChangeset
for help on using the changeset viewer.