@Test public void extractCrnFromAuthHeader() { String result = CrnHelper.extractCrnFromAuthHeader("eyJhY2Nlc3Nfa2V5X2lkIjoiWTNKdU9tTmtjRHBwWVcwNmRYTXRkMlZ6ZEMweE9tTnNi" + "M1ZrWlhKaE9uVnpaWEk2ZFhObGNnPT0iLCJhdXRoX21ldGhvZCI6ImVkMjU1MTl2MSJ9.SIGNATURE_NOT_HANDLED"); Assert.assertEquals("crn:cdp:iam:us-west-1:cloudera:user:user", result); }
public static String extractCrnFromAuthHeader(String authHeader) { String authFirstPart = authHeader.substring(0, authHeader.indexOf(".")); byte[] authMetaJson = Base64.getUrlDecoder().decode(authFirstPart); String resultCrn = ""; ObjectMapper om = new ObjectMapper(); try { JsonNode root = om.readTree(authMetaJson); resultCrn = root.get("access_key_id").asText(); } catch (IOException e) { throw new RuntimeException("authentication failure"); } return new String(Base64.getUrlDecoder().decode(resultCrn)); }
CrnHelper { public static String extractCrnFromAuthHeader(String authHeader) { String authFirstPart = authHeader.substring(0, authHeader.indexOf(".")); byte[] authMetaJson = Base64.getUrlDecoder().decode(authFirstPart); String resultCrn = ""; ObjectMapper om = new ObjectMapper(); try { JsonNode root = om.readTree(authMetaJson); resultCrn = root.get("access_key_id").asText(); } catch (IOException e) { throw new RuntimeException("authentication failure"); } return new String(Base64.getUrlDecoder().decode(resultCrn)); } }
CrnHelper { public static String extractCrnFromAuthHeader(String authHeader) { String authFirstPart = authHeader.substring(0, authHeader.indexOf(".")); byte[] authMetaJson = Base64.getUrlDecoder().decode(authFirstPart); String resultCrn = ""; ObjectMapper om = new ObjectMapper(); try { JsonNode root = om.readTree(authMetaJson); resultCrn = root.get("access_key_id").asText(); } catch (IOException e) { throw new RuntimeException("authentication failure"); } return new String(Base64.getUrlDecoder().decode(resultCrn)); } private  CrnHelper(); }
CrnHelper { public static String extractCrnFromAuthHeader(String authHeader) { String authFirstPart = authHeader.substring(0, authHeader.indexOf(".")); byte[] authMetaJson = Base64.getUrlDecoder().decode(authFirstPart); String resultCrn = ""; ObjectMapper om = new ObjectMapper(); try { JsonNode root = om.readTree(authMetaJson); resultCrn = root.get("access_key_id").asText(); } catch (IOException e) { throw new RuntimeException("authentication failure"); } return new String(Base64.getUrlDecoder().decode(resultCrn)); } private  CrnHelper(); static String extractCrnFromAuthHeader(String authHeader); static String generateCrn(String tenant, String user); static AltusKey generateAltusApiKey(String tenant, String user); }
CrnHelper { public static String extractCrnFromAuthHeader(String authHeader) { String authFirstPart = authHeader.substring(0, authHeader.indexOf(".")); byte[] authMetaJson = Base64.getUrlDecoder().decode(authFirstPart); String resultCrn = ""; ObjectMapper om = new ObjectMapper(); try { JsonNode root = om.readTree(authMetaJson); resultCrn = root.get("access_key_id").asText(); } catch (IOException e) { throw new RuntimeException("authentication failure"); } return new String(Base64.getUrlDecoder().decode(resultCrn)); } private  CrnHelper(); static String extractCrnFromAuthHeader(String authHeader); static String generateCrn(String tenant, String user); static AltusKey generateAltusApiKey(String tenant, String user);  }