Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implementing of recording authentication behavior to focus for all mo…
…dules
- Loading branch information
Showing
9 changed files
with
862 additions
and
657 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...l-api/src/main/java/com/evolveum/midpoint/model/api/util/AuthenticationEvaluatorUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.