Changeset 1506


Ignore:
Timestamp:
01/31/20 13:49:48 (4 years ago)
Author:
bnemhaus
Message:

Permissions for encrypting frames are now respected. (Group level permissions still need testing and maybe implementation)

The current implementation of Hetrogeneous Owner requires that the owner of the frame specify the available labels. Injecting the property "HetrogeneousEncryptionLabels: <label name>" into the frame name item adds the specified label to the list of labels that those with 'Hetrogeneous (Owner)' permission are able to use.

Location:
trunk/src/org/expeditee
Files:
7 edited

Legend:

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

    r1504 r1506  
    7171                MessageBay.displayMessage("Test message sent.");
    7272        }
    73                
    74         public static void CheckMailTest() {
    75                 List<Mail.MailEntry> mail = MailBay.getMailClient().checkMail();
    76                 for (Mail.MailEntry entry: mail) {
    77                         MessageBay.displayMessage(entry.toString());
    78                 }
    79                 MessageBay.displayMessage(mail.size() + " new mail since last run.");
    80         }
    8173       
    8274        public static void SendTestOneOffMessage(String recipient) {
  • trunk/src/org/expeditee/encryption/io/EncryptedExpWriter.java

    r1431 r1506  
    5252        public EncryptedExpWriter(String encryptionLabel) {
    5353                label = encryptionLabel;
    54                 if (label.equals(labelNone)) {
     54                if (label.equals(getLabelNone())) {
    5555                        return;
    5656                }
     
    122122               
    123123                String toWrite;
    124                 if (key == null && label.equals(labelNone)) {
     124                if (key == null && label.equals(getLabelNone())) {
    125125                        toWrite = line + nl;
    126126                } else {
     
    276276                }
    277277        }
     278
     279        /**
     280         * @return the labelnone
     281         */
     282        public static String getLabelNone() {
     283                return labelNone;
     284        }
    278285}
  • trunk/src/org/expeditee/gui/AttributeUtils.java

    r1505 r1506  
    204204                       
    205205                        // Encryption Frame attributes
    206                         _FrameAttrib.put("FrameEncryptionLabel",                Frame.class.getMethod("getFrameEncryptionLabel"),
    207                                                                                                                         Frame.class.getMethod("setFrameEncryptionLabel", pString));
    208                         _FrameAttrib.put("EncryptionFramePermission",   Frame.class.getMethod("getFrameEncryptionPermission"),
    209                                                                                                                         Frame.class.getMethod("setFrameEncryptionPermission", pEncPermission));
    210                         _FrameAttrib.put("HomogeneousEncryptionLabel",  Frame.class.getMethod("getHomogeneousEncryptionLabel"),
    211                                                                                                                         Frame.class.getMethod("setHomogeneousEncryptionLabel", pString));
    212                         _FrameAttrib.put("EncryptionPermission",                Frame.class.getMethod("getEncryptionPermission"),
    213                                                                                                                         Frame.class.getMethod("setEncryptionPermission", pEncPermission));
     206                        _FrameAttrib.put("FrameEncryptionLabel",                        Frame.class.getMethod("getFrameEncryptionLabel"),
     207                                                                                                                                Frame.class.getMethod("setFrameEncryptionLabel", pString));
     208                        _FrameAttrib.put("EncryptionFramePermission",           Frame.class.getMethod("getFrameEncryptionPermission"),
     209                                                                                                                                Frame.class.getMethod("setFrameEncryptionPermission", pEncPermission));
     210                        _FrameAttrib.put("HomogeneousEncryptionLabel",          Frame.class.getMethod("getHomogeneousEncryptionLabel"),
     211                                                                                                                                Frame.class.getMethod("setHomogeneousEncryptionLabel", pString));
     212                        _FrameAttrib.put("EncryptionPermission",                        Frame.class.getMethod("getEncryptionPermission"),
     213                                                                                                                                Frame.class.getMethod("setEncryptionPermission", pEncPermission));
     214                        _FrameAttrib.put("HetrogeneousEncryptionLabels",        Frame.class.getMethod("getHetrogeneousFrameOwnerLabels"),
     215                                                                                                                                Frame.class.getMethod("addToHetrogeneousFrameOwnerLabels", pString));
    214216                       
    215217                        // aliases for Standard frame attribute settings
     
    220222                        // aliases for Encryption frame attribute settings
    221223                        _FrameAttrib.alias("encframelabel",     "FrameEncryptionLabel");
     224                        _FrameAttrib.alias("EncryptionFrameLabel", "FrameEncryptionLabel");
    222225                        _FrameAttrib.alias("encframeperm",      "EncryptionFramePermission");
    223226                        _FrameAttrib.alias("homoenclabel",      "HomogeneousEncryptionLabel");
  • trunk/src/org/expeditee/gui/Frame.java

    r1505 r1506  
    4747import org.expeditee.core.Image;
    4848import org.expeditee.core.bounds.PolygonBounds;
     49import org.expeditee.encryption.io.EncryptedExpWriter;
    4950import org.expeditee.encryption.items.EncryptionPermissionTriple;
     51import org.expeditee.encryption.items.UserAppliedEncryptionPermission;
    5052import org.expeditee.encryption.items.surrogates.Label;
    5153import org.expeditee.encryption.items.surrogates.Label.LabelInfo;
     
    195197
    196198        private String _encryptionLabel;
    197        
    198199        private String _homogeneousEncryptionLabel;
     200        private List<String> _hetrogeneousEncryptionLabels = new ArrayList<String>();   
    199201       
    200202        private String _groupFrameName;
     
    30073009       
    30083010        public void setFrameEncryptionLabel(String label) {
     3011                if (label == null) {
     3012                        _encryptionLabel = null;
     3013                        return;
     3014                }
     3015               
     3016                String errorMessage = "You do not have sufficient permissions to set the encryption label to " + label + " on frame " + getName();
     3017                UserAppliedEncryptionPermission p = getFrameEncryptionPermission().getPermission(this.getOwner(), this.getGroupMembers());
     3018                String homogeneousEncryptionLabel = getHomogeneousEncryptionLabel();
     3019                if (homogeneousEncryptionLabel == null) { homogeneousEncryptionLabel = getFrameEncryptionLabel(); }
     3020                if (homogeneousEncryptionLabel == null) { homogeneousEncryptionLabel = EncryptedExpWriter.getLabelNone(); }
     3021               
     3022                List<String> hetrogeneousFrameOwnerLabels = getHetrogeneousFrameOwnerLabels();
     3023               
     3024                switch (p) {
     3025                case none:
     3026                        MessageBay.displayMessage(errorMessage);
     3027                        return;
     3028                case homogeneous:
     3029                        if (!homogeneousEncryptionLabel.equals(label)) {
     3030                                MessageBay.displayMessage(errorMessage);
     3031                                return;
     3032                        }
     3033                        break;
     3034                case hetrogeneous_owner:
     3035                        if (!homogeneousEncryptionLabel.equals(label) && !hetrogeneousFrameOwnerLabels.contains(label)) {
     3036                                MessageBay.displayMessage(errorMessage);
     3037                                return;
     3038                        }
     3039                        break;
     3040                case hetrogeneous: break;
     3041                }
     3042               
    30093043                LabelInfo labelResult = Label.getLabel(label);
    30103044                boolean isProfileOrNone = label.equals("Profile") || label.equals("None");
     
    30183052                _encryptionLabel = label;
    30193053        }
     3054
     3055        public boolean hasEncryptionPermissionOrHigher(UserAppliedEncryptionPermission permissionLevel) {
     3056                UserAppliedEncryptionPermission p = getFrameEncryptionPermission().getPermission(this.getOwner(), this.getGroupMembers());
     3057                return p.ordinal() >= permissionLevel.ordinal();
     3058        }
    30203059       
    30213060        public EncryptionPermissionTriple getFrameEncryptionPermission() {
     3061                if (_frameEncryptionPermission == null) {
     3062                        _frameEncryptionPermission = EncryptionPermissionTriple.convertString("300");
     3063                }
    30223064                return _frameEncryptionPermission;
    30233065        }
     
    30293071        public String getHomogeneousEncryptionLabel() {
    30303072                return _homogeneousEncryptionLabel;
     3073        }
     3074       
     3075        public List<String> getHetrogeneousFrameOwnerLabels() {
     3076                if (_hetrogeneousEncryptionLabels == null) {
     3077                        _hetrogeneousEncryptionLabels = new ArrayList<String>();
     3078                }
     3079                return _hetrogeneousEncryptionLabels;
     3080        }
     3081       
     3082        public void addToHetrogeneousFrameOwnerLabels(String label) {
     3083                if (!UserSettings.UserName.get().equals(this.getOwner())) {
     3084                        MessageBay.displayMessage("Only the owner of a frame is able to add hetrogeneous owner encryption labels.");
     3085                        return;
     3086                }
     3087               
     3088                if (_hetrogeneousEncryptionLabels == null) {
     3089                        _hetrogeneousEncryptionLabels = new ArrayList<String>();
     3090                }
     3091                if (_hetrogeneousEncryptionLabels.contains(label)) {
     3092                        _hetrogeneousEncryptionLabels.remove(label);
     3093                } else {
     3094                        _hetrogeneousEncryptionLabels.add(label);
     3095                }
    30313096        }
    30323097       
     
    30363101                if (!isProfileOrNone && !labelResult.is(LabelResult.SuccessResolveLabelToKey)) {
    30373102                        MessageBay.displayMessage(labelResult.toString());
    3038                         this._homogeneousEncryptionLabel = null;
    3039                         return;
     3103                        MessageBay.displayMessage("You will not be able to set the FrameEncryptionLabel to the Homogeneous Label.");
    30403104                }
    30413105               
  • trunk/src/org/expeditee/io/Conversion.java

    r1505 r1506  
    650650                }
    651651
    652                 if ((method.getReturnType().isEnum()) || (name.equals("getPermission")) || (name.equals("getEncryptionPermission"))) {
     652                if ((method.getReturnType().isEnum()) || (name.equals("getPermission")) || (name.equals("getFrameEncryptionPermission"))) {
    653653                        try {
    654654                                return output.getClass().getMethod("getCode", new Class[] {})
  • trunk/src/org/expeditee/io/DefaultFrameReader.java

    r1505 r1506  
    104104                        _FrameTags.put('k', Frame.class.getMethod("setHomogeneousEncryptionLabel", pString));
    105105                        _FrameTags.put('e', Frame.class.getMethod("setEncryptionPermission", pEncPermission));
     106                        _FrameTags.put('a', Frame.class.getMethod("addToHetrogeneousFrameOwnerLabels", pString));
    106107
    107108                        // Note: As of 26/11/18 there are no unused letter item tags.  Use other characters.
  • trunk/src/org/expeditee/io/DefaultFrameWriter.java

    r1505 r1506  
    198198                        _FrameTags.put('k', Frame.class.getMethod("getHomogeneousEncryptionLabel"));
    199199                        _FrameTags.put('e', Frame.class.getMethod("getEncryptionPermission"));
     200                        _FrameTags.put('a', Frame.class.getMethod("getHetrogeneousFrameOwnerLabels"));
    200201                       
    201202                        // Note: As of 26/11/18 there are no unused letter item tags.  Use other characters.
Note: See TracChangeset for help on using the changeset viewer.