source: trunk/src/org/expeditee/encryption/items/UserAppliedEncryptionPermission.java@ 1505

Last change on this file since 1505 was 1505, checked in by bnemhaus, 4 years ago

New Attributes (and repurposed old ones) to be used for encryption of frames:

  • FrameEncryptionLabel. Used to be EncryptionLabel, which is still the case for items. When applied to a frame, it determines the label used to encrypt the entire frame.
  • HomogeneousEncryptionLabel. Does not yet actually do anything. The future point of this attribute is to provide the label that must be used to encrypt items on the frame when the user has only homogeneous encryption permissions.
  • EncryptionFramePermission. Does not yet actually do anything. The future point of this attribute isto determine if a user is able to change the FrameEncryptionLabel on a frame. Level 0 (none), no they cannot. Level 1 (homogeneous), they can only change it to HomogeneousEncryptionLabel. Level 2 (Hetrogeneous Owner), they can change it to any label as long as the owner of the Frame has that label. Level 3 (Hetrogeneous), they can change it to anything.
  • EncryptionPermission. Does not yet actually do anything. The future point of this attribute is to determine what encryption labels can be applied to items on the frame. Level 0 (none), cannot apply an encryption label. Level 1 (homogeneous), they can only used the label specified in HomogeneousEncryptionLabel. Level 2 (Hetrogeneous Owner), they can only use encryption labels that the owner of the frame has. Level 3 (Hetrogeneous) they can use any labels to encrypt an item.
File size: 1.2 KB
Line 
1package org.expeditee.encryption.items;
2
3public enum UserAppliedEncryptionPermission {
4 none(0), homogeneous(1), hetrogeneous_owner(2), hetrogeneous(3);
5
6 private final int val;
7
8 private UserAppliedEncryptionPermission(int val) {
9 this.val = val;
10 }
11
12 public static UserAppliedEncryptionPermission getPermission(
13 String permissionCode,
14 UserAppliedEncryptionPermission defaultPermission) {
15 if (permissionCode == null) {
16 return defaultPermission;
17 }
18
19 permissionCode = permissionCode.trim().toLowerCase();
20 if (permissionCode.length() == 0) {
21 return defaultPermission;
22 }
23
24 try {
25 return resolve(Integer.parseInt(permissionCode), defaultPermission);
26 } catch (final NumberFormatException e) {
27 try {
28 return valueOf(permissionCode);
29 } catch (final Exception ex) {
30 return defaultPermission;
31 }
32 }
33 }
34
35 public int getCode() { return val; }
36
37 public String toString() { return this.name(); }
38
39 private static UserAppliedEncryptionPermission resolve(
40 int val,
41 UserAppliedEncryptionPermission defaultPermission) {
42 for (UserAppliedEncryptionPermission p : values()) {
43 if (p.val == val) {
44 return p;
45 }
46 }
47 return defaultPermission;
48 }
49}
Note: See TracBrowser for help on using the repository browser.