- Timestamp:
- 11/29/19 15:10:31 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/encryption/Actions.java
r1430 r1456 20 20 21 21 import org.expeditee.auth.AuthenticatorBrowser; 22 import org.expeditee.auth.account.Authenticate; 23 import org.expeditee.core.Colour; 22 24 import org.expeditee.gui.DisplayController; 23 25 import org.expeditee.gui.Frame; 24 26 import org.expeditee.gui.FrameIO; 27 import org.expeditee.gui.FreeItems; 25 28 import org.expeditee.gui.MessageBay; 26 29 import org.expeditee.items.Item; … … 50 53 } 51 54 55 public static Text GenerateSecret() { 56 return AuthGenerateSecretUsage(); 57 } 58 52 59 public static Text GenerateSecret(String label) { 60 String nl = System.getProperty("line.separator"); 61 String secretsFrame = UserSettings.UserName.get() + 11; 62 StringBuilder instructions = new StringBuilder("You have generated a encryption label with name " + label + "." + nl); 63 instructions.append("Place this generated label on your secrets frame (" + secretsFrame + ") before using it."); 64 MessageBay.displayMessage(instructions.toString()).setLink(secretsFrame); 53 65 return AuthGenerateSecret(label); 54 66 } … … 68 80 public static void Decrypt(Text labelWithKey) { 69 81 AuthDecrypt(labelWithKey); 82 } 83 84 public static Text AuthGenerateSecret() { 85 return AuthGenerateSecretUsage(); 70 86 } 71 87 … … 82 98 return text; 83 99 } 84 100 85 101 public static Text AuthSplitSecret(Text key) { 102 if (!FreeItems.hasItemsAttachedToCursor()) { 103 return AuthSplitSecretUsage(); 104 } 105 86 106 // Retrieve secret 87 107 String secret = key.getData().get(0); … … 103 123 } 104 124 key.setData(data); 125 key.setText(arguments[0]); 105 126 106 127 return key; 107 128 } 108 129 109 130 public static Text AuthJoinSecret(Text key) { 110 131 Map<Integer, byte[]> contributingParts = new HashMap<Integer, byte[]>(); … … 216 237 secretsFrame.addText(500, 500, name, null).addToData(data); 217 238 } 239 240 private static Text AuthSplitSecretUsage() { 241 String nl = System.getProperty("line.separator"); 242 String tab = " "; 243 StringBuilder message = new StringBuilder("Usage: " + nl); 244 message.append(tab + "With Text Item attached to cursor: " + nl); 245 message.append(tab + tab + "Content matches pattern \"<SecretName> <Amount of Coperation Required> <Individual Name 1> <Individual Name 2> ... <Individual Name N>\"" + nl); 246 message.append(tab + tab + "Context Example: \"SecretName 3 Sandra John Billy Sally Sam Tim\"" + nl); 247 message.append(tab + tab + "Data contains key data" + nl); 248 message.append(tab + "Middle click on this action." + nl); 249 message.append(tab + "Resulting Text Item will contain shares in data."); 250 return generateUsageText(message); 251 } 252 253 private static Text AuthGenerateSecretUsage() { 254 String nl = System.getProperty("line.separator"); 255 String tab = " "; 256 StringBuilder message = new StringBuilder("Usage: " + nl); 257 message.append(tab + "With Text Item attached to cursor: " + nl); 258 message.append(tab + tab + "Content should be one word with no spaces." + nl); 259 message.append(tab + tab + "Content represents the desired label name for the generated secret." + nl); 260 message.append(tab + tab + "This action will overwrite any existing data." + nl); 261 message.append(tab + "Middle click on this action." + nl); 262 message.append(tab + "Text Item will now contain a full key in its data." + nl); 263 message.append(tab + "Resulting Text Item is now a Secret and can be placed on secrets frame."); 264 return generateUsageText(message); 265 } 266 267 private static Text generateUsageText(StringBuilder message) { 268 Text ret = new Text(message.toString()); 269 ret.setPosition(DisplayController.getMousePosition()); 270 ret.setSize(14); 271 ret.setBackgroundColor(Colour.LIGHT_GRAY); 272 ret.setBorderColor(Colour.DARK_GRAY); 273 return ret; 274 } 218 275 }
Note:
See TracChangeset
for help on using the changeset viewer.