- Timestamp:
- 05/31/19 11:39:55 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/encryption/io/EncryptedExpWriter.java
r1399 r1400 22 22 import org.expeditee.gui.MessageBay; 23 23 import org.expeditee.io.ExpWriter; 24 import org.expeditee.items.Item; 24 25 import org.expeditee.items.Text; 25 26 import org.expeditee.settings.UserSettings; … … 60 61 61 62 @Override 63 public void outputFrame(Frame frame) throws IOException { 64 individualItemEncryption(frame); 65 super.outputFrame(frame); 66 } 67 68 @Override 62 69 protected void writeLine(String line) throws IOException { 63 70 // do not write empty lines … … 71 78 _writer.write(toWrite); 72 79 _stringWriter.append(toWrite); 80 } 81 82 private void individualItemEncryption(Frame frame) { 83 // Find items with their own encryption label. 84 Collection<Item> itemsWithEncryptionLabel = frame.getAllItems(); 85 itemsWithEncryptionLabel.removeIf(i -> i.getEncryptionLabel() == null || i.getEncryptionLabel().isEmpty()); 86 87 for (Item i: itemsWithEncryptionLabel) { 88 // Encrypt the Text Items 89 if (i instanceof Text) { 90 byte[] keyBytes = resolveKeyFromLabel(i.getEncryptionLabel(), "(actually item) on " + i.getParent().getName()); 91 if (keyBytes == null) { continue; } 92 SecretKeySpec key = new SecretKeySpec(keyBytes, SymmetricAlgorithm); 93 byte[] encryptedBytes = EncryptSymmetric(i.getText().getBytes(), key); 94 i.setText(Base64.getEncoder().encodeToString(encryptedBytes)); 95 } 96 } 73 97 } 74 98
Note:
See TracChangeset
for help on using the changeset viewer.