Skip to content

Commit

Permalink
ModelRestController.java: fix for principal returning Focus, not User
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Apr 9, 2020
1 parent 0588378 commit 0c02eb5
Showing 1 changed file with 5 additions and 3 deletions.
Expand Up @@ -24,6 +24,7 @@
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

@RestController
Expand All @@ -44,15 +45,15 @@ public class ModelRestController {
RestServiceUtil.APPLICATION_YAML
})
public ResponseEntity<?> getSelf(HttpServletRequest request) {
//@Context MessageContext mc){ TODO: do we need it in init request in new erea?
//@Context MessageContext mc){ TODO: do we need it in init request in new era?
LOGGER.debug("model rest service for get operation start");
// uses experimental version, does not require CXF/JAX-RS
Task task = RestServiceUtil.initRequest(taskManager);
OperationResult parentResult = task.getResult().createSubresult(OPERATION_SELF);
ResponseEntity<?> response;

try {
UserType loggedInUser = SecurityUtil.getPrincipal().getUser();
FocusType loggedInUser = SecurityUtil.getPrincipal().getFocus();
System.out.println("loggedInUser = " + loggedInUser);
PrismObject<UserType> user = model.getObject(UserType.class, loggedInUser.getOid(), null, task, parentResult);
response = createResponse(HttpStatus.OK, user, parentResult, true);
Expand All @@ -67,7 +68,8 @@ public ResponseEntity<?> getSelf(HttpServletRequest request) {
return response;
}

public static <T> ResponseEntity<?> createResponse(HttpStatus statusCode, T body, OperationResult result, boolean sendOriginObjectIfNotSuccess) {
public static <T> ResponseEntity<?> createResponse(
HttpStatus statusCode, T body, OperationResult result, boolean sendOriginObjectIfNotSuccess) {
result.computeStatusIfUnknown();

// if (result.isPartialError()) {
Expand Down

0 comments on commit 0c02eb5

Please sign in to comment.