package com.cm.common.service.impl;

import com.cm.common.config.properties.AccessControl;
import com.cm.common.service.IRbacService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName: RbacServiceImpl
 * @Description: 权限校验
 * @Author: WangGeng
 * @Date: 2019-05-30 15:16
 * @Version: 1.0
 **/
@Component("rbacService")
public class RbacServiceImpl implements IRbacService {

    @Override
    public boolean hasPermission(HttpServletRequest request, Authentication authentication) {
        Object object = authentication.getPrincipal();
        if (object == null || "anonymousUser".equals(object.toString())) {
            return false;
        }
        return true;
    }

}
