0
# Security & Validation
1
2
Permission system, access control, data validation framework, and security policy enforcement.
3
4
## Capabilities
5
6
### Permission System
7
8
```java { .api }
9
interface DDMPermissionSupport {
10
String getResourceName(String className);
11
boolean contains(PermissionChecker permissionChecker, String name,
12
long primaryKey, String actionId) throws PortalException;
13
}
14
15
interface DDMStructurePermission {
16
static void check(PermissionChecker permissionChecker, DDMStructure structure, String actionId)
17
throws PortalException;
18
static boolean contains(PermissionChecker permissionChecker, DDMStructure structure, String actionId);
19
}
20
21
interface DDMTemplatePermission {
22
static void check(PermissionChecker permissionChecker, DDMTemplate template, String actionId)
23
throws PortalException;
24
static boolean contains(PermissionChecker permissionChecker, DDMTemplate template, String actionId);
25
}
26
```
27
28
### Validation Framework
29
30
```java { .api }
31
interface DDMValidator {
32
void validate(DDMValidatorValidateRequest ddmValidatorValidateRequest)
33
throws DDMValidatorException;
34
}
35
36
class DDMValidatorValidateRequest {
37
DDMFormValues getDDMFormValues();
38
Locale getLocale();
39
ServiceContext getServiceContext();
40
}
41
42
class DDMValidatorException extends PortalException {
43
DDMValidatorException(String msg);
44
Map<String, List<String>> getErrors();
45
}
46
```
47
48
## Usage Examples
49
50
### Permission Checking
51
52
```java
53
@Component
54
public class SecurityExample {
55
56
public void checkPermissions(PermissionChecker permissionChecker,
57
DDMStructure structure) throws PortalException {
58
59
// Check if user can view the structure
60
DDMStructurePermission.check(permissionChecker, structure, ActionKeys.VIEW);
61
62
// Check if user can update the structure
63
if (DDMStructurePermission.contains(permissionChecker, structure, ActionKeys.UPDATE)) {
64
// User has update permission
65
System.out.println("User can update structure");
66
}
67
}
68
}
69
```