@Test void testWithoutArnQualifier() { assertThatThrownBy(() -> fromString("foo:aws:iam::123456789012:David")) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("must have an arn qualifier at the beginning"); }
public static AmazonResourceName fromString(String name) { Assert.notNull(name, "name must not be null"); String[] tokens = name.split(RESOURCE_NAME_DELIMITER); if (tokens.length < 6 || tokens.length > 7) { throw new IllegalArgumentException( "Resource name:'" + name + "' is not a valid resource identifier"); } if (!"arn".equals(tokens[0])) { throw new IllegalArgumentException("Resource name:'" + name + "' must have an arn qualifier at the beginning"); } if (!("aws".equals(tokens[1]) || tokens[1].startsWith("aws-"))) { throw new IllegalArgumentException( "Resource name:'" + name + "' must have a valid partition name"); } String actualResourceTypeDelimiter; if (tokens.length == 6) { tokens = Arrays.copyOf(tokens, 7); String[] split = StringUtils.split(tokens[5], RESOURCE_TYPE_DELIMITER); if (split != null) { tokens[5] = split[0]; tokens[6] = split[1]; } actualResourceTypeDelimiter = RESOURCE_TYPE_DELIMITER; } else { actualResourceTypeDelimiter = RESOURCE_NAME_DELIMITER; } return new AmazonResourceName(tokens[1], tokens[2], trimToNull(tokens[3]), trimToNull(tokens[4]), trimToNull(tokens[5]), trimToNull(tokens[6]), actualResourceTypeDelimiter); }
AmazonResourceName { public static AmazonResourceName fromString(String name) { Assert.notNull(name, "name must not be null"); String[] tokens = name.split(RESOURCE_NAME_DELIMITER); if (tokens.length < 6 || tokens.length > 7) { throw new IllegalArgumentException( "Resource name:'" + name + "' is not a valid resource identifier"); } if (!"arn".equals(tokens[0])) { throw new IllegalArgumentException("Resource name:'" + name + "' must have an arn qualifier at the beginning"); } if (!("aws".equals(tokens[1]) || tokens[1].startsWith("aws-"))) { throw new IllegalArgumentException( "Resource name:'" + name + "' must have a valid partition name"); } String actualResourceTypeDelimiter; if (tokens.length == 6) { tokens = Arrays.copyOf(tokens, 7); String[] split = StringUtils.split(tokens[5], RESOURCE_TYPE_DELIMITER); if (split != null) { tokens[5] = split[0]; tokens[6] = split[1]; } actualResourceTypeDelimiter = RESOURCE_TYPE_DELIMITER; } else { actualResourceTypeDelimiter = RESOURCE_NAME_DELIMITER; } return new AmazonResourceName(tokens[1], tokens[2], trimToNull(tokens[3]), trimToNull(tokens[4]), trimToNull(tokens[5]), trimToNull(tokens[6]), actualResourceTypeDelimiter); } }
AmazonResourceName { public static AmazonResourceName fromString(String name) { Assert.notNull(name, "name must not be null"); String[] tokens = name.split(RESOURCE_NAME_DELIMITER); if (tokens.length < 6 || tokens.length > 7) { throw new IllegalArgumentException( "Resource name:'" + name + "' is not a valid resource identifier"); } if (!"arn".equals(tokens[0])) { throw new IllegalArgumentException("Resource name:'" + name + "' must have an arn qualifier at the beginning"); } if (!("aws".equals(tokens[1]) || tokens[1].startsWith("aws-"))) { throw new IllegalArgumentException( "Resource name:'" + name + "' must have a valid partition name"); } String actualResourceTypeDelimiter; if (tokens.length == 6) { tokens = Arrays.copyOf(tokens, 7); String[] split = StringUtils.split(tokens[5], RESOURCE_TYPE_DELIMITER); if (split != null) { tokens[5] = split[0]; tokens[6] = split[1]; } actualResourceTypeDelimiter = RESOURCE_TYPE_DELIMITER; } else { actualResourceTypeDelimiter = RESOURCE_NAME_DELIMITER; } return new AmazonResourceName(tokens[1], tokens[2], trimToNull(tokens[3]), trimToNull(tokens[4]), trimToNull(tokens[5]), trimToNull(tokens[6]), actualResourceTypeDelimiter); } private  AmazonResourceName(); private  AmazonResourceName(String partition, String service, String region,
			String account, String resourceType, String resourceName,
			String actualResourceTypeDelimiter); }
AmazonResourceName { public static AmazonResourceName fromString(String name) { Assert.notNull(name, "name must not be null"); String[] tokens = name.split(RESOURCE_NAME_DELIMITER); if (tokens.length < 6 || tokens.length > 7) { throw new IllegalArgumentException( "Resource name:'" + name + "' is not a valid resource identifier"); } if (!"arn".equals(tokens[0])) { throw new IllegalArgumentException("Resource name:'" + name + "' must have an arn qualifier at the beginning"); } if (!("aws".equals(tokens[1]) || tokens[1].startsWith("aws-"))) { throw new IllegalArgumentException( "Resource name:'" + name + "' must have a valid partition name"); } String actualResourceTypeDelimiter; if (tokens.length == 6) { tokens = Arrays.copyOf(tokens, 7); String[] split = StringUtils.split(tokens[5], RESOURCE_TYPE_DELIMITER); if (split != null) { tokens[5] = split[0]; tokens[6] = split[1]; } actualResourceTypeDelimiter = RESOURCE_TYPE_DELIMITER; } else { actualResourceTypeDelimiter = RESOURCE_NAME_DELIMITER; } return new AmazonResourceName(tokens[1], tokens[2], trimToNull(tokens[3]), trimToNull(tokens[4]), trimToNull(tokens[5]), trimToNull(tokens[6]), actualResourceTypeDelimiter); } private  AmazonResourceName(); private  AmazonResourceName(String partition, String service, String region,
			String account, String resourceType, String resourceName,
			String actualResourceTypeDelimiter); static AmazonResourceName fromString(String name); static boolean isValidAmazonResourceName(String name); String getPartition(); String getService(); String getRegion(); String getAccount(); String getResourceType(); String getResourceName(); @Override String toString(); }
AmazonResourceName { public static AmazonResourceName fromString(String name) { Assert.notNull(name, "name must not be null"); String[] tokens = name.split(RESOURCE_NAME_DELIMITER); if (tokens.length < 6 || tokens.length > 7) { throw new IllegalArgumentException( "Resource name:'" + name + "' is not a valid resource identifier"); } if (!"arn".equals(tokens[0])) { throw new IllegalArgumentException("Resource name:'" + name + "' must have an arn qualifier at the beginning"); } if (!("aws".equals(tokens[1]) || tokens[1].startsWith("aws-"))) { throw new IllegalArgumentException( "Resource name:'" + name + "' must have a valid partition name"); } String actualResourceTypeDelimiter; if (tokens.length == 6) { tokens = Arrays.copyOf(tokens, 7); String[] split = StringUtils.split(tokens[5], RESOURCE_TYPE_DELIMITER); if (split != null) { tokens[5] = split[0]; tokens[6] = split[1]; } actualResourceTypeDelimiter = RESOURCE_TYPE_DELIMITER; } else { actualResourceTypeDelimiter = RESOURCE_NAME_DELIMITER; } return new AmazonResourceName(tokens[1], tokens[2], trimToNull(tokens[3]), trimToNull(tokens[4]), trimToNull(tokens[5]), trimToNull(tokens[6]), actualResourceTypeDelimiter); } private  AmazonResourceName(); private  AmazonResourceName(String partition, String service, String region,
			String account, String resourceType, String resourceName,
			String actualResourceTypeDelimiter); static AmazonResourceName fromString(String name); static boolean isValidAmazonResourceName(String name); String getPartition(); String getService(); String getRegion(); String getAccount(); String getResourceType(); String getResourceName(); @Override String toString();  }