forked from kidgrow-microservices-platform

zhaoxiaohao
2020-10-30 2e109492d152e08bfca445b54f15c91a2334f21c
kidgrow-commons/kidgrow-authclient-spring-boot-starter/src/main/java/com/kidgrow/authclient/util/AuthUtils.java
@@ -2,14 +2,13 @@
import com.kidgrow.common.constant.CommonConstant;
import com.kidgrow.common.model.SysUser;
import com.kidgrow.common.utils.AesUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.exceptions.UnapprovedClientAuthenticationException;
import javax.servlet.http.HttpServletRequest;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Enumeration;
/**
@@ -82,9 +81,12 @@
     * @param header header中的参数
     */
    public static String[] extractHeaderClient(String header) {
        byte[] base64Client = header.substring(BASIC_.length()).getBytes(StandardCharsets.UTF_8);
        byte[] decoded = Base64.getDecoder().decode(base64Client);
        String clientStr = new String(decoded, StandardCharsets.UTF_8);
        String clientStr = null;
        try{
            clientStr =  AesUtils.desEncrypt(header.substring(BASIC_.length()));
        }catch(Exception w){
            log.error("Header解密失败", w);
        }
        String[] clientArr = clientStr.split(":");
        if (clientArr.length != 2) {
            throw new RuntimeException("Invalid basic authentication token");