/*
 * Copyright (c) 2012 Evolveum
 *
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the License). You may not use this file except in
 * compliance with the License.
 *
 * You can obtain a copy of the License at
 * http://www.opensource.org/licenses/cddl1 or
 * CDDLv1.0.txt file in the source code distribution.
 * See the License for the specific language governing
 * permission and limitations under the License.
 *
 * If applicable, add the following below the CDDL Header,
 * with the fields enclosed by brackets [] replaced by
 * your own identifying information:
 *
 * Portions Copyrighted 2012 [name of copyright owner]
 */

package com.evolveum.midpoint.web.security;

import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @author lazyman
 */
public class SecurityUtils {

    private static final Trace LOGGER = TraceManager.getTrace(SecurityUtils.class);

    public static com.evolveum.midpoint.model.security.api.PrincipalUser getPrincipalUser() {
        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        if (principal != null || !(principal instanceof com.evolveum.midpoint.model.security.api.PrincipalUser)) {
            LOGGER.warn("Principal user in security context holder is {} but not type of {}",
                    new Object[]{principal, com.evolveum.midpoint.model.security.api.PrincipalUser.class.getName()});
            return null;
        }

        return (com.evolveum.midpoint.model.security.api.PrincipalUser) principal;
    }
}

@@ -1265,29 +1265,8 @@
 if (
-principal != null %7C%7C 
 !(pr

fix in security utils (mainly task owners were set to null)