Changeset 1456 for trunk


Ignore:
Timestamp:
11/29/19 15:10:31 (4 years ago)
Author:
bnemhaus
Message:

Added usage instructions to SplitSecret and GenerateSecret actions.

File:
1 edited

Legend:

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

    r1430 r1456  
    2020
    2121import org.expeditee.auth.AuthenticatorBrowser;
     22import org.expeditee.auth.account.Authenticate;
     23import org.expeditee.core.Colour;
    2224import org.expeditee.gui.DisplayController;
    2325import org.expeditee.gui.Frame;
    2426import org.expeditee.gui.FrameIO;
     27import org.expeditee.gui.FreeItems;
    2528import org.expeditee.gui.MessageBay;
    2629import org.expeditee.items.Item;
     
    5053        }
    5154       
     55        public static Text GenerateSecret() {
     56                return AuthGenerateSecretUsage();
     57        }
     58       
    5259        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);
    5365                return AuthGenerateSecret(label);
    5466        }
     
    6880        public static void Decrypt(Text labelWithKey) {
    6981                AuthDecrypt(labelWithKey);
     82        }
     83       
     84        public static Text AuthGenerateSecret() {
     85                return AuthGenerateSecretUsage();
    7086        }
    7187       
     
    8298                return text;
    8399        }
    84 
     100       
    85101        public static Text AuthSplitSecret(Text key) {
     102                if (!FreeItems.hasItemsAttachedToCursor()) {
     103                        return AuthSplitSecretUsage();
     104                }
     105               
    86106                // Retrieve secret
    87107                String secret = key.getData().get(0);
     
    103123                }
    104124                key.setData(data);
     125                key.setText(arguments[0]);
    105126               
    106127                return key;
    107128        }
    108        
     129               
    109130        public static Text AuthJoinSecret(Text key) {
    110131                Map<Integer, byte[]> contributingParts = new HashMap<Integer, byte[]>();
     
    216237                secretsFrame.addText(500, 500, name, null).addToData(data);
    217238        }
     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        }
    218275}
Note: See TracChangeset for help on using the changeset viewer.