1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.document.authorization;
17
18 import org.kuali.rice.kns.web.ui.Field;
19 import org.kuali.rice.krad.datadictionary.mask.MaskFormatter;
20
21 import java.util.HashMap;
22 import java.util.Map;
23 import java.util.Set;
24
25
26
27
28 @Deprecated
29 public class BusinessObjectRestrictionsBase implements
30 BusinessObjectRestrictions {
31 private Map<String, MaskFormatter> partiallyMaskedFields;
32 private Map<String, MaskFormatter> fullyMaskedFields;
33
34 protected Set<String> allRestrictedFields;
35
36 public BusinessObjectRestrictionsBase() {
37 clearAllRestrictions();
38 }
39
40 public boolean hasAnyFieldRestrictions() {
41 return !partiallyMaskedFields.isEmpty() || !fullyMaskedFields.isEmpty();
42 }
43
44 public boolean hasRestriction(String fieldName) {
45 return isPartiallyMaskedField(fieldName) || isFullyMaskedField(fieldName);
46 }
47
48 public void addFullyMaskedField(String fieldName,
49 MaskFormatter maskFormatter) {
50 fullyMaskedFields.put(fieldName, maskFormatter);
51 }
52
53 public void addPartiallyMaskedField(String fieldName,
54 MaskFormatter maskFormatter) {
55 partiallyMaskedFields.put(fieldName, maskFormatter);
56 }
57
58
59
60
61
62
63
64
65
66
67
68
69 public FieldRestriction getFieldRestriction(String fieldName) {
70 if (hasRestriction(fieldName)) {
71 FieldRestriction fieldRestriction = null;
72 if (isPartiallyMaskedField(fieldName)) {
73 fieldRestriction = new FieldRestriction(fieldName,
74 Field.PARTIALLY_MASKED);
75 fieldRestriction.setMaskFormatter(partiallyMaskedFields
76 .get(normalizeFieldName(fieldName)));
77 }
78 if (isFullyMaskedField(fieldName)) {
79 fieldRestriction = new FieldRestriction(fieldName, Field.MASKED);
80 fieldRestriction.setMaskFormatter(fullyMaskedFields
81 .get(normalizeFieldName(fieldName)));
82 }
83 return fieldRestriction;
84 } else {
85 return new FieldRestriction(fieldName, Field.EDITABLE);
86 }
87 }
88
89 public void clearAllRestrictions() {
90 partiallyMaskedFields = new HashMap<String, MaskFormatter>();
91 fullyMaskedFields = new HashMap<String, MaskFormatter>();
92 allRestrictedFields = null;
93 }
94
95
96
97
98
99
100
101
102
103 protected String normalizeFieldName(String fieldName) {
104 return fieldName;
105 }
106
107 protected boolean isFullyMaskedField(String fieldName) {
108 String normalizedFieldName = normalizeFieldName(fieldName);
109 return fullyMaskedFields.containsKey(normalizedFieldName);
110 }
111
112 protected boolean isPartiallyMaskedField(String fieldName) {
113 String normalizedFieldName = normalizeFieldName(fieldName);
114 return partiallyMaskedFields.containsKey(normalizedFieldName);
115 }
116 }