### Question:
AuthenticationHeaderDecoder { public String decodeApiKey(String authenticationHeader) throws AuthenticationException { if (authenticationHeader == null || authenticationHeader.toUpperCase().indexOf(UPPERCASE_APIKEY_PREFIX) != 0) { throw new BadCredentialsException("Invalid X-Road-Apikey authorization header"); } String apiKey = authenticationHeader.substring(UPPERCASE_APIKEY_PREFIX.length()); if (StringUtils.isBlank(apiKey)) { throw new BadCredentialsException("Missing api key from authorization header"); } return apiKey.trim(); }  String decodeApiKey(String authenticationHeader);  }### Answer:
@Test public void decode() throws Exception { AuthenticationHeaderDecoder decoder = new AuthenticationHeaderDecoder(); String encoded = "X-Road-ApiKEy toKen=123"; assertEquals("123", decoder.decodeApiKey(encoded)); encoded = "X-Road-ApiKEy toKen= 123 \n "; assertEquals("123", decoder.decodeApiKey(encoded)); String badEncoded = "Bearer 123"; try { decoder.decodeApiKey(badEncoded); fail("should have thrown exception"); } catch (AuthenticationException expected) { } badEncoded = "X-Road-ApiKEy token= "; try { decoder.decodeApiKey(badEncoded); fail("should have thrown exception"); } catch (AuthenticationException expected) { } badEncoded = "dsadsadasdasadsX-Road-ApiKEy token=123"; try { decoder.decodeApiKey(badEncoded); fail("should have thrown exception"); } catch (AuthenticationException expected) { } }