package com.tofly.common.oauth.auth;

import com.tofly.common.core.constant.SecurityConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientRegistrationException;
import org.springframework.security.oauth2.provider.client.JdbcClientDetailsService;

import javax.sql.DataSource;

/**
 * @author Administrator
 * 扩展类，暂未使用，开放OPENAPI时，校验权限，客户端
 * @date 2019/9/9  9:32
 */
@Slf4j
public class ToFlyClientDetailsService extends JdbcClientDetailsService{

    public ToFlyClientDetailsService(DataSource dataSource){
        super(dataSource);
    }

    @Override
    @Cacheable(value = SecurityConstants.CLIENT_DETAILS_KEY,key = "#clientId",unless ="#result==null")
    public ClientDetails loadClientByClientId(String clientId) throws ClientRegistrationException {
        return super.loadClientByClientId(clientId);
    }
}
