| | |
| | | |
| | | 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; |
| | | |
| | | /** |
| | |
| | | * @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"); |