-
Notifications
You must be signed in to change notification settings - Fork 188
/
AuthenticationEvaluatorUtil.java
70 lines (62 loc) · 2.65 KB
/
AuthenticationEvaluatorUtil.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Copyright (c) 2010-2019 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.model.api.util;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import java.util.List;
/**
* @author skublik
*/
public class AuthenticationEvaluatorUtil {
public static boolean checkRequiredAssignment(List<AssignmentType> assignments, List<ObjectReferenceType> requireAssignments) {
if (requireAssignments == null || requireAssignments.isEmpty()){
return true;
}
if (assignments == null || assignments.isEmpty()) {
return false;
}
for (ObjectReferenceType requiredAssignment : requireAssignments) {
if (requiredAssignment == null) {
throw new IllegalStateException("Required assignment is null");
}
if (requiredAssignment.getOid() == null){
throw new IllegalStateException("Oid of required assignment is null");
}
boolean match = false;
for (AssignmentType assignment : assignments) {
ObjectReferenceType targetRef = assignment.getTargetRef();
if (targetRef != null) {
if (targetRef.getOid() != null && targetRef.getOid().equals(requiredAssignment.getOid())) {
match = true;
break;
}
} else if (assignment.getConstruction() != null && requiredAssignment.getType() != null
&& QNameUtil.match(requiredAssignment.getType(), ResourceType.COMPLEX_TYPE)) {
if (assignment.getConstruction().getResourceRef() != null &&
assignment.getConstruction().getResourceRef().getOid() != null &&
assignment.getConstruction().getResourceRef().getOid().equals(requiredAssignment.getOid())) {
match = true;
break;
}
}
}
if (!match) {
return false;
}
}
return true;
}
public static AuthenticationBehavioralDataType getBehavior(FocusType focus) {
if (focus.getBehavior() == null){
focus.setBehavior(new BehaviorType());
}
if (focus.getBehavior().getAuthentication() == null){
focus.getBehavior().setAuthentication(new AuthenticationBehavioralDataType());
}
return focus.getBehavior().getAuthentication();
}
}