Changeset 1394 for trunk


Ignore:
Timestamp:
05/30/19 12:40:31 (5 years ago)
Author:
bln4
Message:

EncPermission setting is now represented as a full mask. An invalid value when the user sets the permission results in the default being used as according to the mask.

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

Legend:

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

    r1390 r1394  
    1212        private UserAppliedEncryptionPermission otherPermission;
    1313       
    14         public EncryptionPermissionTriple(String permissionCode,
    15                         UserAppliedEncryptionPermission defaultPermission) {
    16                 ownerPermission = defaultPermission;
    17                 groupPermission = defaultPermission;
    18                 otherPermission = defaultPermission;
     14        public EncryptionPermissionTriple(String permissionCode, String defaultPermission) {
     15                ownerPermission = defaultPermission.length() > 0 ?
     16                                UserAppliedEncryptionPermission.getPermission(defaultPermission.charAt(0) + "", UserAppliedEncryptionPermission.none) :
     17                                UserAppliedEncryptionPermission.none;
     18                groupPermission = defaultPermission.length() > 1 ?
     19                                UserAppliedEncryptionPermission.getPermission(defaultPermission.charAt(1) + "", UserAppliedEncryptionPermission.none) :
     20                                UserAppliedEncryptionPermission.none;;
     21                otherPermission = defaultPermission.length() > 2 ?
     22                                UserAppliedEncryptionPermission.getPermission(defaultPermission.charAt(2) + "", UserAppliedEncryptionPermission.none) :
     23                                UserAppliedEncryptionPermission.none;;
    1924               
    2025                if (permissionCode != null) {
     
    2429                                // If it does not then it will remain as the default permission passed to the function.
    2530                                String ownerPermissionCode = permissionCode.charAt(0) + "";
    26                                 this.ownerPermission = UserAppliedEncryptionPermission.getPermission(ownerPermissionCode, defaultPermission);
     31                                this.ownerPermission = UserAppliedEncryptionPermission.getPermission(ownerPermissionCode, ownerPermission);
    2732                               
    2833                                // If the permission code has a character at index 1, then it is the group permission.
     
    3035                                if (permissionCode.length() < 2) { return; }
    3136                                String groupPermissionCode = permissionCode.charAt(1) + "";
    32                                 this.groupPermission = UserAppliedEncryptionPermission.getPermission(groupPermissionCode, defaultPermission);
     37                                this.groupPermission = UserAppliedEncryptionPermission.getPermission(groupPermissionCode, groupPermission);
    3338                               
    3439                                if (permissionCode.length() < 3) { return; }
    3540                                String otherPermissionCode = permissionCode.charAt(2) + "";
    36                                 this.otherPermission = UserAppliedEncryptionPermission.getPermission(otherPermissionCode, defaultPermission);
     41                                this.otherPermission = UserAppliedEncryptionPermission.getPermission(otherPermissionCode, otherPermission);
    3742                        }
    3843                }
     
    6570       
    6671        public static EncryptionPermissionTriple convertString(String permissionCode) {
    67                 UserAppliedEncryptionPermission defaultPermission = UserAppliedEncryptionPermission.values()[EncryptionDefaults.DefaultEncryptionPermission.get()];
    68                 return new EncryptionPermissionTriple(permissionCode, defaultPermission);
     72                String defaultEncryptionPermission = EncryptionDefaults.DefaultEncryptionPermission.get();
     73                return new EncryptionPermissionTriple(permissionCode, defaultEncryptionPermission);
    6974        }
    7075       
  • trunk/src/org/expeditee/settings/encryption/EncryptionDefaults.java

    r1390 r1394  
    11package org.expeditee.settings.encryption;
    22
    3 import org.expeditee.setting.IntegerSetting;
     3import org.expeditee.setting.StringSetting;
    44
    55public class EncryptionDefaults {
    6         public static final IntegerSetting DefaultEncryptionPermission = new IntegerSetting(
    7                 "The default level of permission for encryption when not otherwise specified",
    8                 "DefaultEncryptionPermission",
    9                 0
     6        public static final StringSetting DefaultEncryptionPermission = new StringSetting(
     7                "The default level of permission for encryption when not otherwise specified", 
     8                "000"
    109        );
    1110}
Note: See TracChangeset for help on using the changeset viewer.