BearerNoneTokenInfoResourceServerTokenServices extends TokenInfoResourceServerTokenServices { @Override public OAuth2Authentication loadAuthentication(final String accessToken) throws AuthenticationException, InvalidTokenException { if (!StringUtils.hasText(accessToken)) { throw new InvalidTokenException("AccessToken should not be 'null', 'empty' or 'whitespace'"); } if (NONE.equalsIgnoreCase(accessToken)) { throw new InvalidTokenException("AccessToken should not be 'None'"); } if (accessToken.length() < 30) { throw new InvalidTokenException("AccessToken should have a length of 30 at least "); } return super.loadAuthentication(accessToken); } BearerNoneTokenInfoResourceServerTokenServices(final String tokenInfoEndpointUrl); @Override OAuth2Authentication loadAuthentication(final String accessToken);  }
@Test(expected = InvalidTokenException.class) public void noneAccessToken() { tir.loadAuthentication("None"); }
@Test(expected = InvalidTokenException.class) public void noneIgnoreCaseAccessTokenAllUppercase() { tir.loadAuthentication("NONE"); }
@Test(expected = InvalidTokenException.class) public void noneIgnoreCaseAccessTokenAllLowercase() { tir.loadAuthentication("none"); }
@Test(expected = InvalidTokenException.class) public void less_than_30_AccessToken() { tir.loadAuthentication("12345678909876543211234567898"); }
@Test(expected = InvalidTokenException.class) public void nullAccessToken() { tir.loadAuthentication(null); }
@Test(expected = InvalidTokenException.class) public void emptyAccessToken() { tir.loadAuthentication(""); }
@Test(expected = InvalidTokenException.class) public void whitspaceAccessToken() { tir.loadAuthentication(" "); }