All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openl.rules.webstudio.security.CurrentUserInfo Maven / Gradle / Ivy

There is a newer version: 5.27.9
Show newest version
package org.openl.rules.webstudio.security;

import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * Register this bean as managed bean with application scope to get possibility to access user's info in JSF EL.
 *
 * @author Andrey Naumenko
 */
public class CurrentUserInfo {
    /**
     * Currently logged in user.
     */
    public String getUserName() {
        SecurityContext ctx = SecurityContextHolder.getContext();
        if (ctx == null || ctx.getAuthentication() == null) {
            return null;
        }

        return ctx.getAuthentication().getName();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy