Total Complexity | 3 |
Total Lines | 15 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | package unicon.matthews.security.auth.jwt.extractor; |
||
15 | @Component |
||
16 | public class JwtHeaderTokenExtractor implements TokenExtractor { |
||
17 | public static String HEADER_PREFIX = "Bearer "; |
||
18 | |||
19 | @Override |
||
20 | public String extract(String header) { |
||
21 | if (StringUtils.isBlank(header)) { |
||
22 | throw new AuthenticationServiceException("Authorization header cannot be blank!"); |
||
23 | } |
||
24 | |||
25 | if (header.length() < HEADER_PREFIX.length()) { |
||
26 | throw new AuthenticationServiceException("Invalid authorization header size."); |
||
27 | } |
||
28 | |||
29 | return header.substring(HEADER_PREFIX.length(), header.length()); |
||
30 | } |
||
32 |
See this CWE advisory on why this is a security issue.