@Test public void testParseAuthHeader() throws Throwable { assertEquals(S3V4Authentication.getV4AuthComponents("AWS").size(), 0); Map<V4AuthComponent, String> auth = S3V4Authentication.getV4AuthComponents(V4_HEADER); assert auth.get(V4AuthComponent.Credential).equals("AKIAIOSFODNN7EXAMPLE/20130524/us-east-1/s3/aws4_request"); assert auth.get(V4AuthComponent.SignedHeaders).equals("host;range;x-amz-date"); assert auth.get(V4AuthComponent.Signature).equals("fe5f80f77d5fa3beca038a248ff027d0445342fe2855ddc963176630326f1024"); }
static Map<V4AuthComponent, String> getV4AuthComponents(String authHeader) { authHeader = authHeader.replaceFirst(AWS_V4_AUTH_TYPE, "").trim(); Iterable<String> authParts = CSV_SPLITTER.split(authHeader); Map<V4AuthComponent, String> authParams = new HashMap<>(); for (String nvp : authParts) { Iterable<String> nameAndValue = NVP_SPLITTER.split(nvp); try { V4AuthComponent name = V4AuthComponent.valueOf(Iterables.get(nameAndValue, 0, "")); String value = Iterables.get(nameAndValue, 1, ""); if (value != null && !value.isEmpty()) authParams.put(name, value); } catch (IllegalArgumentException ignore) { } } return authParams; }
S3V4Authentication { static Map<V4AuthComponent, String> getV4AuthComponents(String authHeader) { authHeader = authHeader.replaceFirst(AWS_V4_AUTH_TYPE, "").trim(); Iterable<String> authParts = CSV_SPLITTER.split(authHeader); Map<V4AuthComponent, String> authParams = new HashMap<>(); for (String nvp : authParts) { Iterable<String> nameAndValue = NVP_SPLITTER.split(nvp); try { V4AuthComponent name = V4AuthComponent.valueOf(Iterables.get(nameAndValue, 0, "")); String value = Iterables.get(nameAndValue, 1, ""); if (value != null && !value.isEmpty()) authParams.put(name, value); } catch (IllegalArgumentException ignore) { } } return authParams; } }
S3V4Authentication { static Map<V4AuthComponent, String> getV4AuthComponents(String authHeader) { authHeader = authHeader.replaceFirst(AWS_V4_AUTH_TYPE, "").trim(); Iterable<String> authParts = CSV_SPLITTER.split(authHeader); Map<V4AuthComponent, String> authParams = new HashMap<>(); for (String nvp : authParts) { Iterable<String> nameAndValue = NVP_SPLITTER.split(nvp); try { V4AuthComponent name = V4AuthComponent.valueOf(Iterables.get(nameAndValue, 0, "")); String value = Iterables.get(nameAndValue, 1, ""); if (value != null && !value.isEmpty()) authParams.put(name, value); } catch (IllegalArgumentException ignore) { } } return authParams; } private  S3V4Authentication(); }
S3V4Authentication { static Map<V4AuthComponent, String> getV4AuthComponents(String authHeader) { authHeader = authHeader.replaceFirst(AWS_V4_AUTH_TYPE, "").trim(); Iterable<String> authParts = CSV_SPLITTER.split(authHeader); Map<V4AuthComponent, String> authParams = new HashMap<>(); for (String nvp : authParts) { Iterable<String> nameAndValue = NVP_SPLITTER.split(nvp); try { V4AuthComponent name = V4AuthComponent.valueOf(Iterables.get(nameAndValue, 0, "")); String value = Iterables.get(nameAndValue, 1, ""); if (value != null && !value.isEmpty()) authParams.put(name, value); } catch (IllegalArgumentException ignore) { } } return authParams; } private  S3V4Authentication();  }
S3V4Authentication { static Map<V4AuthComponent, String> getV4AuthComponents(String authHeader) { authHeader = authHeader.replaceFirst(AWS_V4_AUTH_TYPE, "").trim(); Iterable<String> authParts = CSV_SPLITTER.split(authHeader); Map<V4AuthComponent, String> authParams = new HashMap<>(); for (String nvp : authParts) { Iterable<String> nameAndValue = NVP_SPLITTER.split(nvp); try { V4AuthComponent name = V4AuthComponent.valueOf(Iterables.get(nameAndValue, 0, "")); String value = Iterables.get(nameAndValue, 1, ""); if (value != null && !value.isEmpty()) authParams.put(name, value); } catch (IllegalArgumentException ignore) { } } return authParams; } private  S3V4Authentication();  static final String AWS_V4_AUTH_TYPE; static final String AWS_CONTENT_SHA_HEADER; static final String AWS_EXPIRES_PARAM; static final String AWS_DECODED_CONTENT_LEN; static final String STREAMING_PAYLOAD; static final String UNSIGNED_PAYLOAD; }