37 | 38 | | 39 ||
43 | PREV CLASS 44 | NEXT CLASS | 45 |46 | FRAMES 47 | NO FRAMES 48 | 55 | 58 | 59 | 60 | | 61 |
64 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 65 |66 | DETAIL: FIELD | CONSTR | METHOD | 67 |
public class ESAPI
82 | ESAPI locator class is provided to make it easy to gain access to the current ESAPI classes in use.
83 | For example you can use the validator() function to access the validator methods. (i.e. ESAPI.validator().isValidCreditCard(creditcard, false)
)
84 |
85 | 86 |
87 |
97 | Method Summary | 98 ||
---|---|
101 | static SFDCAccessController |
102 | accessController()
103 |
104 | 105 | |
106 |
109 | static SFDCEncoder |
110 | encoder()
111 |
112 | 113 | |
114 |
117 | static SFDCValidator |
118 | validator()
119 |
120 | 121 | |
122 |
133 | Method Detail | 134 |
---|
140 | public static SFDCValidator validator()141 |
152 | public static SFDCEncoder encoder()153 |
164 | public static SFDCAccessController accessController()165 |
181 | 182 | | 183 ||
187 | PREV CLASS 188 | NEXT CLASS | 189 |190 | FRAMES 191 | NO FRAMES 192 | 199 | 202 | 203 | 204 | | 205 |
208 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 209 |210 | DETAIL: FIELD | CONSTR | METHOD | 211 |
37 | 38 | | 39 ||
43 | PREV CLASS 44 | NEXT CLASS | 45 |46 | FRAMES 47 | NO FRAMES 48 | 55 | 58 | 59 | 60 | | 61 |
64 | SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | 65 |66 | DETAIL: ENUM CONSTANTS | FIELD | METHOD | 67 |
82 | ExceptionReason - this enum defines the different reasons for the exception type. 83 |
84 | 85 |
86 |
95 | Enum Constant Summary | 96 ||
---|---|
GENERIC
99 |
100 | 101 | This is a generic reason. |
102 | |
NO_CREATE
105 |
106 | 107 | This error is due to the user not having the create permission on the specific object/field/record. |
108 | |
NO_DELETE
111 |
112 | 113 | This error is due to the user not having the delete permission on the specific object/field/record. |
114 | |
NO_READ
117 |
118 | 119 | This error is due to the user not having the read permission on the specific object/field/record. |
120 | |
NO_UPDATE
123 |
124 | 125 | This error is due to the user not having the update permission on the specific object/field/record. |
126 |
136 | Enum Constant Detail | 137 |
---|
143 | public static final SFDCAccessControlException.ExceptionReason GENERIC144 |
147 |
155 | public static final SFDCAccessControlException.ExceptionReason NO_CREATE156 |
159 |
167 | public static final SFDCAccessControlException.ExceptionReason NO_READ168 |
171 |
179 | public static final SFDCAccessControlException.ExceptionReason NO_UPDATE180 |
183 |
191 | public static final SFDCAccessControlException.ExceptionReason NO_DELETE192 |
195 |
209 | 210 | | 211 ||
215 | PREV CLASS 216 | NEXT CLASS | 217 |218 | FRAMES 219 | NO FRAMES 220 | 227 | 230 | 231 | 232 | | 233 |
236 | SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | 237 |238 | DETAIL: ENUM CONSTANTS | FIELD | METHOD | 239 |
37 | 38 | | 39 ||
43 | PREV CLASS 44 | NEXT CLASS | 45 |46 | FRAMES 47 | NO FRAMES 48 | 55 | 58 | 59 | 60 | | 61 |
64 | SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | 65 |66 | DETAIL: ENUM CONSTANTS | FIELD | METHOD | 67 |
83 | ExceptionType - this enum defines the different types of access control exceptions. 84 |
85 | 86 |
87 |
96 | Enum Constant Summary | 97 ||
---|---|
FIELD_ACCESS_VIOLATION
100 |
101 | 102 | This error type is a field level access violation. |
103 | |
GENERIC
106 |
107 | 108 | This error is a generic error type. |
109 | |
NO_RECORD_FOUND
112 |
113 | 114 | This error type is a generic record not found error. |
115 | |
FIELD_NOT_FOUND
118 |
119 | 120 | This error type is a generic field not found error. |
121 | |
OBJECT_ACCESS_VIOLATION
124 |
125 | 126 | This error type is an object level access violation. |
127 | |
SHARING_ACCESS_VIOLATION
130 |
131 | 132 | This error type is a sharing access violation. |
133 |
142 | Enum Constant Detail | 143 |
---|
149 | public static final SFDCAccessControlException.ExceptionType GENERIC150 |
153 |
161 | public static final SFDCAccessControlException.ExceptionType OBJECT_ACCESS_VIOLATION162 |
165 |
173 | public static final SFDCAccessControlException.ExceptionType FIELD_ACCESS_VIOLATION174 |
177 |
185 | public static final SFDCAccessControlException.ExceptionType SHARING_ACCESS_VIOLATION186 |
189 |
197 | public static final SFDCAccessControlException.ExceptionType NO_RECORD_FOUND198 |
201 |
209 | public static final SFDCAccessControlException.ExceptionType FIELD_NOT_FOUND210 |
213 |
227 | 228 | | 229 ||
233 | PREV CLASS 234 | NEXT CLASS | 235 |236 | FRAMES 237 | NO FRAMES 238 | 245 | 248 | 249 | 250 | | 251 |
254 | SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | 255 |256 | DETAIL: ENUM CONSTANTS | FIELD | METHOD | 257 |
37 | 38 | | 39 ||
43 | PREV CLASS 44 | NEXT CLASS | 45 |46 | FRAMES 47 | NO FRAMES 48 | 55 | 58 | 59 | 60 | | 61 |
64 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 65 |66 | DETAIL: FIELD | CONSTR | METHOD | 67 |
77 | SFDCAccessControlResults 78 |80 |SFDCAccessControlResults.DeleteResults 79 |
public class SFDCAccessControlResults.DeleteResults
89 | This class provides results info and functionality for delete operations. 90 |
91 | 92 |
93 |
102 | Constructor Summary | 103 ||
---|---|
SFDCAccessControlResults.DeleteResults(Database.DeleteResult[] results)
106 |
107 | 108 | This constructor sets the results from the delete operation. |
109 |
118 | Method Summary | 119 ||
---|---|
122 | Database.DeleteResult[] |
123 | getResults()
124 |
125 | 126 | Get the Database.DeleteResult [] returned by the delete operation. |
127 |
130 | Boolean |
131 | wasSuccessful()
132 |
133 | 134 | Did the delete operation succeed for all objects in the array? |
135 |
146 | Constructor Detail | 147 |
---|
153 | public SFDCAccessControlResults.DeleteResults(Database.DeleteResult[] results)154 |
157 |
165 | Method Detail | 166 |
---|
172 | public Database.DeleteResult[] getResults()173 |
176 |
185 | public Boolean wasSuccessful()186 |
191 |
205 | 206 | | 207 ||
211 | PREV CLASS 212 | NEXT CLASS | 213 |214 | FRAMES 215 | NO FRAMES 216 | 223 | 226 | 227 | 228 | | 229 |
232 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 233 |234 | DETAIL: FIELD | CONSTR | METHOD | 235 |
37 | 38 | | 39 ||
43 | PREV CLASS 44 | NEXT CLASS | 45 |46 | FRAMES 47 | NO FRAMES 48 | 55 | 58 | 59 | 60 | | 61 |
64 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 65 |66 | DETAIL: FIELD | CONSTR | METHOD | 67 |
77 | SFDCAccessControlResults 78 |80 |SFDCAccessControlResults.InsertResults 79 |
public class SFDCAccessControlResults.InsertResults
89 | This class provides results info and functionality for insert operations. 90 |
91 | 92 |
93 |
102 | Constructor Summary | 103 ||
---|---|
SFDCAccessControlResults.InsertResults(SObject[] objects,
106 | Database.SaveResult[] results)
107 |
108 | 109 | This constructor sets the objects that were actually inserted into the db, and also sets the results from that insert operation. |
110 |
119 | Method Summary | 120 ||
---|---|
123 | SObject[] |
124 | getInsertedObjects()
125 |
126 | 127 | Get the objects that were actually inserted into the db. |
128 |
131 | Database.SaveResult[] |
132 | getResults()
133 |
134 | 135 | Get the Database.SaveResult [] returned by the insert operation. |
136 |
139 | Boolean |
140 | wasSuccessful()
141 |
142 | 143 | Did the insert operation succeed for all objects in the array? |
144 |
155 | Constructor Detail | 156 |
---|
162 | public SFDCAccessControlResults.InsertResults(SObject[] objects, 163 | Database.SaveResult[] results)164 |
167 |
175 | Method Detail | 176 |
---|
182 | public Database.SaveResult[] getResults()183 |
186 |
195 | public SObject[] getInsertedObjects()196 |
202 |
211 | public Boolean wasSuccessful()212 |
217 |
231 | 232 | | 233 ||
237 | PREV CLASS 238 | NEXT CLASS | 239 |240 | FRAMES 241 | NO FRAMES 242 | 249 | 252 | 253 | 254 | | 255 |
258 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 259 |260 | DETAIL: FIELD | CONSTR | METHOD | 261 |
37 | 38 | | 39 ||
43 | PREV CLASS 44 | NEXT CLASS | 45 |46 | FRAMES 47 | NO FRAMES 48 | 55 | 58 | 59 | 60 | | 61 |
64 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 65 |66 | DETAIL: FIELD | CONSTR | METHOD | 67 |
77 | SFDCAccessControlResults 78 |80 |SFDCAccessControlResults.UpdateResults 79 |
public class SFDCAccessControlResults.UpdateResults
89 | This class provides results info and functionality for update operations. 90 |
91 | 92 |
93 |
102 | Constructor Summary | 103 ||
---|---|
SFDCAccessControlResults.UpdateResults(SObject[] objects,
106 | Database.SaveResult[] results)
107 |
108 | 109 | This constructor sets the objects that were actually used to update the db, and also sets the results from that update operation. |
110 |
119 | Method Summary | 120 ||
---|---|
123 | Database.SaveResult[] |
124 | getResults()
125 |
126 | 127 | Get the Database.SaveResult [] returned by the update operation. |
128 |
131 | SObject[] |
132 | getUpdatedObjects()
133 |
134 | 135 | Get the objects that were actually updated into the db. |
136 |
139 | Boolean |
140 | wasSuccessful()
141 |
142 | 143 | Did the update operation succeed for all objects in the array? |
144 |
155 | Constructor Detail | 156 |
---|
162 | public SFDCAccessControlResults.UpdateResults(SObject[] objects, 163 | Database.SaveResult[] results)164 |
167 |
175 | Method Detail | 176 |
---|
182 | public Database.SaveResult[] getResults()183 |
186 |
195 | public SObject[] getUpdatedObjects()196 |
202 |
211 | public Boolean wasSuccessful()212 |
217 |
231 | 232 | | 233 ||
237 | PREV CLASS 238 | NEXT CLASS | 239 |240 | FRAMES 241 | NO FRAMES 242 | 249 | 252 | 253 | 254 | | 255 |
258 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 259 |260 | DETAIL: FIELD | CONSTR | METHOD | 261 |
37 | 38 | | 39 ||
43 | PREV CLASS 44 | NEXT CLASS | 45 |46 | FRAMES 47 | NO FRAMES 48 | 55 | 58 | 59 | 60 | | 61 |
64 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 65 |66 | DETAIL: FIELD | CONSTR | METHOD | 67 |
public class SFDCAccessControlResults
82 | This class provides access control results functionality. 83 | This will help to encapsulate and provide more functionality in processing 84 | results from access control function calls such as insertAsUser and updateAsUser. 85 |
86 | 87 |
88 |
97 | Nested Class Summary | 98 ||
---|---|
101 | class |
102 | SFDCAccessControlResults.DeleteResults
103 |
104 | 105 | This class provides results info and functionality for delete operations. |
106 |
109 | class |
110 | SFDCAccessControlResults.InsertResults
111 |
112 | 113 | This class provides results info and functionality for insert operations. |
114 |
117 | class |
118 | SFDCAccessControlResults.UpdateResults
119 |
120 | 121 | This class provides results info and functionality for update operations. |
122 |
134 | 135 | | 136 ||
140 | PREV CLASS 141 | NEXT CLASS | 142 |143 | FRAMES 144 | NO FRAMES 145 | 152 | 155 | 156 | 157 | | 158 |
161 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 162 |163 | DETAIL: FIELD | CONSTR | METHOD | 164 |
37 | 38 | | 39 ||
43 | PREV CLASS 44 | NEXT CLASS | 45 |46 | FRAMES 47 | NO FRAMES 48 | 55 | 58 | 59 | 60 | | 61 |
64 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 65 |66 | DETAIL: FIELD | CONSTR | METHOD | 67 |
77 | Exception 78 |80 |SFDCAccessController.AccessControlDmlException 79 |
public class SFDCAccessController.AccessControlDmlException
89 |
99 | Constructor Summary | 100 ||
---|---|
SFDCAccessController.AccessControlDmlException()
103 |
104 | 105 | |
106 |
115 | Method Summary | 116 |
---|
127 | Constructor Detail | 128 |
---|
134 | public SFDCAccessController.AccessControlDmlException()135 |
147 | 148 | | 149 ||
153 | PREV CLASS 154 | NEXT CLASS | 155 |156 | FRAMES 157 | NO FRAMES 158 | 165 | 168 | 169 | 170 | | 171 |
174 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 175 |176 | DETAIL: FIELD | CONSTR | METHOD | 177 |
37 | 38 | | 39 ||
43 | PREV CLASS 44 | NEXT CLASS | 45 |46 | FRAMES 47 | NO FRAMES 48 | 55 | 58 | 59 | 60 | | 61 |
64 | SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | 65 |66 | DETAIL: ENUM CONSTANTS | FIELD | METHOD | 67 |
public static enum SFDCAccessController.OperationMode
85 | OperationMode - this enum defines the DB operations mode to be used.
86 |
87 | You can set the operation mode in the constructor or later using the setOperatoinMode() method.
88 | If you use the default constructor, we will set it to ALL_OR_NONE.
89 |
90 | 91 |
92 |
101 | Enum Constant Summary | 102 ||
---|---|
ALL_OR_NONE
105 |
106 | 107 | Will make sure all required fields have the proper permissions before any operation takes place. |
108 | |
BEST_EFFORT
111 |
112 | 113 | Will only set fields that are allowed. |
114 |
125 | Enum Constant Detail | 126 |
---|
132 | public static final SFDCAccessController.OperationMode ALL_OR_NONE133 |
136 |
144 | public static final SFDCAccessController.OperationMode BEST_EFFORT145 |
148 |
162 | 163 | | 164 ||
168 | PREV CLASS 169 | NEXT CLASS | 170 |171 | FRAMES 172 | NO FRAMES 173 | 180 | 183 | 184 | 185 | | 186 |
189 | SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | 190 |191 | DETAIL: ENUM CONSTANTS | FIELD | METHOD | 192 |
37 | 38 | | 39 ||
43 | PREV CLASS 44 | NEXT CLASS | 45 |46 | FRAMES 47 | NO FRAMES 48 | 55 | 58 | 59 | 60 | | 61 |
64 | SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | 65 |66 | DETAIL: ENUM CONSTANTS | FIELD | METHOD | 67 |
public static enum SFDCAccessController.SharingMode
85 | SharingMode - this enum defines the sharing mode to be used.
86 |
87 | You can set the sharing mode in the constructor or later using the setSharingMode() method.
88 | If you use the default constructor, we will set it to WITH.
89 |
90 | 91 |
92 |
101 | Enum Constant Summary | 102 ||
---|---|
INHERIT
105 |
106 | 107 | Will use the class instance that just inherits from the class that calls this class. |
108 | |
WITH
111 |
112 | 113 | Will use the class instance that enforces "with sharing". |
114 | |
WITHOUT
117 |
118 | 119 | Will use the class instance that enforces "without sharing". |
120 |
129 | Enum Constant Detail | 130 |
---|
136 | public static final SFDCAccessController.SharingMode WITH137 |
140 |
148 | public static final SFDCAccessController.SharingMode WITHOUT149 |
152 |
160 | public static final SFDCAccessController.SharingMode INHERIT161 |
164 |
178 | 179 | | 180 ||
184 | PREV CLASS 185 | NEXT CLASS | 186 |187 | FRAMES 188 | NO FRAMES 189 | 196 | 199 | 200 | 201 | | 202 |
205 | SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | 206 |207 | DETAIL: ENUM CONSTANTS | FIELD | METHOD | 208 |
37 | 38 | | 39 ||
43 | PREV CLASS 44 | NEXT CLASS | 45 |46 | FRAMES 47 | NO FRAMES 48 | 55 | 58 | 59 | 60 | | 61 |
64 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 65 |66 | DETAIL: FIELD | CONSTR | METHOD | 67 |
public class SFDCEncoder
82 | This class is a basic encoder/escaper to help prevent some XSS attacks etc. 83 |
84 | 85 |
86 |
96 | Constructor Summary | 97 ||
---|---|
SFDCEncoder()
100 |
101 | 102 | |
103 |
112 | Method Summary | 113 ||
---|---|
116 | String |
117 | SFDC_HTMLENCODE(String input)
118 |
119 | 120 | Similar to the VisualForce HTMLENCODE function. |
121 |
124 | String |
125 | SFDC_JSENCODE(String input)
126 |
127 | 128 | Similar to the VisualForce JSENCODE function. |
129 |
132 | String |
133 | SFDC_JSINHTMLENCODE(String input)
134 |
135 | 136 | Similar to the VisualForce JSINHTMLENCODE function. |
137 |
140 | String |
141 | SFDC_URLENCODE(String input)
142 |
143 | 144 | Similar to the VisualForce URLENCODE function. |
145 |
148 | String |
149 | SFDC_URLENCODE(String input,
150 | String encoding)
151 |
152 | 153 | Similar to SFDC_URLENCODE (String input) but
154 | allows to set specific encoding type. |
155 |
166 | Constructor Detail | 167 |
---|
173 | public SFDCEncoder()174 |
183 | Method Detail | 184 |
---|
190 | public String SFDC_HTMLENCODE(String input)191 |
196 | //htmlstr is going to be sent to visualforce as html code 197 | htmlstr = '<div>' + ESAPI.encoder().SFDC_HTMLENCODE(unsafe_text) + '</div>'; 198 |199 |
200 |
209 | public String SFDC_JSENCODE(String input)210 |
215 | //htmlstr is going to be sent to visualforce as html code 216 | htmlstr = '<script> var str = "' + ESAPI.encoder().SFDC_JSENCODE(unsafe_text) + '";</script>'; 217 |218 |
219 |
228 | public String SFDC_JSINHTMLENCODE(String input)229 |
234 | //htmlstr is going to be sent to visualforce as html code 235 | htmlstr = '<div onclick=\'alert("' + ESAPI.encoder().SFDC_JSINHTMLENCODE(unsafe_text) + '");\'>some text</div>'; 236 |237 |
238 |
247 | public String SFDC_URLENCODE(String input)248 |
261 | //htmlstr is going to be sent to visualforce as html code 262 | htmlstr = '<img src=\'http://domain/' + ESAPI.encoder().SFDC_URLENCODE(unsafe_text) + '\' />'; 263 |264 |
265 |
274 | public String SFDC_URLENCODE(String input, 275 | String encoding)276 |
SFDC_URLENCODE
(String input) but
278 | allows to set specific encoding type. 282 | //htmlstr is going to be sent to visualforce as html code 283 | htmlstr = '<img src=\'http://domain/' + ESAPI.encoder().SFDC_URLENCODE(unsafe_text, 'ISO-8859-1') + '\' />'; 284 |285 |
286 |
300 | 301 | | 302 ||
306 | PREV CLASS 307 | NEXT CLASS | 308 |309 | FRAMES 310 | NO FRAMES 311 | 318 | 321 | 322 | 323 | | 324 |
327 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 328 |329 | DETAIL: FIELD | CONSTR | METHOD | 330 |
37 | 38 | | 39 ||
43 | PREV CLASS 44 | NEXT CLASS | 45 |46 | FRAMES 47 | NO FRAMES 48 | 55 | 58 | 59 | 60 | | 61 |
64 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 65 |66 | DETAIL: FIELD | CONSTR | METHOD | 67 |
public interface SFDCPlugins.SFDCIDescribeInfoCache
85 | This interface defines the methods for a describe info cache implementation. 86 |
87 | 88 |
89 |
99 | Method Summary | 100 ||
---|---|
103 | Map<String,Schema.SObjectType> |
104 | fieldMapFor(Schema.SObjectType objectType)
105 |
106 | 107 | Returns a field map for a given sobject type. |
108 |
119 | Method Detail | 120 |
---|
126 | Map<String,Schema.SObjectType> fieldMapFor(Schema.SObjectType objectType)127 |
130 |
objectType
- sobject type for ex. Contact.getSObjectType()144 | 145 | | 146 ||
150 | PREV CLASS 151 | NEXT CLASS | 152 |153 | FRAMES 154 | NO FRAMES 155 | 162 | 165 | 166 | 167 | | 168 |
171 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 172 |173 | DETAIL: FIELD | CONSTR | METHOD | 174 |
37 | 38 | | 39 ||
43 | PREV CLASS 44 | NEXT CLASS | 45 |46 | FRAMES 47 | NO FRAMES 48 | 55 | 58 | 59 | 60 | | 61 |
64 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 65 |66 | DETAIL: FIELD | CONSTR | METHOD | 67 |
public class SFDCPlugins
82 | This class contains plugins for use in the ESAPI. 83 | The DescribeInfoCache plugin provides caching functionality for describe info. 84 |
85 | 86 |
87 |
96 | Nested Class Summary | 97 ||
---|---|
100 | public interface |
101 | SFDCPlugins.SFDCIDescribeInfoCache
102 |
103 | 104 | This interface defines the methods for a describe info cache implementation. |
105 |
114 | Constructor Summary | 115 ||
---|---|
SFDCPlugins()
118 |
119 | 120 | |
121 |
130 | Method Summary | 131 ||
---|---|
134 | static void |
135 | registerDescribeInfoCache(SFDCPlugins.SFDCIDescribeInfoCache impl)
136 |
137 | 138 | Register your own function to handle the describe cache. |
139 |
150 | Constructor Detail | 151 |
---|
157 | public SFDCPlugins()158 |
167 | Method Detail | 168 |
---|
174 | public static void registerDescribeInfoCache(SFDCPlugins.SFDCIDescribeInfoCache impl)175 |
178 |
impl
- an object of your SFDCIDescribeInfoCache implementation192 | 193 | | 194 ||
198 | PREV CLASS 199 | NEXT CLASS | 200 |201 | FRAMES 202 | NO FRAMES 203 | 210 | 213 | 214 | 215 | | 216 |
219 | SUMMARY: NESTED | FIELD | CONSTR | METHOD | 220 |221 | DETAIL: FIELD | CONSTR | METHOD | 222 |
ESAPI
25 | 26 | SFDCAccessControlException 27 | 28 | SFDCAccessControlException.ExceptionReason 29 | 30 | SFDCAccessControlException.ExceptionType 31 | 32 | SFDCAccessController 33 | 34 | SFDCAccessController.OperationMode 35 | 36 | SFDCAccessController.SharingMode 37 | 38 | SFDCAccessControlResults 39 | 40 | SFDCAccessControlResults.DeleteResults 41 | 42 | SFDCAccessControlResults.InsertResults 43 | 44 | SFDCAccessControlResults.UpdateResults 45 | 46 | SFDCEncoder 47 | 48 | SFDCPatterns 49 | 50 | SFDCPlugins 51 | 52 | SFDCPlugins.SFDCIDescribeInfoCache 53 | 54 | SFDCValidator 55 | 56 | |
57 |
ESAPI
25 | 26 | SFDCAccessControlException 27 | 28 | SFDCAccessControlException.ExceptionReason 29 | 30 | SFDCAccessControlException.ExceptionType 31 | 32 | SFDCAccessController 33 | 34 | SFDCAccessController.OperationMode 35 | 36 | SFDCAccessController.SharingMode 37 | 38 | SFDCAccessControlResults 39 | 40 | SFDCAccessControlResults.DeleteResults 41 | 42 | SFDCAccessControlResults.InsertResults 43 | 44 | SFDCAccessControlResults.UpdateResults 45 | 46 | SFDCEncoder 47 | 48 | SFDCPatterns 49 | 50 | SFDCPlugins 51 | 52 | SFDCPlugins.SFDCIDescribeInfoCache 53 | 54 | SFDCValidator 55 | 56 | |
57 |
ESAPI.validator().isValidCreditCard(creditcard, false)
)
20 | */
21 | global with sharing class ESAPI {
22 |
23 | private static SFDCValidator SFDC_validator = null;
24 | private static SFDCEncoder SFDC_encoder = null;
25 | private static SFDCAccessController SFDC_accessController = null;
26 |
27 | /**
28 | * prevent instantiation of this class
29 | */
30 | private ESAPI() {
31 | }
32 |
33 | /**
34 | * @return the current ESAPI SFDCValidator being used to validate data in this application.
35 | */
36 | global static SFDCValidator validator() {
37 | if (SFDC_validator == null) {
38 | SFDC_validator = new SFDCValidator();
39 | }
40 | return SFDC_validator;
41 | }
42 |
43 | /**
44 | * @return the current SFDCEncoder object. This gives the basic encoding functionality as those availabel in VisualForce (HTMLENCODE, JSENCODE, JSINHTMLENCODE and URLENCODE)
45 | */
46 | global static SFDCEncoder encoder() {
47 | if (SFDC_encoder == null) {
48 | SFDC_encoder = new SFDCEncoder();
49 | }
50 | return SFDC_encoder;
51 | }
52 |
53 | /**
54 | * @return the current ESAPI SFDCAccessController object being used to maintain the access control rules for this application.
55 | */
56 | global static SFDCAccessController accessController() {
57 | if (SFDC_accessController == null) {
58 | SFDC_accessController = new SFDCAccessController();
59 | }
60 | return SFDC_accessController;
61 | }
62 | }
--------------------------------------------------------------------------------
/force-app/main/default/classes/ESAPI.cls-meta.xml:
--------------------------------------------------------------------------------
1 |
2 | 42 | * //htmlstr is going to be sent to visualforce as html code 43 | * htmlstr = '<div>' + ESAPI.encoder().SFDC_HTMLENCODE(unsafe_text) + '</div>'; 44 | *45 | */ 46 | global String SFDC_HTMLENCODE(String input) { 47 | return ENCODE(input, HTML_DECODED, HTML_ENCODED); 48 | } 49 | 50 | /** 51 | * Similar to the VisualForce JSENCODE function.
55 | * //htmlstr is going to be sent to visualforce as html code 56 | * htmlstr = '<script> var str = "' + ESAPI.encoder().SFDC_JSENCODE(unsafe_text) + '";</script>'; 57 | *58 | */ 59 | global String SFDC_JSENCODE(String input) { 60 | return ENCODE(input, JS_DECODED, JS_ENCODED); 61 | } 62 | 63 | /** 64 | * Similar to the VisualForce JSINHTMLENCODE function.
68 | * //htmlstr is going to be sent to visualforce as html code 69 | * htmlstr = '<div onclick=\'alert("' + ESAPI.encoder().SFDC_JSINHTMLENCODE(unsafe_text) + '");\'>some text</div>'; 70 | *71 | */ 72 | global String SFDC_JSINHTMLENCODE(String input) { 73 | return ENCODE(input, JSINHTML_DECODED, JSINHTML_ENCODED); 74 | } 75 | 76 | /** 77 | * Similar to the VisualForce URLENCODE function.
89 | * //htmlstr is going to be sent to visualforce as html code 90 | * htmlstr = '<img src=\'http://domain/' + ESAPI.encoder().SFDC_URLENCODE(unsafe_text) + '\' />'; 91 | *92 | */ 93 | global String SFDC_URLENCODE(String input) { 94 | return EncodingUtil.urlEncode(input, 'UTF-8'); 95 | } 96 | 97 | /** 98 | * Similar to {@link #SFDC_URLENCODE(String) SFDC_URLENCODE}(String input) but 99 | * allows to set specific encoding type.
103 | * //htmlstr is going to be sent to visualforce as html code 104 | * htmlstr = '<img src=\'http://domain/' + ESAPI.encoder().SFDC_URLENCODE(unsafe_text, 'ISO-8859-1') + '\' />'; 105 | *106 | * 107 | */ 108 | global String SFDC_URLENCODE(String input, String encoding) { 109 | return EncodingUtil.urlEncode(input, encoding); 110 | } 111 | 112 | /** 113 | * Note : This function always encodes into UTF-8 URL encoding
121 | * //htmlstr is going to be sent to visualforce as html code 122 | * htmlstr = '<img src="data:image/gif;base64,"" + ESAPI.encoder().SFDC_BASE64_URLENCODE(unsafe_text) + '"\' />'; 123 | *124 | */ 125 | global String SFDC_BASE64_URLENCODE(final Blob input){ 126 | if(input == null) { 127 | return null; 128 | } 129 | return EncodingUtil.base64Encode(input) 130 | .replace('/', '_') 131 | .replace('+', '-') 132 | .replaceAll('=+$', ''); 133 | } 134 | 135 | private String ENCODE(String input, String[] fromArr, String[] toArr) { 136 | if (input == null || input.length() == 0) 137 | return input; 138 | 139 | for (Integer i = 0; i < fromArr.size(); ++i) { 140 | input = input.replace(fromArr[i], toArr[i]); 141 | } 142 | 143 | return input; 144 | } 145 | } -------------------------------------------------------------------------------- /force-app/main/default/classes/SFDCEncoder.cls-meta.xml: -------------------------------------------------------------------------------- 1 | 2 |