target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void filter_tag_exclude_correct() { subject.validate(Query.parse("--filter-tag-exclude unref TEST-MNT"), messages); } | @Override public void validate(final Query query, final Messages messages) { if (query.hasOption(QueryFlag.FILTER_TAG_INCLUDE) && query.hasOption(QueryFlag.FILTER_TAG_EXCLUDE)) { final Sets.SetView<String> intersection = Sets.intersection(query.getOptionValues(QueryFlag.FILTER_TAG_INCLUDE), query.getOptionValues(QueryFlag.FILTER_TAG_EXCLUDE)); if (!intersection.isEmpty()) { final String args = " (" + Joiner.on(',').join(intersection.iterator()) + ")"; messages.add(QueryMessages.invalidCombinationOfFlags( QueryFlag.FILTER_TAG_INCLUDE.toString() + args, QueryFlag.FILTER_TAG_EXCLUDE.toString() + args)); } } } | TagValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.hasOption(QueryFlag.FILTER_TAG_INCLUDE) && query.hasOption(QueryFlag.FILTER_TAG_EXCLUDE)) { final Sets.SetView<String> intersection = Sets.intersection(query.getOptionValues(QueryFlag.FILTER_TAG_INCLUDE), query.getOptionValues(QueryFlag.FILTER_TAG_EXCLUDE)); if (!intersection.isEmpty()) { final String args = " (" + Joiner.on(',').join(intersection.iterator()) + ")"; messages.add(QueryMessages.invalidCombinationOfFlags( QueryFlag.FILTER_TAG_INCLUDE.toString() + args, QueryFlag.FILTER_TAG_EXCLUDE.toString() + args)); } } } } | TagValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.hasOption(QueryFlag.FILTER_TAG_INCLUDE) && query.hasOption(QueryFlag.FILTER_TAG_EXCLUDE)) { final Sets.SetView<String> intersection = Sets.intersection(query.getOptionValues(QueryFlag.FILTER_TAG_INCLUDE), query.getOptionValues(QueryFlag.FILTER_TAG_EXCLUDE)); if (!intersection.isEmpty()) { final String args = " (" + Joiner.on(',').join(intersection.iterator()) + ")"; messages.add(QueryMessages.invalidCombinationOfFlags( QueryFlag.FILTER_TAG_INCLUDE.toString() + args, QueryFlag.FILTER_TAG_EXCLUDE.toString() + args)); } } } } | TagValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.hasOption(QueryFlag.FILTER_TAG_INCLUDE) && query.hasOption(QueryFlag.FILTER_TAG_EXCLUDE)) { final Sets.SetView<String> intersection = Sets.intersection(query.getOptionValues(QueryFlag.FILTER_TAG_INCLUDE), query.getOptionValues(QueryFlag.FILTER_TAG_EXCLUDE)); if (!intersection.isEmpty()) { final String args = " (" + Joiner.on(',').join(intersection.iterator()) + ")"; messages.add(QueryMessages.invalidCombinationOfFlags( QueryFlag.FILTER_TAG_INCLUDE.toString() + args, QueryFlag.FILTER_TAG_EXCLUDE.toString() + args)); } } } @Override void validate(final Query query, final Messages messages); } | TagValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.hasOption(QueryFlag.FILTER_TAG_INCLUDE) && query.hasOption(QueryFlag.FILTER_TAG_EXCLUDE)) { final Sets.SetView<String> intersection = Sets.intersection(query.getOptionValues(QueryFlag.FILTER_TAG_INCLUDE), query.getOptionValues(QueryFlag.FILTER_TAG_EXCLUDE)); if (!intersection.isEmpty()) { final String args = " (" + Joiner.on(',').join(intersection.iterator()) + ")"; messages.add(QueryMessages.invalidCombinationOfFlags( QueryFlag.FILTER_TAG_INCLUDE.toString() + args, QueryFlag.FILTER_TAG_EXCLUDE.toString() + args)); } } } @Override void validate(final Query query, final Messages messages); } |
@Test public void parse_and_value() { subject = new SearchKey("test"); assertThat(subject.getValue(), is("test")); } | public String getValue() { return value; } | SearchKey { public String getValue() { return value; } } | SearchKey { public String getValue() { return value; } SearchKey(final String value); } | SearchKey { public String getValue() { return value; } SearchKey(final String value); String getValue(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); AsBlockRange getAsBlockRangeOrNull(); @Override String toString(); String getOrigin(); } | SearchKey { public String getValue() { return value; } SearchKey(final String value); String getValue(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); AsBlockRange getAsBlockRangeOrNull(); @Override String toString(); String getOrigin(); static final Pattern WHITESPACE_PATTERN; } |
@Test public void comma_in_search_key() { subject = new SearchKey("10,10"); assertNull(subject.getIpKeyOrNull()); } | public IpInterval<?> getIpKeyOrNull() { return ipKey; } | SearchKey { public IpInterval<?> getIpKeyOrNull() { return ipKey; } } | SearchKey { public IpInterval<?> getIpKeyOrNull() { return ipKey; } SearchKey(final String value); } | SearchKey { public IpInterval<?> getIpKeyOrNull() { return ipKey; } SearchKey(final String value); String getValue(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); AsBlockRange getAsBlockRangeOrNull(); @Override String toString(); String getOrigin(); } | SearchKey { public IpInterval<?> getIpKeyOrNull() { return ipKey; } SearchKey(final String value); String getValue(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); AsBlockRange getAsBlockRangeOrNull(); @Override String toString(); String getOrigin(); static final Pattern WHITESPACE_PATTERN; } |
@Test public void parse_ipv6_with_v4() { final SearchKey searchKey = new SearchKey("::ffff:0.0.0.0"); final IpInterval<?> ipKeyOrNull = searchKey.getIpKeyOrNull(); assertNull(ipKeyOrNull); } | public IpInterval<?> getIpKeyOrNull() { return ipKey; } | SearchKey { public IpInterval<?> getIpKeyOrNull() { return ipKey; } } | SearchKey { public IpInterval<?> getIpKeyOrNull() { return ipKey; } SearchKey(final String value); } | SearchKey { public IpInterval<?> getIpKeyOrNull() { return ipKey; } SearchKey(final String value); String getValue(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); AsBlockRange getAsBlockRangeOrNull(); @Override String toString(); String getOrigin(); } | SearchKey { public IpInterval<?> getIpKeyOrNull() { return ipKey; } SearchKey(final String value); String getValue(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); AsBlockRange getAsBlockRangeOrNull(); @Override String toString(); String getOrigin(); static final Pattern WHITESPACE_PATTERN; } |
@Test public void parse_ipv6_with_v4_prefix() { final SearchKey searchKey = new SearchKey("::ffff:0.0.0.0/72"); final IpInterval<?> ipKeyOrNull = searchKey.getIpKeyOrNull(); assertNull(ipKeyOrNull); } | public IpInterval<?> getIpKeyOrNull() { return ipKey; } | SearchKey { public IpInterval<?> getIpKeyOrNull() { return ipKey; } } | SearchKey { public IpInterval<?> getIpKeyOrNull() { return ipKey; } SearchKey(final String value); } | SearchKey { public IpInterval<?> getIpKeyOrNull() { return ipKey; } SearchKey(final String value); String getValue(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); AsBlockRange getAsBlockRangeOrNull(); @Override String toString(); String getOrigin(); } | SearchKey { public IpInterval<?> getIpKeyOrNull() { return ipKey; } SearchKey(final String value); String getValue(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); AsBlockRange getAsBlockRangeOrNull(); @Override String toString(); String getOrigin(); static final Pattern WHITESPACE_PATTERN; } |
@Test public void not_inverse_query() { when(query.isInverse()).thenReturn(FALSE); subject.validate(query, messages); assertThat(messages.hasMessages(), is(false)); } | @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } | InverseValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } } | InverseValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } } | InverseValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } @Override void validate(final Query query, final Messages messages); } | InverseValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } @Override void validate(final Query query, final Messages messages); } |
@Test public void crowd_client_exception_server_down() throws Exception { final UserSession userSession = new UserSession("[email protected]", "Test User", true, "2033-01-30T16:38:27.369+11:00"); userSession.setUuid("T2hOz8tlmka5lxoZQxzC1Q00"); when(ssoTokenTranslator.translateSsoToken("token")).thenThrow(CrowdClientException.class); when(crowdClient.getUsername("T2hOz8tlmka5lxoZQxzC1Q00")).thenThrow(CrowdClientException.class); subject = new FilterAuthFunction(Collections.<String>emptyList(), "token", ssoTokenTranslator, crowdClient, rpslObjectDao); final RpslObject result = subject.apply( RpslObject.parse("" + "mntner: SSO-MNT\n" + "auth: SSO T2hOz8tlmka5lxoZQxzC1Q00\n" + "source: RIPE")); assertThat(result.toString(), is("" + "mntner: SSO-MNT\n" + "auth: SSO # Filtered\n" + "source: RIPE # Filtered\n")); } | @Override @Nonnull public RpslObject apply(final RpslObject rpslObject) { final List<RpslAttribute> authAttributes = rpslObject.findAttributes(AttributeType.AUTH); if (authAttributes.isEmpty()) { return rpslObject; } final Map<RpslAttribute, RpslAttribute> replace = Maps.newHashMap(); final boolean authenticated = isMntnerAuthenticated(rpslObject); for (final RpslAttribute authAttribute : authAttributes) { final Iterator<String> authIterator = SPACE_SPLITTER.split(authAttribute.getCleanValue()).iterator(); final String passwordType = authIterator.next().toUpperCase(); if (authenticated) { if (passwordType.equals("SSO")) { final String username = crowdClient.getUsername(authIterator.next()); replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, "SSO " + username)); } } else { if (passwordType.endsWith("-PW") || passwordType.equals("SSO")) { replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, passwordType + FILTERED_APPENDIX)); } } } if (replace.isEmpty()) { return rpslObject; } else { if (!authenticated) { RpslObjectFilter.addFilteredSourceReplacement(rpslObject, replace); } return new RpslObjectBuilder(rpslObject).replaceAttributes(replace).get(); } } | FilterAuthFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(final RpslObject rpslObject) { final List<RpslAttribute> authAttributes = rpslObject.findAttributes(AttributeType.AUTH); if (authAttributes.isEmpty()) { return rpslObject; } final Map<RpslAttribute, RpslAttribute> replace = Maps.newHashMap(); final boolean authenticated = isMntnerAuthenticated(rpslObject); for (final RpslAttribute authAttribute : authAttributes) { final Iterator<String> authIterator = SPACE_SPLITTER.split(authAttribute.getCleanValue()).iterator(); final String passwordType = authIterator.next().toUpperCase(); if (authenticated) { if (passwordType.equals("SSO")) { final String username = crowdClient.getUsername(authIterator.next()); replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, "SSO " + username)); } } else { if (passwordType.endsWith("-PW") || passwordType.equals("SSO")) { replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, passwordType + FILTERED_APPENDIX)); } } } if (replace.isEmpty()) { return rpslObject; } else { if (!authenticated) { RpslObjectFilter.addFilteredSourceReplacement(rpslObject, replace); } return new RpslObjectBuilder(rpslObject).replaceAttributes(replace).get(); } } } | FilterAuthFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(final RpslObject rpslObject) { final List<RpslAttribute> authAttributes = rpslObject.findAttributes(AttributeType.AUTH); if (authAttributes.isEmpty()) { return rpslObject; } final Map<RpslAttribute, RpslAttribute> replace = Maps.newHashMap(); final boolean authenticated = isMntnerAuthenticated(rpslObject); for (final RpslAttribute authAttribute : authAttributes) { final Iterator<String> authIterator = SPACE_SPLITTER.split(authAttribute.getCleanValue()).iterator(); final String passwordType = authIterator.next().toUpperCase(); if (authenticated) { if (passwordType.equals("SSO")) { final String username = crowdClient.getUsername(authIterator.next()); replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, "SSO " + username)); } } else { if (passwordType.endsWith("-PW") || passwordType.equals("SSO")) { replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, passwordType + FILTERED_APPENDIX)); } } } if (replace.isEmpty()) { return rpslObject; } else { if (!authenticated) { RpslObjectFilter.addFilteredSourceReplacement(rpslObject, replace); } return new RpslObjectBuilder(rpslObject).replaceAttributes(replace).get(); } } FilterAuthFunction(final List<String> passwords,
final String token,
final SsoTokenTranslator ssoTokenTranslator,
final CrowdClient crowdClient,
final RpslObjectDao rpslObjectDao); FilterAuthFunction(); } | FilterAuthFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(final RpslObject rpslObject) { final List<RpslAttribute> authAttributes = rpslObject.findAttributes(AttributeType.AUTH); if (authAttributes.isEmpty()) { return rpslObject; } final Map<RpslAttribute, RpslAttribute> replace = Maps.newHashMap(); final boolean authenticated = isMntnerAuthenticated(rpslObject); for (final RpslAttribute authAttribute : authAttributes) { final Iterator<String> authIterator = SPACE_SPLITTER.split(authAttribute.getCleanValue()).iterator(); final String passwordType = authIterator.next().toUpperCase(); if (authenticated) { if (passwordType.equals("SSO")) { final String username = crowdClient.getUsername(authIterator.next()); replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, "SSO " + username)); } } else { if (passwordType.endsWith("-PW") || passwordType.equals("SSO")) { replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, passwordType + FILTERED_APPENDIX)); } } } if (replace.isEmpty()) { return rpslObject; } else { if (!authenticated) { RpslObjectFilter.addFilteredSourceReplacement(rpslObject, replace); } return new RpslObjectBuilder(rpslObject).replaceAttributes(replace).get(); } } FilterAuthFunction(final List<String> passwords,
final String token,
final SsoTokenTranslator ssoTokenTranslator,
final CrowdClient crowdClient,
final RpslObjectDao rpslObjectDao); FilterAuthFunction(); @Override @Nonnull RpslObject apply(final RpslObject rpslObject); } | FilterAuthFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(final RpslObject rpslObject) { final List<RpslAttribute> authAttributes = rpslObject.findAttributes(AttributeType.AUTH); if (authAttributes.isEmpty()) { return rpslObject; } final Map<RpslAttribute, RpslAttribute> replace = Maps.newHashMap(); final boolean authenticated = isMntnerAuthenticated(rpslObject); for (final RpslAttribute authAttribute : authAttributes) { final Iterator<String> authIterator = SPACE_SPLITTER.split(authAttribute.getCleanValue()).iterator(); final String passwordType = authIterator.next().toUpperCase(); if (authenticated) { if (passwordType.equals("SSO")) { final String username = crowdClient.getUsername(authIterator.next()); replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, "SSO " + username)); } } else { if (passwordType.endsWith("-PW") || passwordType.equals("SSO")) { replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, passwordType + FILTERED_APPENDIX)); } } } if (replace.isEmpty()) { return rpslObject; } else { if (!authenticated) { RpslObjectFilter.addFilteredSourceReplacement(rpslObject, replace); } return new RpslObjectBuilder(rpslObject).replaceAttributes(replace).get(); } } FilterAuthFunction(final List<String> passwords,
final String token,
final SsoTokenTranslator ssoTokenTranslator,
final CrowdClient crowdClient,
final RpslObjectDao rpslObjectDao); FilterAuthFunction(); @Override @Nonnull RpslObject apply(final RpslObject rpslObject); static final Splitter SPACE_SPLITTER; static final String FILTERED_APPENDIX; } |
@Test public void searchValue_not_SSO_nor_MD5() { when(query.isInverse()).thenReturn(TRUE); when(query.getSearchValue()).thenReturn("ORG-TP1-TEST"); subject.validate(query, messages); assertThat(messages.hasMessages(), is(false)); } | @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } | InverseValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } } | InverseValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } } | InverseValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } @Override void validate(final Query query, final Messages messages); } | InverseValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } @Override void validate(final Query query, final Messages messages); } |
@Test public void searchValue_SSO() { when(query.isInverse()).thenReturn(TRUE); when(query.getSearchValue()).thenReturn("SSO [email protected]"); subject.validate(query, messages); assertThat(messages.getErrors(), contains(QueryMessages.inverseSearchNotAllowed())); } | @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } | InverseValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } } | InverseValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } } | InverseValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } @Override void validate(final Query query, final Messages messages); } | InverseValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } @Override void validate(final Query query, final Messages messages); } |
@Test public void searchValue_MD5() { when(query.isInverse()).thenReturn(TRUE); when(query.getSearchValue()).thenReturn("MD5-PW \\$1\\$fU9ZMQN9\\$QQtm3kRqZXWAuLpeOiLN7."); subject.validate(query, messages); assertThat(messages.getErrors(), contains(QueryMessages.inverseSearchNotAllowed())); } | @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } | InverseValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } } | InverseValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } } | InverseValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } @Override void validate(final Query query, final Messages messages); } | InverseValidator implements QueryValidator { @Override public void validate(final Query query, final Messages messages) { if (query.isInverse()) { final String auth = query.getSearchValue().toUpperCase(); if ((!query.isTrusted() && auth.startsWith("SSO ")) || auth.startsWith("MD5-PW ")) { messages.add(net.ripe.db.whois.query.QueryMessages.inverseSearchNotAllowed()); } } } @Override void validate(final Query query, final Messages messages); } |
@Test public void empty() { try { parse(""); fail("Expected exception"); } catch (QueryException e) { assertThat(e.getMessages(), contains(QueryMessages.noSearchKeySpecified())); } } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void deprecated_R() { try { parse("-R test"); } catch (QueryException e) { assertThat(e.getMessages(), hasSize(1)); assertThat(e.getMessages().iterator().next(), is(QueryMessages.malformedQuery())); } } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void missing_arguments_for_flags() { String[] flagsWithArguments = {"i", "s", "t", "v", "q", "V"}; for (String flag : flagsWithArguments) { try { parse("-" + flag); fail("Missing argument for " + flag + " should throw an exception"); } catch (QueryException e) { assertThat(e.getMessages(), contains(QueryMessages.malformedQuery())); } } } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void single_type_invalid_searchkey() { try { parse("-T aut-num foo"); fail("Expected query exception"); } catch (QueryException e) { assertThat(e.getCompletionInfo(), Matchers.is(QueryCompletionInfo.PARAMETER_ERROR)); assertThat(e.getMessages(), contains(QueryMessages.invalidSearchKey())); } } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void non_existing_types() { try { parse("-T aUT-Num,IAmInvalid,iNETnUm"); fail("Non existing type should throw an exception"); } catch (QueryException e) { assertThat(e.getMessage(), containsString("ERROR:103")); } } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test(expected = QueryException.class) public void proxied_for_invalid() { parse("-VclientId,ipAddress"); } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test(expected = QueryException.class) public void proxy_with_invalid_ip() { parse("-Vone,two"); } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void sso_token_translator_exception() throws Exception { when(ssoTokenTranslator.translateSsoToken(any(String.class))).thenThrow(CrowdClientException.class); subject = new FilterAuthFunction(Collections.<String>emptyList(), "token", ssoTokenTranslator, crowdClient, rpslObjectDao); final RpslObject result = subject.apply( RpslObject.parse("" + "mntner: SSO-MNT\n" + "auth: SSO T2hOz8tlmka5lxoZQxzC1Q00\n" + "source: RIPE")); assertThat(result.toString(), is("" + "mntner: SSO-MNT\n" + "auth: SSO # Filtered\n" + "source: RIPE # Filtered\n")); } | @Override @Nonnull public RpslObject apply(final RpslObject rpslObject) { final List<RpslAttribute> authAttributes = rpslObject.findAttributes(AttributeType.AUTH); if (authAttributes.isEmpty()) { return rpslObject; } final Map<RpslAttribute, RpslAttribute> replace = Maps.newHashMap(); final boolean authenticated = isMntnerAuthenticated(rpslObject); for (final RpslAttribute authAttribute : authAttributes) { final Iterator<String> authIterator = SPACE_SPLITTER.split(authAttribute.getCleanValue()).iterator(); final String passwordType = authIterator.next().toUpperCase(); if (authenticated) { if (passwordType.equals("SSO")) { final String username = crowdClient.getUsername(authIterator.next()); replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, "SSO " + username)); } } else { if (passwordType.endsWith("-PW") || passwordType.equals("SSO")) { replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, passwordType + FILTERED_APPENDIX)); } } } if (replace.isEmpty()) { return rpslObject; } else { if (!authenticated) { RpslObjectFilter.addFilteredSourceReplacement(rpslObject, replace); } return new RpslObjectBuilder(rpslObject).replaceAttributes(replace).get(); } } | FilterAuthFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(final RpslObject rpslObject) { final List<RpslAttribute> authAttributes = rpslObject.findAttributes(AttributeType.AUTH); if (authAttributes.isEmpty()) { return rpslObject; } final Map<RpslAttribute, RpslAttribute> replace = Maps.newHashMap(); final boolean authenticated = isMntnerAuthenticated(rpslObject); for (final RpslAttribute authAttribute : authAttributes) { final Iterator<String> authIterator = SPACE_SPLITTER.split(authAttribute.getCleanValue()).iterator(); final String passwordType = authIterator.next().toUpperCase(); if (authenticated) { if (passwordType.equals("SSO")) { final String username = crowdClient.getUsername(authIterator.next()); replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, "SSO " + username)); } } else { if (passwordType.endsWith("-PW") || passwordType.equals("SSO")) { replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, passwordType + FILTERED_APPENDIX)); } } } if (replace.isEmpty()) { return rpslObject; } else { if (!authenticated) { RpslObjectFilter.addFilteredSourceReplacement(rpslObject, replace); } return new RpslObjectBuilder(rpslObject).replaceAttributes(replace).get(); } } } | FilterAuthFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(final RpslObject rpslObject) { final List<RpslAttribute> authAttributes = rpslObject.findAttributes(AttributeType.AUTH); if (authAttributes.isEmpty()) { return rpslObject; } final Map<RpslAttribute, RpslAttribute> replace = Maps.newHashMap(); final boolean authenticated = isMntnerAuthenticated(rpslObject); for (final RpslAttribute authAttribute : authAttributes) { final Iterator<String> authIterator = SPACE_SPLITTER.split(authAttribute.getCleanValue()).iterator(); final String passwordType = authIterator.next().toUpperCase(); if (authenticated) { if (passwordType.equals("SSO")) { final String username = crowdClient.getUsername(authIterator.next()); replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, "SSO " + username)); } } else { if (passwordType.endsWith("-PW") || passwordType.equals("SSO")) { replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, passwordType + FILTERED_APPENDIX)); } } } if (replace.isEmpty()) { return rpslObject; } else { if (!authenticated) { RpslObjectFilter.addFilteredSourceReplacement(rpslObject, replace); } return new RpslObjectBuilder(rpslObject).replaceAttributes(replace).get(); } } FilterAuthFunction(final List<String> passwords,
final String token,
final SsoTokenTranslator ssoTokenTranslator,
final CrowdClient crowdClient,
final RpslObjectDao rpslObjectDao); FilterAuthFunction(); } | FilterAuthFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(final RpslObject rpslObject) { final List<RpslAttribute> authAttributes = rpslObject.findAttributes(AttributeType.AUTH); if (authAttributes.isEmpty()) { return rpslObject; } final Map<RpslAttribute, RpslAttribute> replace = Maps.newHashMap(); final boolean authenticated = isMntnerAuthenticated(rpslObject); for (final RpslAttribute authAttribute : authAttributes) { final Iterator<String> authIterator = SPACE_SPLITTER.split(authAttribute.getCleanValue()).iterator(); final String passwordType = authIterator.next().toUpperCase(); if (authenticated) { if (passwordType.equals("SSO")) { final String username = crowdClient.getUsername(authIterator.next()); replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, "SSO " + username)); } } else { if (passwordType.endsWith("-PW") || passwordType.equals("SSO")) { replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, passwordType + FILTERED_APPENDIX)); } } } if (replace.isEmpty()) { return rpslObject; } else { if (!authenticated) { RpslObjectFilter.addFilteredSourceReplacement(rpslObject, replace); } return new RpslObjectBuilder(rpslObject).replaceAttributes(replace).get(); } } FilterAuthFunction(final List<String> passwords,
final String token,
final SsoTokenTranslator ssoTokenTranslator,
final CrowdClient crowdClient,
final RpslObjectDao rpslObjectDao); FilterAuthFunction(); @Override @Nonnull RpslObject apply(final RpslObject rpslObject); } | FilterAuthFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(final RpslObject rpslObject) { final List<RpslAttribute> authAttributes = rpslObject.findAttributes(AttributeType.AUTH); if (authAttributes.isEmpty()) { return rpslObject; } final Map<RpslAttribute, RpslAttribute> replace = Maps.newHashMap(); final boolean authenticated = isMntnerAuthenticated(rpslObject); for (final RpslAttribute authAttribute : authAttributes) { final Iterator<String> authIterator = SPACE_SPLITTER.split(authAttribute.getCleanValue()).iterator(); final String passwordType = authIterator.next().toUpperCase(); if (authenticated) { if (passwordType.equals("SSO")) { final String username = crowdClient.getUsername(authIterator.next()); replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, "SSO " + username)); } } else { if (passwordType.endsWith("-PW") || passwordType.equals("SSO")) { replace.put(authAttribute, new RpslAttribute(AttributeType.AUTH, passwordType + FILTERED_APPENDIX)); } } } if (replace.isEmpty()) { return rpslObject; } else { if (!authenticated) { RpslObjectFilter.addFilteredSourceReplacement(rpslObject, replace); } return new RpslObjectBuilder(rpslObject).replaceAttributes(replace).get(); } } FilterAuthFunction(final List<String> passwords,
final String token,
final SsoTokenTranslator ssoTokenTranslator,
final CrowdClient crowdClient,
final RpslObjectDao rpslObjectDao); FilterAuthFunction(); @Override @Nonnull RpslObject apply(final RpslObject rpslObject); static final Splitter SPACE_SPLITTER; static final String FILTERED_APPENDIX; } |
@Test(expected = QueryException.class) public void proxy_with_more_than_two_elements() { parse("-Vone,two,10.1.1.1"); } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test(expected = QueryException.class) public void invalidProxyShouldThrowException() { Query.parse("-Vone,two,three -Tperson DW-RIPE"); } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test(expected = QueryException.class) public void multiple_proxies() { Query.parse("-V ripews,188.111.4.162 -V 85.25.132.61"); } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void isReturningIrt() { Query query = Query.parse("-c 10.0.0.0"); assertTrue(query.isReturningIrt()); } | public boolean isReturningIrt() { return isBriefAbuseContact() || (!isKeysOnly() && queryParser.hasOption(QueryFlag.IRT)); } | Query { public boolean isReturningIrt() { return isBriefAbuseContact() || (!isKeysOnly() && queryParser.hasOption(QueryFlag.IRT)); } } | Query { public boolean isReturningIrt() { return isBriefAbuseContact() || (!isKeysOnly() && queryParser.hasOption(QueryFlag.IRT)); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public boolean isReturningIrt() { return isBriefAbuseContact() || (!isKeysOnly() && queryParser.hasOption(QueryFlag.IRT)); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public boolean isReturningIrt() { return isBriefAbuseContact() || (!isKeysOnly() && queryParser.hasOption(QueryFlag.IRT)); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void hasSources() { Query query = Query.parse("-s RIPE,TEST 10.0.0.0"); assertTrue(query.hasSources()); assertThat(query.getSources(), contains("RIPE", "TEST")); } | public boolean hasSources() { return !sources.isEmpty(); } | Query { public boolean hasSources() { return !sources.isEmpty(); } } | Query { public boolean hasSources() { return !sources.isEmpty(); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public boolean hasSources() { return !sources.isEmpty(); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public boolean hasSources() { return !sources.isEmpty(); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void isPrimaryObjectsOnly() { Query query = Query.parse("-rG 10.0.0.0"); assertTrue(query.isPrimaryObjectsOnly()); } | public boolean isPrimaryObjectsOnly() { return !(isReturningReferencedObjects() || isReturningIrt() || isGrouping()); } | Query { public boolean isPrimaryObjectsOnly() { return !(isReturningReferencedObjects() || isReturningIrt() || isGrouping()); } } | Query { public boolean isPrimaryObjectsOnly() { return !(isReturningReferencedObjects() || isReturningIrt() || isGrouping()); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public boolean isPrimaryObjectsOnly() { return !(isReturningReferencedObjects() || isReturningIrt() || isGrouping()); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public boolean isPrimaryObjectsOnly() { return !(isReturningReferencedObjects() || isReturningIrt() || isGrouping()); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void isAllSources() { Query query = Query.parse("-a foo"); assertThat(query.isAllSources(), is(true)); } | public boolean isAllSources() { return queryParser.hasOption(QueryFlag.ALL_SOURCES); } | Query { public boolean isAllSources() { return queryParser.hasOption(QueryFlag.ALL_SOURCES); } } | Query { public boolean isAllSources() { return queryParser.hasOption(QueryFlag.ALL_SOURCES); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public boolean isAllSources() { return queryParser.hasOption(QueryFlag.ALL_SOURCES); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public boolean isAllSources() { return queryParser.hasOption(QueryFlag.ALL_SOURCES); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void isKeysOnly() { Query query = Query.parse("-K 10.0.0.0"); assertThat(query.isKeysOnly(), is(true)); } | public boolean isKeysOnly() { return queryParser.hasOption(QueryFlag.PRIMARY_KEYS); } | Query { public boolean isKeysOnly() { return queryParser.hasOption(QueryFlag.PRIMARY_KEYS); } } | Query { public boolean isKeysOnly() { return queryParser.hasOption(QueryFlag.PRIMARY_KEYS); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public boolean isKeysOnly() { return queryParser.hasOption(QueryFlag.PRIMARY_KEYS); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public boolean isKeysOnly() { return queryParser.hasOption(QueryFlag.PRIMARY_KEYS); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void hasOption() { Query query = Query.parse("-s RIPE -T inetnum 10.0.0.0"); assertThat(query.hasOption(QueryFlag.SOURCES), is(true)); assertThat(query.hasOption(QueryFlag.SELECT_TYPES), is(true)); assertThat(query.hasOption(QueryFlag.NO_REFERENCED), is(false)); } | public boolean hasOption(QueryFlag queryFlag) { return queryParser.hasOption(queryFlag); } | Query { public boolean hasOption(QueryFlag queryFlag) { return queryParser.hasOption(queryFlag); } } | Query { public boolean hasOption(QueryFlag queryFlag) { return queryParser.hasOption(queryFlag); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public boolean hasOption(QueryFlag queryFlag) { return queryParser.hasOption(queryFlag); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public boolean hasOption(QueryFlag queryFlag) { return queryParser.hasOption(queryFlag); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void multiple_match_operations() { try { Query.parse("-m -x 10.0.0.0"); fail("Expected exception"); } catch (QueryException e) { assertThat(e.getMessages(), contains(QueryMessages.duplicateIpFlagsPassed())); } } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void apply_no_email_attribute() { final RpslObject rpslObject = RpslObject.parse("" + "irt: DEV-IRT\n" + "auth: MD5-PW $1$YmPozTxJ$s3eGZRVrKVGdSDTeEZJu\n" + "source: RIPE" ); final RpslObject response = subject.apply(rpslObject); assertThat(response, is(rpslObject)); } | @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } | FilterEmailFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } } | FilterEmailFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } } | FilterEmailFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } @Override @Nonnull RpslObject apply(RpslObject rpslObject); } | FilterEmailFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } @Override @Nonnull RpslObject apply(RpslObject rpslObject); } |
@Test public void invalid_combination() { try { Query.parse("-b -F 10.0.0.0"); fail("Expected exception"); } catch (QueryException e) { assertThat(e.getMessages(), contains(QueryMessages.invalidCombinationOfFlags("-b, --abuse-contact", "-F, --brief"))); } } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void brief_without_ipkey() { try { Query.parse("-b test"); fail("Expected exception"); } catch (QueryException e) { assertThat(e.getMessages(), contains(QueryMessages.malformedQuery())); } } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void unsupportedQuery() { try { Query.parse("..."); fail("Expected exception"); } catch (QueryException e) { assertThat(e.getMessages(), contains(QueryMessages.invalidSearchKey())); } } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void allow_only_k_T_and_V_options_for_version_queries() { final String[] validQueries = { "--show-version 1 AS12 -k", "--show-version 1 AS12 -V fred", "--show-version 1 AS12 -k -V fred", "--list-versions AS12 -k -V fred", "--list-versions AS12 -V fred", "--list-versions AS12 -k", "--diff-versions 1:2 AS12", "--diff-versions 1:2 AS12 -k", "--diff-versions 1:2 AS12 -V fred", "--show-version 1 AS12 -T aut-num", }; for (String query : validQueries) { Query.parse(query); } final String[] invalidQueries = { "--show-version 1 AS12 -B", "--list-versions AS12 -G", "--list-versions AS12 -V fred --no-tag-info", "--list-versions AS12 -k --show-version 1 AS12", "--diff-versions 1:2 AS12 -k --show-version 1", "--diff-versions 1:2 AS12 -B", "--diff-versions 1:2 AS12 -V fred --no-tag-info" }; for (String query : invalidQueries) { try { Query.parse(query); fail(String.format("%s should not succeed", query)); } catch (final QueryException e) { assertThat(e.getMessage(), containsString("cannot be used together")); } } } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void filter_tag_include_no_query() { try { Query.parse("--filter-tag-include unref"); fail("Expected exception"); } catch (QueryException e) { assertThat(e.getMessages(), contains(QueryMessages.noSearchKeySpecified())); } } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void filter_tag_exclude_no_query() { try { Query.parse("--filter-tag-exclude unref"); fail("Expected exception"); } catch (QueryException e) { assertThat(e.getMessages(), contains(QueryMessages.noSearchKeySpecified())); } } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void no_tag_info_and_show_tag_info_in_the_same_query() { try { Query.parse("--no-tag-info --show-tag-info TEST-MNT"); fail(); } catch (QueryException e) { assertThat(e.getMessage(), containsString("The flags \"--show-tag-info\" and \"--no-tag-info\" cannot be used together.")); } } | public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); } | Query { public static Query parse(final String args) { return parse(args, Origin.LEGACY, false); } private Query(final String query, final Origin origin, final boolean trusted); static Query parse(final String args); static Query parse(final String args, final Origin origin, final boolean trusted); static Query parse(final String args, final String ssoToken, final List<String> passwords, final boolean trusted); List<String> getPasswords(); String getSsoToken(); boolean isTrusted(); boolean hasSubstitutions(); boolean via(Origin origin); Collection<Message> getWarnings(); boolean isAllSources(); boolean isResource(); boolean isLookupInBothDirections(); boolean isReturningIrt(); boolean isGrouping(); boolean isBriefAbuseContact(); boolean isKeysOnly(); boolean isPrimaryObjectsOnly(); boolean isFiltered(); boolean isHelp(); boolean isSystemInfo(); boolean isReturningReferencedObjects(); boolean isInverse(); boolean isTemplate(); boolean isVersionList(); boolean isVersionDiff(); boolean isObjectVersion(); int getObjectVersion(); int[] getObjectVersions(); String getTemplateOption(); boolean isVerbose(); boolean isValidSyntax(); boolean isNoValidSyntax(); SystemInfoOption getSystemInfoOption(); String getVerboseOption(); boolean hasObjectTypesSpecified(); Set<ObjectType> getObjectTypes(); Set<AttributeType> getAttributeTypes(); MatchOperation matchOperation(); boolean hasIpFlags(); boolean hasObjectTypeFilter(ObjectType objectType); String getSearchValue(); Set<ObjectType> getSuppliedObjectTypes(); IpInterval<?> getIpKeyOrNull(); IpInterval<?> getIpKeyOrNullReverse(); String getRouteOrigin(); AsBlockRange getAsBlockRangeOrNull(); String getProxy(); boolean hasProxy(); boolean hasProxyWithIp(); boolean hasKeepAlive(); boolean isShortHand(); boolean hasOnlyKeepAlive(); boolean isProxyValid(); String getProxyIp(); boolean hasOptions(); boolean hasOption(QueryFlag queryFlag); @Deprecated Set<String> getOptionValues(QueryFlag queryFlag); @Deprecated Set<CIString> getOptionValuesCI(QueryFlag queryFlag); boolean hasSources(); Set<String> getSources(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchesObjectTypeAndAttribute(final ObjectType objectType, final AttributeType attributeType); boolean isMatchPrimaryKeyOnly(); Query setMatchPrimaryKeyOnly(boolean matchPrimaryKeyOnly); static final EnumSet<ObjectType> ABUSE_CONTACT_OBJECT_TYPES; } |
@Test public void test_limit_default() throws Exception { assertThat(subject.getLimit(inetAddress), is(5000)); } | public int getLimit(final InetAddress address) { final Integer result = limit.getValue(IpInterval.asIpInterval(address)); return result == null ? DEFAULT_LIMIT : result; } | IpResourceConfiguration { public int getLimit(final InetAddress address) { final Integer result = limit.getValue(IpInterval.asIpInterval(address)); return result == null ? DEFAULT_LIMIT : result; } } | IpResourceConfiguration { public int getLimit(final InetAddress address) { final Integer result = limit.getValue(IpInterval.asIpInterval(address)); return result == null ? DEFAULT_LIMIT : result; } @Autowired IpResourceConfiguration(final Loader loader); } | IpResourceConfiguration { public int getLimit(final InetAddress address) { final Integer result = limit.getValue(IpInterval.asIpInterval(address)); return result == null ? DEFAULT_LIMIT : result; } @Autowired IpResourceConfiguration(final Loader loader); boolean isDenied(final InetAddress address); boolean isDenied(final IpInterval address); boolean isProxy(final InetAddress address); boolean isProxy(final IpInterval address); int getLimit(final InetAddress address); int getLimit(final IpInterval address); boolean isUnlimitedConnections(final InetAddress address); boolean isUnlimitedConnections(final IpInterval address); @PostConstruct @Scheduled(fixedDelay = TREE_UPDATE_IN_SECONDS * 1000) synchronized void reload(); } | IpResourceConfiguration { public int getLimit(final InetAddress address) { final Integer result = limit.getValue(IpInterval.asIpInterval(address)); return result == null ? DEFAULT_LIMIT : result; } @Autowired IpResourceConfiguration(final Loader loader); boolean isDenied(final InetAddress address); boolean isDenied(final IpInterval address); boolean isProxy(final InetAddress address); boolean isProxy(final IpInterval address); int getLimit(final InetAddress address); int getLimit(final IpInterval address); boolean isUnlimitedConnections(final InetAddress address); boolean isUnlimitedConnections(final IpInterval address); @PostConstruct @Scheduled(fixedDelay = TREE_UPDATE_IN_SECONDS * 1000) synchronized void reload(); } |
@Test public void test_proxy_default() throws Exception { assertThat(subject.isProxy(inetAddress), is(false)); } | public boolean isProxy(final InetAddress address) { final Boolean result = proxy.getValue(IpInterval.asIpInterval(address)); return result != null && result; } | IpResourceConfiguration { public boolean isProxy(final InetAddress address) { final Boolean result = proxy.getValue(IpInterval.asIpInterval(address)); return result != null && result; } } | IpResourceConfiguration { public boolean isProxy(final InetAddress address) { final Boolean result = proxy.getValue(IpInterval.asIpInterval(address)); return result != null && result; } @Autowired IpResourceConfiguration(final Loader loader); } | IpResourceConfiguration { public boolean isProxy(final InetAddress address) { final Boolean result = proxy.getValue(IpInterval.asIpInterval(address)); return result != null && result; } @Autowired IpResourceConfiguration(final Loader loader); boolean isDenied(final InetAddress address); boolean isDenied(final IpInterval address); boolean isProxy(final InetAddress address); boolean isProxy(final IpInterval address); int getLimit(final InetAddress address); int getLimit(final IpInterval address); boolean isUnlimitedConnections(final InetAddress address); boolean isUnlimitedConnections(final IpInterval address); @PostConstruct @Scheduled(fixedDelay = TREE_UPDATE_IN_SECONDS * 1000) synchronized void reload(); } | IpResourceConfiguration { public boolean isProxy(final InetAddress address) { final Boolean result = proxy.getValue(IpInterval.asIpInterval(address)); return result != null && result; } @Autowired IpResourceConfiguration(final Loader loader); boolean isDenied(final InetAddress address); boolean isDenied(final IpInterval address); boolean isProxy(final InetAddress address); boolean isProxy(final IpInterval address); int getLimit(final InetAddress address); int getLimit(final IpInterval address); boolean isUnlimitedConnections(final InetAddress address); boolean isUnlimitedConnections(final IpInterval address); @PostConstruct @Scheduled(fixedDelay = TREE_UPDATE_IN_SECONDS * 1000) synchronized void reload(); } |
@Test public void test_denied_default() throws Exception { assertThat(subject.isDenied(inetAddress), is(false)); } | public boolean isDenied(final InetAddress address) { final Boolean result = denied.getValue(IpInterval.asIpInterval(address)); return result != null && result; } | IpResourceConfiguration { public boolean isDenied(final InetAddress address) { final Boolean result = denied.getValue(IpInterval.asIpInterval(address)); return result != null && result; } } | IpResourceConfiguration { public boolean isDenied(final InetAddress address) { final Boolean result = denied.getValue(IpInterval.asIpInterval(address)); return result != null && result; } @Autowired IpResourceConfiguration(final Loader loader); } | IpResourceConfiguration { public boolean isDenied(final InetAddress address) { final Boolean result = denied.getValue(IpInterval.asIpInterval(address)); return result != null && result; } @Autowired IpResourceConfiguration(final Loader loader); boolean isDenied(final InetAddress address); boolean isDenied(final IpInterval address); boolean isProxy(final InetAddress address); boolean isProxy(final IpInterval address); int getLimit(final InetAddress address); int getLimit(final IpInterval address); boolean isUnlimitedConnections(final InetAddress address); boolean isUnlimitedConnections(final IpInterval address); @PostConstruct @Scheduled(fixedDelay = TREE_UPDATE_IN_SECONDS * 1000) synchronized void reload(); } | IpResourceConfiguration { public boolean isDenied(final InetAddress address) { final Boolean result = denied.getValue(IpInterval.asIpInterval(address)); return result != null && result; } @Autowired IpResourceConfiguration(final Loader loader); boolean isDenied(final InetAddress address); boolean isDenied(final IpInterval address); boolean isProxy(final InetAddress address); boolean isProxy(final IpInterval address); int getLimit(final InetAddress address); int getLimit(final IpInterval address); boolean isUnlimitedConnections(final InetAddress address); boolean isUnlimitedConnections(final IpInterval address); @PostConstruct @Scheduled(fixedDelay = TREE_UPDATE_IN_SECONDS * 1000) synchronized void reload(); } |
@Test public void apply_email_attributes() { final RpslObject rpslObject = RpslObject.parse("" + "mntner: WEIRD-MNT\n" + "e-mail: value\n" + "e-mail: value\n" + "notify: value\n" + "notify: value\n" + "ref-nfy: value\n" + "ref-nfy: value\n" + "mnt-nfy: value\n" + "mnt-nfy: value\n" + "upd-to: value\n" + "upd-to: value\n" + "source: RIPE\n" ); final RpslObject response = subject.apply(rpslObject); assertThat(response.toString(), is("" + "mntner: WEIRD-MNT\n" + "source: RIPE # Filtered\n")); } | @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } | FilterEmailFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } } | FilterEmailFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } } | FilterEmailFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } @Override @Nonnull RpslObject apply(RpslObject rpslObject); } | FilterEmailFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } @Override @Nonnull RpslObject apply(RpslObject rpslObject); } |
@Test public void test_unlimitedConnections_default() throws Exception { assertThat(subject.isUnlimitedConnections(inetAddress), is(false)); } | public boolean isUnlimitedConnections(final InetAddress address) { final Boolean result = unlimitedConnections.getValue(IpInterval.asIpInterval(address)); return result != null && result; } | IpResourceConfiguration { public boolean isUnlimitedConnections(final InetAddress address) { final Boolean result = unlimitedConnections.getValue(IpInterval.asIpInterval(address)); return result != null && result; } } | IpResourceConfiguration { public boolean isUnlimitedConnections(final InetAddress address) { final Boolean result = unlimitedConnections.getValue(IpInterval.asIpInterval(address)); return result != null && result; } @Autowired IpResourceConfiguration(final Loader loader); } | IpResourceConfiguration { public boolean isUnlimitedConnections(final InetAddress address) { final Boolean result = unlimitedConnections.getValue(IpInterval.asIpInterval(address)); return result != null && result; } @Autowired IpResourceConfiguration(final Loader loader); boolean isDenied(final InetAddress address); boolean isDenied(final IpInterval address); boolean isProxy(final InetAddress address); boolean isProxy(final IpInterval address); int getLimit(final InetAddress address); int getLimit(final IpInterval address); boolean isUnlimitedConnections(final InetAddress address); boolean isUnlimitedConnections(final IpInterval address); @PostConstruct @Scheduled(fixedDelay = TREE_UPDATE_IN_SECONDS * 1000) synchronized void reload(); } | IpResourceConfiguration { public boolean isUnlimitedConnections(final InetAddress address) { final Boolean result = unlimitedConnections.getValue(IpInterval.asIpInterval(address)); return result != null && result; } @Autowired IpResourceConfiguration(final Loader loader); boolean isDenied(final InetAddress address); boolean isDenied(final IpInterval address); boolean isProxy(final InetAddress address); boolean isProxy(final IpInterval address); int getLimit(final InetAddress address); int getLimit(final IpInterval address); boolean isUnlimitedConnections(final InetAddress address); boolean isUnlimitedConnections(final IpInterval address); @PostConstruct @Scheduled(fixedDelay = TREE_UPDATE_IN_SECONDS * 1000) synchronized void reload(); } |
@Test public void check_denied_restricted() throws Exception { assertTrue(subject.isDenied(ipv4Restricted)); assertTrue(subject.isDenied(ipv6Restricted)); } | public boolean isDenied(final InetAddress remoteAddress) { return resourceConfiguration.isDenied(remoteAddress); } | AccessControlListManager { public boolean isDenied(final InetAddress remoteAddress) { return resourceConfiguration.isDenied(remoteAddress); } } | AccessControlListManager { public boolean isDenied(final InetAddress remoteAddress) { return resourceConfiguration.isDenied(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); } | AccessControlListManager { public boolean isDenied(final InetAddress remoteAddress) { return resourceConfiguration.isDenied(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } | AccessControlListManager { public boolean isDenied(final InetAddress remoteAddress) { return resourceConfiguration.isDenied(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } |
@Test public void check_denied_unrestricted() throws Exception { assertFalse(subject.isDenied(ipv4Unrestricted)); assertFalse(subject.isDenied(ipv6Unrestricted)); } | public boolean isDenied(final InetAddress remoteAddress) { return resourceConfiguration.isDenied(remoteAddress); } | AccessControlListManager { public boolean isDenied(final InetAddress remoteAddress) { return resourceConfiguration.isDenied(remoteAddress); } } | AccessControlListManager { public boolean isDenied(final InetAddress remoteAddress) { return resourceConfiguration.isDenied(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); } | AccessControlListManager { public boolean isDenied(final InetAddress remoteAddress) { return resourceConfiguration.isDenied(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } | AccessControlListManager { public boolean isDenied(final InetAddress remoteAddress) { return resourceConfiguration.isDenied(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } |
@Test public void check_denied_unknown() throws Exception { assertFalse(subject.isDenied(ipv4Unknown)); assertFalse(subject.isDenied(ipv6Unknown)); } | public boolean isDenied(final InetAddress remoteAddress) { return resourceConfiguration.isDenied(remoteAddress); } | AccessControlListManager { public boolean isDenied(final InetAddress remoteAddress) { return resourceConfiguration.isDenied(remoteAddress); } } | AccessControlListManager { public boolean isDenied(final InetAddress remoteAddress) { return resourceConfiguration.isDenied(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); } | AccessControlListManager { public boolean isDenied(final InetAddress remoteAddress) { return resourceConfiguration.isDenied(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } | AccessControlListManager { public boolean isDenied(final InetAddress remoteAddress) { return resourceConfiguration.isDenied(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } |
@Test public void check_proxy_restricted() throws Exception { assertFalse(subject.isAllowedToProxy(ipv4Restricted)); assertFalse(subject.isAllowedToProxy(ipv6Restricted)); } | public boolean isAllowedToProxy(final InetAddress remoteAddress) { return resourceConfiguration.isProxy(remoteAddress); } | AccessControlListManager { public boolean isAllowedToProxy(final InetAddress remoteAddress) { return resourceConfiguration.isProxy(remoteAddress); } } | AccessControlListManager { public boolean isAllowedToProxy(final InetAddress remoteAddress) { return resourceConfiguration.isProxy(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); } | AccessControlListManager { public boolean isAllowedToProxy(final InetAddress remoteAddress) { return resourceConfiguration.isProxy(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } | AccessControlListManager { public boolean isAllowedToProxy(final InetAddress remoteAddress) { return resourceConfiguration.isProxy(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } |
@Test public void check_proxy_unrestricted() throws Exception { assertTrue(subject.isAllowedToProxy(ipv4Unrestricted)); assertTrue(subject.isAllowedToProxy(ipv6Unrestricted)); } | public boolean isAllowedToProxy(final InetAddress remoteAddress) { return resourceConfiguration.isProxy(remoteAddress); } | AccessControlListManager { public boolean isAllowedToProxy(final InetAddress remoteAddress) { return resourceConfiguration.isProxy(remoteAddress); } } | AccessControlListManager { public boolean isAllowedToProxy(final InetAddress remoteAddress) { return resourceConfiguration.isProxy(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); } | AccessControlListManager { public boolean isAllowedToProxy(final InetAddress remoteAddress) { return resourceConfiguration.isProxy(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } | AccessControlListManager { public boolean isAllowedToProxy(final InetAddress remoteAddress) { return resourceConfiguration.isProxy(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } |
@Test public void check_proxy_unknown() throws Exception { assertFalse(subject.isAllowedToProxy(ipv4Unknown)); assertFalse(subject.isAllowedToProxy(ipv6Unknown)); } | public boolean isAllowedToProxy(final InetAddress remoteAddress) { return resourceConfiguration.isProxy(remoteAddress); } | AccessControlListManager { public boolean isAllowedToProxy(final InetAddress remoteAddress) { return resourceConfiguration.isProxy(remoteAddress); } } | AccessControlListManager { public boolean isAllowedToProxy(final InetAddress remoteAddress) { return resourceConfiguration.isProxy(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); } | AccessControlListManager { public boolean isAllowedToProxy(final InetAddress remoteAddress) { return resourceConfiguration.isProxy(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } | AccessControlListManager { public boolean isAllowedToProxy(final InetAddress remoteAddress) { return resourceConfiguration.isProxy(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } |
@Test public void check_getLimit_restricted() throws Exception { assertThat(subject.getPersonalDataLimit(ipv4Restricted), is(PERSONAL_DATA_LIMIT)); assertThat(subject.getPersonalDataLimit(ipv6Restricted), is(PERSONAL_DATA_LIMIT)); } | int getPersonalDataLimit(final InetAddress remoteAddress) { return resourceConfiguration.getLimit(remoteAddress); } | AccessControlListManager { int getPersonalDataLimit(final InetAddress remoteAddress) { return resourceConfiguration.getLimit(remoteAddress); } } | AccessControlListManager { int getPersonalDataLimit(final InetAddress remoteAddress) { return resourceConfiguration.getLimit(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); } | AccessControlListManager { int getPersonalDataLimit(final InetAddress remoteAddress) { return resourceConfiguration.getLimit(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } | AccessControlListManager { int getPersonalDataLimit(final InetAddress remoteAddress) { return resourceConfiguration.getLimit(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } |
@Test public void check_getLimit_unrestricted() throws Exception { assertThat(subject.getPersonalDataLimit(ipv4Unrestricted), is(PERSONAL_DATA_NO_LIMIT)); assertThat(subject.getPersonalDataLimit(ipv6Unrestricted), is(PERSONAL_DATA_NO_LIMIT)); } | int getPersonalDataLimit(final InetAddress remoteAddress) { return resourceConfiguration.getLimit(remoteAddress); } | AccessControlListManager { int getPersonalDataLimit(final InetAddress remoteAddress) { return resourceConfiguration.getLimit(remoteAddress); } } | AccessControlListManager { int getPersonalDataLimit(final InetAddress remoteAddress) { return resourceConfiguration.getLimit(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); } | AccessControlListManager { int getPersonalDataLimit(final InetAddress remoteAddress) { return resourceConfiguration.getLimit(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } | AccessControlListManager { int getPersonalDataLimit(final InetAddress remoteAddress) { return resourceConfiguration.getLimit(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } |
@Test public void check_getLimit_unknown() throws Exception { assertThat(subject.getPersonalDataLimit(ipv4Unknown), is(PERSONAL_DATA_LIMIT_UNKNOWN)); assertThat(subject.getPersonalDataLimit(ipv6Unknown), is(PERSONAL_DATA_LIMIT_UNKNOWN)); } | int getPersonalDataLimit(final InetAddress remoteAddress) { return resourceConfiguration.getLimit(remoteAddress); } | AccessControlListManager { int getPersonalDataLimit(final InetAddress remoteAddress) { return resourceConfiguration.getLimit(remoteAddress); } } | AccessControlListManager { int getPersonalDataLimit(final InetAddress remoteAddress) { return resourceConfiguration.getLimit(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); } | AccessControlListManager { int getPersonalDataLimit(final InetAddress remoteAddress) { return resourceConfiguration.getLimit(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } | AccessControlListManager { int getPersonalDataLimit(final InetAddress remoteAddress) { return resourceConfiguration.getLimit(remoteAddress); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } |
@Test public void apply_email_attributes_not_filtered() { final RpslObject rpslObject = RpslObject.parse("" + "mntner: WEIRD-MNT\n" + "source: RIPE\n" ); final RpslObject response = subject.apply(rpslObject); assertThat(response.toString(), is("" + "mntner: WEIRD-MNT\n" + "source: RIPE\n")); } | @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } | FilterEmailFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } } | FilterEmailFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } } | FilterEmailFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } @Override @Nonnull RpslObject apply(RpslObject rpslObject); } | FilterEmailFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } @Override @Nonnull RpslObject apply(RpslObject rpslObject); } |
@Test public void test_if_block_temporary_is_logged() { subject.blockTemporary(ipv6Restricted, PERSONAL_DATA_LIMIT); verify(accessControlListDao).saveAclEvent(ipv6ResourceCaptor.capture(), eq(now), eq(PERSONAL_DATA_LIMIT), eq(BlockEvent.Type.BLOCK_TEMPORARY)); Ipv6Resource ipv6Resource = ipv6ResourceCaptor.getValue(); assertThat(ipv6Resource.toString(), is("2001::/64")); } | public void blockTemporary(final InetAddress hostAddress, final int limit) { IpInterval<?> maskedAddress; if (hostAddress instanceof Inet6Address) { maskedAddress = Ipv6Resource.parse(mask(hostAddress, IPV6_NETMASK).getHostAddress() + "/" + IPV6_NETMASK); } else { maskedAddress = Ipv4Resource.asIpInterval(hostAddress); } accessControlListDao.saveAclEvent(maskedAddress, dateTimeProvider.getCurrentDate(), limit, BlockEvent.Type.BLOCK_TEMPORARY); } | AccessControlListManager { public void blockTemporary(final InetAddress hostAddress, final int limit) { IpInterval<?> maskedAddress; if (hostAddress instanceof Inet6Address) { maskedAddress = Ipv6Resource.parse(mask(hostAddress, IPV6_NETMASK).getHostAddress() + "/" + IPV6_NETMASK); } else { maskedAddress = Ipv4Resource.asIpInterval(hostAddress); } accessControlListDao.saveAclEvent(maskedAddress, dateTimeProvider.getCurrentDate(), limit, BlockEvent.Type.BLOCK_TEMPORARY); } } | AccessControlListManager { public void blockTemporary(final InetAddress hostAddress, final int limit) { IpInterval<?> maskedAddress; if (hostAddress instanceof Inet6Address) { maskedAddress = Ipv6Resource.parse(mask(hostAddress, IPV6_NETMASK).getHostAddress() + "/" + IPV6_NETMASK); } else { maskedAddress = Ipv4Resource.asIpInterval(hostAddress); } accessControlListDao.saveAclEvent(maskedAddress, dateTimeProvider.getCurrentDate(), limit, BlockEvent.Type.BLOCK_TEMPORARY); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); } | AccessControlListManager { public void blockTemporary(final InetAddress hostAddress, final int limit) { IpInterval<?> maskedAddress; if (hostAddress instanceof Inet6Address) { maskedAddress = Ipv6Resource.parse(mask(hostAddress, IPV6_NETMASK).getHostAddress() + "/" + IPV6_NETMASK); } else { maskedAddress = Ipv4Resource.asIpInterval(hostAddress); } accessControlListDao.saveAclEvent(maskedAddress, dateTimeProvider.getCurrentDate(), limit, BlockEvent.Type.BLOCK_TEMPORARY); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } | AccessControlListManager { public void blockTemporary(final InetAddress hostAddress, final int limit) { IpInterval<?> maskedAddress; if (hostAddress instanceof Inet6Address) { maskedAddress = Ipv6Resource.parse(mask(hostAddress, IPV6_NETMASK).getHostAddress() + "/" + IPV6_NETMASK); } else { maskedAddress = Ipv4Resource.asIpInterval(hostAddress); } accessControlListDao.saveAclEvent(maskedAddress, dateTimeProvider.getCurrentDate(), limit, BlockEvent.Type.BLOCK_TEMPORARY); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } |
@Test public void requiresAcl_withRipeSource() { assertTrue(subject.requiresAcl(person, Source.slave("RIPE"))); assertTrue(subject.requiresAcl(role, Source.slave("RIPE"))); assertFalse(subject.requiresAcl(roleWithAbuseMailbox, Source.slave("RIPE"))); assertFalse(subject.requiresAcl(autNum, Source.slave("RIPE"))); assertFalse(subject.requiresAcl(inetnum, Source.slave("RIPE"))); assertFalse(subject.requiresAcl(domain, Source.slave("RIPE"))); } | public boolean requiresAcl(final RpslObject rpslObject, final Source source) { if (source.isGrs()) { return false; } final ObjectType objectType = rpslObject.getType(); return ObjectType.PERSON.equals(objectType) || (ObjectType.ROLE.equals(objectType) && rpslObject.findAttributes(AttributeType.ABUSE_MAILBOX).isEmpty()); } | AccessControlListManager { public boolean requiresAcl(final RpslObject rpslObject, final Source source) { if (source.isGrs()) { return false; } final ObjectType objectType = rpslObject.getType(); return ObjectType.PERSON.equals(objectType) || (ObjectType.ROLE.equals(objectType) && rpslObject.findAttributes(AttributeType.ABUSE_MAILBOX).isEmpty()); } } | AccessControlListManager { public boolean requiresAcl(final RpslObject rpslObject, final Source source) { if (source.isGrs()) { return false; } final ObjectType objectType = rpslObject.getType(); return ObjectType.PERSON.equals(objectType) || (ObjectType.ROLE.equals(objectType) && rpslObject.findAttributes(AttributeType.ABUSE_MAILBOX).isEmpty()); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); } | AccessControlListManager { public boolean requiresAcl(final RpslObject rpslObject, final Source source) { if (source.isGrs()) { return false; } final ObjectType objectType = rpslObject.getType(); return ObjectType.PERSON.equals(objectType) || (ObjectType.ROLE.equals(objectType) && rpslObject.findAttributes(AttributeType.ABUSE_MAILBOX).isEmpty()); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } | AccessControlListManager { public boolean requiresAcl(final RpslObject rpslObject, final Source source) { if (source.isGrs()) { return false; } final ObjectType objectType = rpslObject.getType(); return ObjectType.PERSON.equals(objectType) || (ObjectType.ROLE.equals(objectType) && rpslObject.findAttributes(AttributeType.ABUSE_MAILBOX).isEmpty()); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } |
@Test public void requiresAcl_withNonRipeSource() { assertFalse(subject.requiresAcl(autNum, Source.slave("APNIC-GRS"))); assertFalse(subject.requiresAcl(person, Source.slave("APNIC-GRS"))); assertFalse(subject.requiresAcl(role, Source.slave("AFRINIC-GRS"))); assertFalse(subject.requiresAcl(person, Source.slave("AFRINIC-GRS"))); assertFalse(subject.requiresAcl(role, Source.slave("JPIRR-GRS"))); assertFalse(subject.requiresAcl(inetnum, Source.slave("JPIRR-GRS"))); assertFalse(subject.requiresAcl(autNum, Source.slave("RADB-GRS"))); } | public boolean requiresAcl(final RpslObject rpslObject, final Source source) { if (source.isGrs()) { return false; } final ObjectType objectType = rpslObject.getType(); return ObjectType.PERSON.equals(objectType) || (ObjectType.ROLE.equals(objectType) && rpslObject.findAttributes(AttributeType.ABUSE_MAILBOX).isEmpty()); } | AccessControlListManager { public boolean requiresAcl(final RpslObject rpslObject, final Source source) { if (source.isGrs()) { return false; } final ObjectType objectType = rpslObject.getType(); return ObjectType.PERSON.equals(objectType) || (ObjectType.ROLE.equals(objectType) && rpslObject.findAttributes(AttributeType.ABUSE_MAILBOX).isEmpty()); } } | AccessControlListManager { public boolean requiresAcl(final RpslObject rpslObject, final Source source) { if (source.isGrs()) { return false; } final ObjectType objectType = rpslObject.getType(); return ObjectType.PERSON.equals(objectType) || (ObjectType.ROLE.equals(objectType) && rpslObject.findAttributes(AttributeType.ABUSE_MAILBOX).isEmpty()); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); } | AccessControlListManager { public boolean requiresAcl(final RpslObject rpslObject, final Source source) { if (source.isGrs()) { return false; } final ObjectType objectType = rpslObject.getType(); return ObjectType.PERSON.equals(objectType) || (ObjectType.ROLE.equals(objectType) && rpslObject.findAttributes(AttributeType.ABUSE_MAILBOX).isEmpty()); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } | AccessControlListManager { public boolean requiresAcl(final RpslObject rpslObject, final Source source) { if (source.isGrs()) { return false; } final ObjectType objectType = rpslObject.getType(); return ObjectType.PERSON.equals(objectType) || (ObjectType.ROLE.equals(objectType) && rpslObject.findAttributes(AttributeType.ABUSE_MAILBOX).isEmpty()); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } |
@Test public void requiresAcl_withTest() { assertTrue(subject.requiresAcl(person, Source.slave("TEST"))); assertTrue(subject.requiresAcl(role, Source.slave("TEST"))); assertFalse(subject.requiresAcl(roleWithAbuseMailbox, Source.slave("TEST"))); assertFalse(subject.requiresAcl(autNum, Source.slave("TEST"))); assertFalse(subject.requiresAcl(inetnum, Source.slave("TEST"))); assertFalse(subject.requiresAcl(domain, Source.slave("TEST"))); } | public boolean requiresAcl(final RpslObject rpslObject, final Source source) { if (source.isGrs()) { return false; } final ObjectType objectType = rpslObject.getType(); return ObjectType.PERSON.equals(objectType) || (ObjectType.ROLE.equals(objectType) && rpslObject.findAttributes(AttributeType.ABUSE_MAILBOX).isEmpty()); } | AccessControlListManager { public boolean requiresAcl(final RpslObject rpslObject, final Source source) { if (source.isGrs()) { return false; } final ObjectType objectType = rpslObject.getType(); return ObjectType.PERSON.equals(objectType) || (ObjectType.ROLE.equals(objectType) && rpslObject.findAttributes(AttributeType.ABUSE_MAILBOX).isEmpty()); } } | AccessControlListManager { public boolean requiresAcl(final RpslObject rpslObject, final Source source) { if (source.isGrs()) { return false; } final ObjectType objectType = rpslObject.getType(); return ObjectType.PERSON.equals(objectType) || (ObjectType.ROLE.equals(objectType) && rpslObject.findAttributes(AttributeType.ABUSE_MAILBOX).isEmpty()); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); } | AccessControlListManager { public boolean requiresAcl(final RpslObject rpslObject, final Source source) { if (source.isGrs()) { return false; } final ObjectType objectType = rpslObject.getType(); return ObjectType.PERSON.equals(objectType) || (ObjectType.ROLE.equals(objectType) && rpslObject.findAttributes(AttributeType.ABUSE_MAILBOX).isEmpty()); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } | AccessControlListManager { public boolean requiresAcl(final RpslObject rpslObject, final Source source) { if (source.isGrs()) { return false; } final ObjectType objectType = rpslObject.getType(); return ObjectType.PERSON.equals(objectType) || (ObjectType.ROLE.equals(objectType) && rpslObject.findAttributes(AttributeType.ABUSE_MAILBOX).isEmpty()); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } |
@Test public void testMask() throws UnknownHostException { InetAddress subject = Inet6Address.getByName("3ffe:6a88:85a3:98d3:1319:8a2e:9370:7344"); assertThat(mask(subject, 125).getHostAddress(), is("3ffe:6a88:85a3:98d3:1319:8a2e:9370:7340")); assertThat(mask(subject, 112).getHostAddress(), is("3ffe:6a88:85a3:98d3:1319:8a2e:9370:0")); assertThat(mask(subject, 96).getHostAddress(), is("3ffe:6a88:85a3:98d3:1319:8a2e:0:0")); assertThat(mask(subject, 80).getHostAddress(), is("3ffe:6a88:85a3:98d3:1319:0:0:0")); assertThat(mask(subject, 64).getHostAddress(), is("3ffe:6a88:85a3:98d3:0:0:0:0")); assertThat(mask(subject, 48).getHostAddress(), is("3ffe:6a88:85a3:0:0:0:0:0")); assertThat(mask(subject, 32).getHostAddress(), is("3ffe:6a88:0:0:0:0:0:0")); assertThat(mask(subject, 16).getHostAddress(), is("3ffe:0:0:0:0:0:0:0")); assertThat(mask(subject, 8).getHostAddress(), is("3f00:0:0:0:0:0:0:0")); assertThat(mask(subject, 7).getHostAddress(), is("3e00:0:0:0:0:0:0:0")); assertThat(mask(subject, 6).getHostAddress(), is("3c00:0:0:0:0:0:0:0")); assertThat(mask(subject, 5).getHostAddress(), is("3800:0:0:0:0:0:0:0")); assertThat(mask(subject, 4).getHostAddress(), is("3000:0:0:0:0:0:0:0")); assertThat(mask(subject, 3).getHostAddress(), is("2000:0:0:0:0:0:0:0")); assertThat(mask(subject, 2).getHostAddress(), is("0:0:0:0:0:0:0:0")); assertThat(mask(subject, 1).getHostAddress(), is("0:0:0:0:0:0:0:0")); assertThat(mask(subject, 0).getHostAddress(), is("0:0:0:0:0:0:0:0")); assertThat(mask(Inet6Address.getByName("::1"), AccessControlListManager.IPV6_NETMASK), is(Inet6Address.getByName("0:0:0:0:0:0:0:0"))); } | public static InetAddress mask(final InetAddress address, final int mask) { if (address instanceof Inet6Address) { byte[] bytes = address.getAddress(); int part = mask % 8; int firstMaskedIndex = (mask / 8) + (part == 0 ? 0 : 1); for (int i = firstMaskedIndex; i < bytes.length; i++) { bytes[i] = (byte) 0; } if (part != 0) { bytes[mask / 8] &= ~((1 << (8 - part)) - 1); } try { return Inet6Address.getByAddress(bytes); } catch (UnknownHostException e) { LOGGER.warn("We do not change the length; we cannot ever have this exception", e); } } return address; } | AccessControlListManager { public static InetAddress mask(final InetAddress address, final int mask) { if (address instanceof Inet6Address) { byte[] bytes = address.getAddress(); int part = mask % 8; int firstMaskedIndex = (mask / 8) + (part == 0 ? 0 : 1); for (int i = firstMaskedIndex; i < bytes.length; i++) { bytes[i] = (byte) 0; } if (part != 0) { bytes[mask / 8] &= ~((1 << (8 - part)) - 1); } try { return Inet6Address.getByAddress(bytes); } catch (UnknownHostException e) { LOGGER.warn("We do not change the length; we cannot ever have this exception", e); } } return address; } } | AccessControlListManager { public static InetAddress mask(final InetAddress address, final int mask) { if (address instanceof Inet6Address) { byte[] bytes = address.getAddress(); int part = mask % 8; int firstMaskedIndex = (mask / 8) + (part == 0 ? 0 : 1); for (int i = firstMaskedIndex; i < bytes.length; i++) { bytes[i] = (byte) 0; } if (part != 0) { bytes[mask / 8] &= ~((1 << (8 - part)) - 1); } try { return Inet6Address.getByAddress(bytes); } catch (UnknownHostException e) { LOGGER.warn("We do not change the length; we cannot ever have this exception", e); } } return address; } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); } | AccessControlListManager { public static InetAddress mask(final InetAddress address, final int mask) { if (address instanceof Inet6Address) { byte[] bytes = address.getAddress(); int part = mask % 8; int firstMaskedIndex = (mask / 8) + (part == 0 ? 0 : 1); for (int i = firstMaskedIndex; i < bytes.length; i++) { bytes[i] = (byte) 0; } if (part != 0) { bytes[mask / 8] &= ~((1 << (8 - part)) - 1); } try { return Inet6Address.getByAddress(bytes); } catch (UnknownHostException e) { LOGGER.warn("We do not change the length; we cannot ever have this exception", e); } } return address; } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } | AccessControlListManager { public static InetAddress mask(final InetAddress address, final int mask) { if (address instanceof Inet6Address) { byte[] bytes = address.getAddress(); int part = mask % 8; int firstMaskedIndex = (mask / 8) + (part == 0 ? 0 : 1); for (int i = firstMaskedIndex; i < bytes.length; i++) { bytes[i] = (byte) 0; } if (part != 0) { bytes[mask / 8] &= ~((1 << (8 - part)) - 1); } try { return Inet6Address.getByAddress(bytes); } catch (UnknownHostException e) { LOGGER.warn("We do not change the length; we cannot ever have this exception", e); } } return address; } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } |
@Test public void override_from_trusted_range() { when(ipRanges.isTrusted(any(IpInterval.class))).thenReturn(true); assertThat(subject.isTrusted(InetAddresses.forString("10.0.0.1")), is(true)); } | public boolean isTrusted(final InetAddress remoteAddress) { return ipRanges.isTrusted(IpInterval.asIpInterval(remoteAddress)); } | AccessControlListManager { public boolean isTrusted(final InetAddress remoteAddress) { return ipRanges.isTrusted(IpInterval.asIpInterval(remoteAddress)); } } | AccessControlListManager { public boolean isTrusted(final InetAddress remoteAddress) { return ipRanges.isTrusted(IpInterval.asIpInterval(remoteAddress)); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); } | AccessControlListManager { public boolean isTrusted(final InetAddress remoteAddress) { return ipRanges.isTrusted(IpInterval.asIpInterval(remoteAddress)); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } | AccessControlListManager { public boolean isTrusted(final InetAddress remoteAddress) { return ipRanges.isTrusted(IpInterval.asIpInterval(remoteAddress)); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } |
@Test public void override_from_untrusted_range() { when(ipRanges.isTrusted(any(IpInterval.class))).thenReturn(false); assertThat(subject.isTrusted(InetAddresses.forString("10.0.0.1")), is(false)); } | public boolean isTrusted(final InetAddress remoteAddress) { return ipRanges.isTrusted(IpInterval.asIpInterval(remoteAddress)); } | AccessControlListManager { public boolean isTrusted(final InetAddress remoteAddress) { return ipRanges.isTrusted(IpInterval.asIpInterval(remoteAddress)); } } | AccessControlListManager { public boolean isTrusted(final InetAddress remoteAddress) { return ipRanges.isTrusted(IpInterval.asIpInterval(remoteAddress)); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); } | AccessControlListManager { public boolean isTrusted(final InetAddress remoteAddress) { return ipRanges.isTrusted(IpInterval.asIpInterval(remoteAddress)); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } | AccessControlListManager { public boolean isTrusted(final InetAddress remoteAddress) { return ipRanges.isTrusted(IpInterval.asIpInterval(remoteAddress)); } @Autowired AccessControlListManager(final DateTimeProvider dateTimeProvider,
final IpResourceConfiguration resourceConfiguration,
final AccessControlListDao accessControlListDao,
final PersonalObjectAccounting personalObjectAccounting,
final IpRanges ipRanges); boolean requiresAcl(final RpslObject rpslObject, final Source source); boolean isDenied(final InetAddress remoteAddress); boolean isAllowedToProxy(final InetAddress remoteAddress); boolean isUnlimited(final InetAddress remoteAddress); boolean canQueryPersonalObjects(final InetAddress remoteAddress); boolean isTrusted(final InetAddress remoteAddress); int getPersonalObjects(final InetAddress remoteAddress); void accountPersonalObjects(final InetAddress remoteAddress, final int amount); void blockTemporary(final InetAddress hostAddress, final int limit); static InetAddress mask(final InetAddress address, final int mask); } |
@Test public void test_queried_personal_objects() { assertThat(subject.getQueriedPersonalObjects(ipv4Address), is(0)); } | @Override public int getQueriedPersonalObjects(final InetAddress remoteAddress) { Integer count = null; try { count = counterMap.get(remoteAddress); } catch (OperationTimeoutException | IllegalStateException e) { LOGGER.debug("{}: {}", e.getClass().getName(), e.getMessage()); } if (count == null) { return 0; } return count; } | HazelcastPersonalObjectAccounting implements PersonalObjectAccounting { @Override public int getQueriedPersonalObjects(final InetAddress remoteAddress) { Integer count = null; try { count = counterMap.get(remoteAddress); } catch (OperationTimeoutException | IllegalStateException e) { LOGGER.debug("{}: {}", e.getClass().getName(), e.getMessage()); } if (count == null) { return 0; } return count; } } | HazelcastPersonalObjectAccounting implements PersonalObjectAccounting { @Override public int getQueriedPersonalObjects(final InetAddress remoteAddress) { Integer count = null; try { count = counterMap.get(remoteAddress); } catch (OperationTimeoutException | IllegalStateException e) { LOGGER.debug("{}: {}", e.getClass().getName(), e.getMessage()); } if (count == null) { return 0; } return count; } } | HazelcastPersonalObjectAccounting implements PersonalObjectAccounting { @Override public int getQueriedPersonalObjects(final InetAddress remoteAddress) { Integer count = null; try { count = counterMap.get(remoteAddress); } catch (OperationTimeoutException | IllegalStateException e) { LOGGER.debug("{}: {}", e.getClass().getName(), e.getMessage()); } if (count == null) { return 0; } return count; } @PostConstruct void startService(); @PreDestroy void stopService(); @Override int getQueriedPersonalObjects(final InetAddress remoteAddress); @Override int accountPersonalObject(final InetAddress remoteAddress, final int amount); @Override void resetAccounting(); } | HazelcastPersonalObjectAccounting implements PersonalObjectAccounting { @Override public int getQueriedPersonalObjects(final InetAddress remoteAddress) { Integer count = null; try { count = counterMap.get(remoteAddress); } catch (OperationTimeoutException | IllegalStateException e) { LOGGER.debug("{}: {}", e.getClass().getName(), e.getMessage()); } if (count == null) { return 0; } return count; } @PostConstruct void startService(); @PreDestroy void stopService(); @Override int getQueriedPersonalObjects(final InetAddress remoteAddress); @Override int accountPersonalObject(final InetAddress remoteAddress, final int amount); @Override void resetAccounting(); } |
@Test public void test_account_personal_object_amount_1() { for (int i = 1; i < 100; i++) { int balance = subject.accountPersonalObject(ipv4Address, 1); assertThat(balance, is(i)); } } | @Override public int accountPersonalObject(final InetAddress remoteAddress, final int amount) { try { Integer count = counterMap.tryLockAndGet(remoteAddress, 3, TimeUnit.SECONDS); if (count == null) { count = amount; } else { count += amount; } counterMap.putAndUnlock(remoteAddress, count); return count; } catch (TimeoutException | IllegalStateException e) { LOGGER.info("Unable to account personal object, allowed by default. Threw " + e.getClass().getName() + ": " + e.getMessage()); } return 0; } | HazelcastPersonalObjectAccounting implements PersonalObjectAccounting { @Override public int accountPersonalObject(final InetAddress remoteAddress, final int amount) { try { Integer count = counterMap.tryLockAndGet(remoteAddress, 3, TimeUnit.SECONDS); if (count == null) { count = amount; } else { count += amount; } counterMap.putAndUnlock(remoteAddress, count); return count; } catch (TimeoutException | IllegalStateException e) { LOGGER.info("Unable to account personal object, allowed by default. Threw " + e.getClass().getName() + ": " + e.getMessage()); } return 0; } } | HazelcastPersonalObjectAccounting implements PersonalObjectAccounting { @Override public int accountPersonalObject(final InetAddress remoteAddress, final int amount) { try { Integer count = counterMap.tryLockAndGet(remoteAddress, 3, TimeUnit.SECONDS); if (count == null) { count = amount; } else { count += amount; } counterMap.putAndUnlock(remoteAddress, count); return count; } catch (TimeoutException | IllegalStateException e) { LOGGER.info("Unable to account personal object, allowed by default. Threw " + e.getClass().getName() + ": " + e.getMessage()); } return 0; } } | HazelcastPersonalObjectAccounting implements PersonalObjectAccounting { @Override public int accountPersonalObject(final InetAddress remoteAddress, final int amount) { try { Integer count = counterMap.tryLockAndGet(remoteAddress, 3, TimeUnit.SECONDS); if (count == null) { count = amount; } else { count += amount; } counterMap.putAndUnlock(remoteAddress, count); return count; } catch (TimeoutException | IllegalStateException e) { LOGGER.info("Unable to account personal object, allowed by default. Threw " + e.getClass().getName() + ": " + e.getMessage()); } return 0; } @PostConstruct void startService(); @PreDestroy void stopService(); @Override int getQueriedPersonalObjects(final InetAddress remoteAddress); @Override int accountPersonalObject(final InetAddress remoteAddress, final int amount); @Override void resetAccounting(); } | HazelcastPersonalObjectAccounting implements PersonalObjectAccounting { @Override public int accountPersonalObject(final InetAddress remoteAddress, final int amount) { try { Integer count = counterMap.tryLockAndGet(remoteAddress, 3, TimeUnit.SECONDS); if (count == null) { count = amount; } else { count += amount; } counterMap.putAndUnlock(remoteAddress, count); return count; } catch (TimeoutException | IllegalStateException e) { LOGGER.info("Unable to account personal object, allowed by default. Threw " + e.getClass().getName() + ": " + e.getMessage()); } return 0; } @PostConstruct void startService(); @PreDestroy void stopService(); @Override int getQueriedPersonalObjects(final InetAddress remoteAddress); @Override int accountPersonalObject(final InetAddress remoteAddress, final int amount); @Override void resetAccounting(); } |
@Test public void auth_attribute_md5() { assertThat(subject.getReferencedType(AttributeType.AUTH, CIString.ciString("MD5-PW $1$d9fKeTr2$Si7YudNf4rUGmR71n/cqk/")), is(nullValue())); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void apply_filtered_only_once() { final RpslObject rpslObject = RpslObject.parse("" + "mntner: WEIRD-MNT\n" + "source:RIPE # Filtered\n" + "e-mail:[email protected]\n" ); final RpslObject response = subject.apply(rpslObject); assertThat(response.toString(), is("" + "mntner: WEIRD-MNT\n" + "source: RIPE # Filtered\n")); } | @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } | FilterEmailFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } } | FilterEmailFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } } | FilterEmailFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } @Override @Nonnull RpslObject apply(RpslObject rpslObject); } | FilterEmailFunction implements FilterFunction { @Override @Nonnull public RpslObject apply(RpslObject rpslObject) { RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject).removeAttributeTypes(filterAttributes); return rpslObject.size() == builder.size() ? rpslObject : RpslObjectFilter.setFiltered(builder).get(); } @Override @Nonnull RpslObject apply(RpslObject rpslObject); } |
@Test public void no_check_for_non_person_role() throws ClaimException { final RpslObject object = RpslObject.parse("mntner: test-mnt"); subject.checkForReservedNicHandle(object); verifyZeroInteractions(nicHandleFactory); } | public void checkForReservedNicHandle(final RpslObject object) throws ClaimException { if (object.getType() != ObjectType.PERSON && object.getType() != ObjectType.ROLE) { return; } final CIString pkey = object.getKey(); if (pkey.equals("AUTO-1")){ throw new ClaimException(new Message(Messages.Type.ERROR, "AUTO-1 in nic-hdl is not available in Bootstrap/LoadDump mode")); } if (!nicHandleFactory.isAvailable(object.getKey().toString())){ throw new ClaimException(UpdateMessages.nicHandleNotAvailable(object.getKey())); } } | ObjectLoader { public void checkForReservedNicHandle(final RpslObject object) throws ClaimException { if (object.getType() != ObjectType.PERSON && object.getType() != ObjectType.ROLE) { return; } final CIString pkey = object.getKey(); if (pkey.equals("AUTO-1")){ throw new ClaimException(new Message(Messages.Type.ERROR, "AUTO-1 in nic-hdl is not available in Bootstrap/LoadDump mode")); } if (!nicHandleFactory.isAvailable(object.getKey().toString())){ throw new ClaimException(UpdateMessages.nicHandleNotAvailable(object.getKey())); } } } | ObjectLoader { public void checkForReservedNicHandle(final RpslObject object) throws ClaimException { if (object.getType() != ObjectType.PERSON && object.getType() != ObjectType.ROLE) { return; } final CIString pkey = object.getKey(); if (pkey.equals("AUTO-1")){ throw new ClaimException(new Message(Messages.Type.ERROR, "AUTO-1 in nic-hdl is not available in Bootstrap/LoadDump mode")); } if (!nicHandleFactory.isAvailable(object.getKey().toString())){ throw new ClaimException(UpdateMessages.nicHandleNotAvailable(object.getKey())); } } @Autowired ObjectLoader(RpslObjectDao rpslObjectDao,
RpslObjectUpdateDao rpslObjectUpdateDao,
AttributeSanitizer attributeSanitizer,
NicHandleFactory nicHandleFactory,
OrganisationIdRepository organisationIdRepository,
X509Repository x509Repository); } | ObjectLoader { public void checkForReservedNicHandle(final RpslObject object) throws ClaimException { if (object.getType() != ObjectType.PERSON && object.getType() != ObjectType.ROLE) { return; } final CIString pkey = object.getKey(); if (pkey.equals("AUTO-1")){ throw new ClaimException(new Message(Messages.Type.ERROR, "AUTO-1 in nic-hdl is not available in Bootstrap/LoadDump mode")); } if (!nicHandleFactory.isAvailable(object.getKey().toString())){ throw new ClaimException(UpdateMessages.nicHandleNotAvailable(object.getKey())); } } @Autowired ObjectLoader(RpslObjectDao rpslObjectDao,
RpslObjectUpdateDao rpslObjectUpdateDao,
AttributeSanitizer attributeSanitizer,
NicHandleFactory nicHandleFactory,
OrganisationIdRepository organisationIdRepository,
X509Repository x509Repository); void processObject(final String fullObject,
final Result result,
final int pass,
final LoaderMode loaderMode); @Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRES_NEW) void addObjectRisky(RpslObject rpslObject, Result result, int pass); void checkForReservedNicHandle(final RpslObject object); void claimIds(RpslObject rpslObject); } | ObjectLoader { public void checkForReservedNicHandle(final RpslObject object) throws ClaimException { if (object.getType() != ObjectType.PERSON && object.getType() != ObjectType.ROLE) { return; } final CIString pkey = object.getKey(); if (pkey.equals("AUTO-1")){ throw new ClaimException(new Message(Messages.Type.ERROR, "AUTO-1 in nic-hdl is not available in Bootstrap/LoadDump mode")); } if (!nicHandleFactory.isAvailable(object.getKey().toString())){ throw new ClaimException(UpdateMessages.nicHandleNotAvailable(object.getKey())); } } @Autowired ObjectLoader(RpslObjectDao rpslObjectDao,
RpslObjectUpdateDao rpslObjectUpdateDao,
AttributeSanitizer attributeSanitizer,
NicHandleFactory nicHandleFactory,
OrganisationIdRepository organisationIdRepository,
X509Repository x509Repository); void processObject(final String fullObject,
final Result result,
final int pass,
final LoaderMode loaderMode); @Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRES_NEW) void addObjectRisky(RpslObject rpslObject, Result result, int pass); void checkForReservedNicHandle(final RpslObject object); void claimIds(RpslObject rpslObject); } |
@Test public void auth_attribute_md5_filtered() { assertThat(subject.getReferencedType(AttributeType.AUTH, CIString.ciString("MD5-PW # Filtered")), is(nullValue())); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void auth_attribute_x509() { assertThat(subject.getReferencedType(AttributeType.AUTH, CIString.ciString("X509-1")), is("key-cert")); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void auth_attribute_pgpkey() { assertThat(subject.getReferencedType(AttributeType.AUTH, CIString.ciString("PGPKEY-28F6CD6C")), is("key-cert")); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void members_by_ref_any() { assertThat(subject.getReferencedType(AttributeType.MBRS_BY_REF, CIString.ciString("ANY")), is(nullValue())); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void members_by_ref_mntner() { assertThat(subject.getReferencedType(AttributeType.MBRS_BY_REF, CIString.ciString("OWNER-MNT")), is("mntner")); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void member_of_as_set() { assertThat(subject.getReferencedType(AttributeType.MEMBER_OF, CIString.ciString("AS-TEST")), is("as-set")); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void member_of_route_set() { assertThat(subject.getReferencedType(AttributeType.MEMBER_OF, CIString.ciString("rs-ripe")), is("route-set")); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void member_of_rtr_set() { assertThat(subject.getReferencedType(AttributeType.MEMBER_OF, CIString.ciString("RTRS-TEST")), is("rtr-set")); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void members_as_set() { assertThat(subject.getReferencedType(AttributeType.MEMBERS, CIString.ciString("AS-TEST")), is("as-set")); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void members_autnum() { assertThat(subject.getReferencedType(AttributeType.MEMBERS, CIString.ciString("AS100")), is("aut-num")); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test(expected = IllegalArgumentException.class) public void null_type() { subject.dummify(3, RpslObject.parse("FOOO:BAR\n")); } | public RpslObject dummify(final int version, final RpslObject rpslObject) { final ObjectType objectType = rpslObject.getType(); Validate.isTrue(isAllowed(version, rpslObject), "The given object type should be skipped", objectType); if (version <= 2 && usePlaceHolder(rpslObject)) { return objectType.equals(ObjectType.ROLE) ? getPlaceholderRoleObject() : getPlaceholderPersonObject(); } final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); stripSomeNonMandatoryAttributes(attributes, objectType); dummifyRemainingAttributes(attributes, rpslObject.getKey()); insertPlaceholder(attributes); attributes.addAll(getDummificationRemarks(rpslObject)); return new RpslObject(rpslObject, attributes); } | DummifierNrtm implements Dummifier { public RpslObject dummify(final int version, final RpslObject rpslObject) { final ObjectType objectType = rpslObject.getType(); Validate.isTrue(isAllowed(version, rpslObject), "The given object type should be skipped", objectType); if (version <= 2 && usePlaceHolder(rpslObject)) { return objectType.equals(ObjectType.ROLE) ? getPlaceholderRoleObject() : getPlaceholderPersonObject(); } final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); stripSomeNonMandatoryAttributes(attributes, objectType); dummifyRemainingAttributes(attributes, rpslObject.getKey()); insertPlaceholder(attributes); attributes.addAll(getDummificationRemarks(rpslObject)); return new RpslObject(rpslObject, attributes); } } | DummifierNrtm implements Dummifier { public RpslObject dummify(final int version, final RpslObject rpslObject) { final ObjectType objectType = rpslObject.getType(); Validate.isTrue(isAllowed(version, rpslObject), "The given object type should be skipped", objectType); if (version <= 2 && usePlaceHolder(rpslObject)) { return objectType.equals(ObjectType.ROLE) ? getPlaceholderRoleObject() : getPlaceholderPersonObject(); } final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); stripSomeNonMandatoryAttributes(attributes, objectType); dummifyRemainingAttributes(attributes, rpslObject.getKey()); insertPlaceholder(attributes); attributes.addAll(getDummificationRemarks(rpslObject)); return new RpslObject(rpslObject, attributes); } } | DummifierNrtm implements Dummifier { public RpslObject dummify(final int version, final RpslObject rpslObject) { final ObjectType objectType = rpslObject.getType(); Validate.isTrue(isAllowed(version, rpslObject), "The given object type should be skipped", objectType); if (version <= 2 && usePlaceHolder(rpslObject)) { return objectType.equals(ObjectType.ROLE) ? getPlaceholderRoleObject() : getPlaceholderPersonObject(); } final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); stripSomeNonMandatoryAttributes(attributes, objectType); dummifyRemainingAttributes(attributes, rpslObject.getKey()); insertPlaceholder(attributes); attributes.addAll(getDummificationRemarks(rpslObject)); return new RpslObject(rpslObject, attributes); } RpslObject dummify(final int version, final RpslObject rpslObject); boolean isAllowed(final int version, final RpslObject rpslObject); static RpslObject getPlaceholderPersonObject(); static RpslObject getPlaceholderRoleObject(); } | DummifierNrtm implements Dummifier { public RpslObject dummify(final int version, final RpslObject rpslObject) { final ObjectType objectType = rpslObject.getType(); Validate.isTrue(isAllowed(version, rpslObject), "The given object type should be skipped", objectType); if (version <= 2 && usePlaceHolder(rpslObject)) { return objectType.equals(ObjectType.ROLE) ? getPlaceholderRoleObject() : getPlaceholderPersonObject(); } final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); stripSomeNonMandatoryAttributes(attributes, objectType); dummifyRemainingAttributes(attributes, rpslObject.getKey()); insertPlaceholder(attributes); attributes.addAll(getDummificationRemarks(rpslObject)); return new RpslObject(rpslObject, attributes); } RpslObject dummify(final int version, final RpslObject rpslObject); boolean isAllowed(final int version, final RpslObject rpslObject); static RpslObject getPlaceholderPersonObject(); static RpslObject getPlaceholderRoleObject(); } |
@Test public void members_route_set() { assertThat(subject.getReferencedType(AttributeType.MEMBERS, CIString.ciString("rs-ripe")), is("route-set")); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void members_rtr_set() { assertThat(subject.getReferencedType(AttributeType.MEMBERS, CIString.ciString("RTRS-TEST")), is("rtr-set")); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void mnt_routes_mntner() { assertThat(subject.getReferencedType(AttributeType.MNT_ROUTES, CIString.ciString("OWNER-MNT")), is("mntner")); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void mnt_routes_mntner_any() { assertThat(subject.getReferencedType(AttributeType.MNT_ROUTES, CIString.ciString("OWNER-MNT ANY")), is("mntner")); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void mnt_routes_mntner_with_curly_braces() { assertThat(subject.getReferencedType(AttributeType.MNT_ROUTES, CIString.ciString("OWNER-MNT {2a00:c00::/24,2a00:c00::/16}")), is("mntner")); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void mnt_routes_invalid_syntax() { assertThat(subject.getReferencedType(AttributeType.MNT_ROUTES, CIString.ciString("NONE NONE")), is(nullValue())); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void person() { when(rpslObjectDao.findByKey(ObjectType.PERSON, "PP1-RIPE")).thenReturn(new RpslObjectInfo(1, ObjectType.PERSON, "PP1-RIPE")); when(rpslObjectDao.findByKey(ObjectType.ROLE, "PP1-RIPE")).thenThrow(EmptyResultDataAccessException.class); assertThat(subject.getReferencedType(AttributeType.TECH_C, CIString.ciString("PP1-RIPE")), is("person")); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void role() { when(rpslObjectDao.findByKey(ObjectType.ROLE, "RR1-RIPE")).thenReturn(new RpslObjectInfo(1, ObjectType.ROLE, "RR1-RIPE")); when(rpslObjectDao.findByKey(ObjectType.PERSON, "RR1-RIPE")).thenThrow(EmptyResultDataAccessException.class); assertThat(subject.getReferencedType(AttributeType.TECH_C, CIString.ciString("RR1-RIPE")), is("role")); } | @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } | ReferencedTypeResolver { @Nullable public String getReferencedType(final AttributeType attributeType, final CIString value) { final Set<ObjectType> references = attributeType.getReferences(); switch (references.size()) { case 0: if (AttributeType.MEMBERS.equals(attributeType)) { if (AttributeType.AUT_NUM.isValidValue(ObjectType.AUT_NUM, value)) { return ObjectType.AUT_NUM.getName(); } if (AttributeType.AS_SET.isValidValue(ObjectType.AS_SET, value)) { return ObjectType.AS_SET.getName(); } if (AttributeType.ROUTE_SET.isValidValue(ObjectType.ROUTE_SET, value)) { return ObjectType.ROUTE_SET.getName(); } if (AttributeType.RTR_SET.isValidValue(ObjectType.RTR_SET, value)) { return ObjectType.RTR_SET.getName(); } } return null; case 1: if (AttributeType.AUTH.equals(attributeType)) { final String authType = SPACE_SPLITTER.split(value).iterator().next().toUpperCase(); if (authType.endsWith("-PW") || authType.equals("SSO")) { return null; } } if (AttributeType.MBRS_BY_REF.equals(attributeType)) { if (value.toLowerCase().equals("any")) { return null; } } if (AttributeType.MNT_ROUTES.equals(attributeType)) { try { MNT_ROUTES_PARSER.parse(value.toString()); } catch (AttributeParseException e) { return null; } } return references.iterator().next().getName(); default: if (references.contains(ObjectType.PERSON) || references.contains(ObjectType.ROLE)) { for (ObjectType objectType : references) { if (attributeType.isValidValue(objectType, value)) { try { return rpslObjectDao.findByKey(objectType, value.toString()).getObjectType().getName(); } catch (EmptyResultDataAccessException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } } } else { for (ObjectType objectType : references) { for (AttributeType lookupAttribute : ObjectTemplate.getTemplate(objectType).getLookupAttributes()) { if (lookupAttribute.isValidValue(objectType, value)) { return objectType.getName(); } } } } return null; } } @Autowired ReferencedTypeResolver(@Qualifier("jdbcRpslObjectSlaveDao") final RpslObjectDao rpslObjectDao); @Nullable String getReferencedType(final AttributeType attributeType, final CIString value); } |
@Test public void dryRun_null() { subject.setDryRun(updateContext, null); verify(updateContext, never()).dryRun(); } | void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } @Autowired WhoisRestService(final RpslObjectDao rpslObjectDao,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext,
final AccessControlListManager accessControlListManager,
final WhoisObjectMapper whoisObjectMapper,
final InternalUpdatePerformer updatePerformer,
final SsoTranslator ssoTranslator,
final LoggerContext loggerContext,
final AuthoritativeResourceData authoritativeResourceData,
@Value("${api.rest.baseurl}") final String baseUrl); } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } @Autowired WhoisRestService(final RpslObjectDao rpslObjectDao,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext,
final AccessControlListManager accessControlListManager,
final WhoisObjectMapper whoisObjectMapper,
final InternalUpdatePerformer updatePerformer,
final SsoTranslator ssoTranslator,
final LoggerContext loggerContext,
final AuthoritativeResourceData authoritativeResourceData,
@Value("${api.rest.baseurl}") final String baseUrl); @DELETE @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response delete(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("reason") @DefaultValue("--") final String reason,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun); @PUT @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response update(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @POST @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}") Response create(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response lookup(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("unformatted") final String unformatted,
@QueryParam("unfiltered") final String unfiltered,
@QueryParam("managed-attributes") final String managedAttributes,
@QueryParam("resource-holder") final String resourceHolder,
@QueryParam("abuse-contact") final String abuseContact); } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } @Autowired WhoisRestService(final RpslObjectDao rpslObjectDao,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext,
final AccessControlListManager accessControlListManager,
final WhoisObjectMapper whoisObjectMapper,
final InternalUpdatePerformer updatePerformer,
final SsoTranslator ssoTranslator,
final LoggerContext loggerContext,
final AuthoritativeResourceData authoritativeResourceData,
@Value("${api.rest.baseurl}") final String baseUrl); @DELETE @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response delete(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("reason") @DefaultValue("--") final String reason,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun); @PUT @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response update(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @POST @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}") Response create(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response lookup(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("unformatted") final String unformatted,
@QueryParam("unfiltered") final String unfiltered,
@QueryParam("managed-attributes") final String managedAttributes,
@QueryParam("resource-holder") final String resourceHolder,
@QueryParam("abuse-contact") final String abuseContact); } |
@Test public void dryRun_false() { subject.setDryRun(updateContext, "fAlsE"); verify(updateContext, never()).dryRun(); } | void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } @Autowired WhoisRestService(final RpslObjectDao rpslObjectDao,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext,
final AccessControlListManager accessControlListManager,
final WhoisObjectMapper whoisObjectMapper,
final InternalUpdatePerformer updatePerformer,
final SsoTranslator ssoTranslator,
final LoggerContext loggerContext,
final AuthoritativeResourceData authoritativeResourceData,
@Value("${api.rest.baseurl}") final String baseUrl); } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } @Autowired WhoisRestService(final RpslObjectDao rpslObjectDao,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext,
final AccessControlListManager accessControlListManager,
final WhoisObjectMapper whoisObjectMapper,
final InternalUpdatePerformer updatePerformer,
final SsoTranslator ssoTranslator,
final LoggerContext loggerContext,
final AuthoritativeResourceData authoritativeResourceData,
@Value("${api.rest.baseurl}") final String baseUrl); @DELETE @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response delete(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("reason") @DefaultValue("--") final String reason,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun); @PUT @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response update(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @POST @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}") Response create(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response lookup(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("unformatted") final String unformatted,
@QueryParam("unfiltered") final String unfiltered,
@QueryParam("managed-attributes") final String managedAttributes,
@QueryParam("resource-holder") final String resourceHolder,
@QueryParam("abuse-contact") final String abuseContact); } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } @Autowired WhoisRestService(final RpslObjectDao rpslObjectDao,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext,
final AccessControlListManager accessControlListManager,
final WhoisObjectMapper whoisObjectMapper,
final InternalUpdatePerformer updatePerformer,
final SsoTranslator ssoTranslator,
final LoggerContext loggerContext,
final AuthoritativeResourceData authoritativeResourceData,
@Value("${api.rest.baseurl}") final String baseUrl); @DELETE @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response delete(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("reason") @DefaultValue("--") final String reason,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun); @PUT @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response update(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @POST @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}") Response create(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response lookup(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("unformatted") final String unformatted,
@QueryParam("unfiltered") final String unfiltered,
@QueryParam("managed-attributes") final String managedAttributes,
@QueryParam("resource-holder") final String resourceHolder,
@QueryParam("abuse-contact") final String abuseContact); } |
@Test public void allow_objects_version_3() { for (ObjectType objectType : ObjectType.values()) { if (DummifierNrtm.SKIPPED_OBJECT_TYPES.contains(objectType)) { continue; } final RpslObject rpslObject = createObject(objectType, "YAY", new RpslAttribute(AttributeType.REMARKS, "Remark!")); assertThat(subject.isAllowed(3, rpslObject), is(true)); } } | public boolean isAllowed(final int version, final RpslObject rpslObject) { return version <= 2 || !usePlaceHolder(rpslObject); } | DummifierNrtm implements Dummifier { public boolean isAllowed(final int version, final RpslObject rpslObject) { return version <= 2 || !usePlaceHolder(rpslObject); } } | DummifierNrtm implements Dummifier { public boolean isAllowed(final int version, final RpslObject rpslObject) { return version <= 2 || !usePlaceHolder(rpslObject); } } | DummifierNrtm implements Dummifier { public boolean isAllowed(final int version, final RpslObject rpslObject) { return version <= 2 || !usePlaceHolder(rpslObject); } RpslObject dummify(final int version, final RpslObject rpslObject); boolean isAllowed(final int version, final RpslObject rpslObject); static RpslObject getPlaceholderPersonObject(); static RpslObject getPlaceholderRoleObject(); } | DummifierNrtm implements Dummifier { public boolean isAllowed(final int version, final RpslObject rpslObject) { return version <= 2 || !usePlaceHolder(rpslObject); } RpslObject dummify(final int version, final RpslObject rpslObject); boolean isAllowed(final int version, final RpslObject rpslObject); static RpslObject getPlaceholderPersonObject(); static RpslObject getPlaceholderRoleObject(); } |
@Test public void dryRun_emptyString() { subject.setDryRun(updateContext, ""); verify(updateContext).dryRun(); } | void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } @Autowired WhoisRestService(final RpslObjectDao rpslObjectDao,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext,
final AccessControlListManager accessControlListManager,
final WhoisObjectMapper whoisObjectMapper,
final InternalUpdatePerformer updatePerformer,
final SsoTranslator ssoTranslator,
final LoggerContext loggerContext,
final AuthoritativeResourceData authoritativeResourceData,
@Value("${api.rest.baseurl}") final String baseUrl); } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } @Autowired WhoisRestService(final RpslObjectDao rpslObjectDao,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext,
final AccessControlListManager accessControlListManager,
final WhoisObjectMapper whoisObjectMapper,
final InternalUpdatePerformer updatePerformer,
final SsoTranslator ssoTranslator,
final LoggerContext loggerContext,
final AuthoritativeResourceData authoritativeResourceData,
@Value("${api.rest.baseurl}") final String baseUrl); @DELETE @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response delete(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("reason") @DefaultValue("--") final String reason,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun); @PUT @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response update(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @POST @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}") Response create(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response lookup(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("unformatted") final String unformatted,
@QueryParam("unfiltered") final String unfiltered,
@QueryParam("managed-attributes") final String managedAttributes,
@QueryParam("resource-holder") final String resourceHolder,
@QueryParam("abuse-contact") final String abuseContact); } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } @Autowired WhoisRestService(final RpslObjectDao rpslObjectDao,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext,
final AccessControlListManager accessControlListManager,
final WhoisObjectMapper whoisObjectMapper,
final InternalUpdatePerformer updatePerformer,
final SsoTranslator ssoTranslator,
final LoggerContext loggerContext,
final AuthoritativeResourceData authoritativeResourceData,
@Value("${api.rest.baseurl}") final String baseUrl); @DELETE @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response delete(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("reason") @DefaultValue("--") final String reason,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun); @PUT @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response update(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @POST @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}") Response create(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response lookup(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("unformatted") final String unformatted,
@QueryParam("unfiltered") final String unfiltered,
@QueryParam("managed-attributes") final String managedAttributes,
@QueryParam("resource-holder") final String resourceHolder,
@QueryParam("abuse-contact") final String abuseContact); } |
@Test public void dryRun_true() { subject.setDryRun(updateContext, "tRuE"); verify(updateContext).dryRun(); } | void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } @Autowired WhoisRestService(final RpslObjectDao rpslObjectDao,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext,
final AccessControlListManager accessControlListManager,
final WhoisObjectMapper whoisObjectMapper,
final InternalUpdatePerformer updatePerformer,
final SsoTranslator ssoTranslator,
final LoggerContext loggerContext,
final AuthoritativeResourceData authoritativeResourceData,
@Value("${api.rest.baseurl}") final String baseUrl); } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } @Autowired WhoisRestService(final RpslObjectDao rpslObjectDao,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext,
final AccessControlListManager accessControlListManager,
final WhoisObjectMapper whoisObjectMapper,
final InternalUpdatePerformer updatePerformer,
final SsoTranslator ssoTranslator,
final LoggerContext loggerContext,
final AuthoritativeResourceData authoritativeResourceData,
@Value("${api.rest.baseurl}") final String baseUrl); @DELETE @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response delete(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("reason") @DefaultValue("--") final String reason,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun); @PUT @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response update(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @POST @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}") Response create(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response lookup(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("unformatted") final String unformatted,
@QueryParam("unfiltered") final String unfiltered,
@QueryParam("managed-attributes") final String managedAttributes,
@QueryParam("resource-holder") final String resourceHolder,
@QueryParam("abuse-contact") final String abuseContact); } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } @Autowired WhoisRestService(final RpslObjectDao rpslObjectDao,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext,
final AccessControlListManager accessControlListManager,
final WhoisObjectMapper whoisObjectMapper,
final InternalUpdatePerformer updatePerformer,
final SsoTranslator ssoTranslator,
final LoggerContext loggerContext,
final AuthoritativeResourceData authoritativeResourceData,
@Value("${api.rest.baseurl}") final String baseUrl); @DELETE @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response delete(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("reason") @DefaultValue("--") final String reason,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun); @PUT @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response update(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @POST @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}") Response create(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response lookup(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("unformatted") final String unformatted,
@QueryParam("unfiltered") final String unfiltered,
@QueryParam("managed-attributes") final String managedAttributes,
@QueryParam("resource-holder") final String resourceHolder,
@QueryParam("abuse-contact") final String abuseContact); } |
@Test public void dryRun_whatever() { subject.setDryRun(updateContext, "whatever"); verify(updateContext, never()).dryRun(); } | void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } @Autowired WhoisRestService(final RpslObjectDao rpslObjectDao,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext,
final AccessControlListManager accessControlListManager,
final WhoisObjectMapper whoisObjectMapper,
final InternalUpdatePerformer updatePerformer,
final SsoTranslator ssoTranslator,
final LoggerContext loggerContext,
final AuthoritativeResourceData authoritativeResourceData,
@Value("${api.rest.baseurl}") final String baseUrl); } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } @Autowired WhoisRestService(final RpslObjectDao rpslObjectDao,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext,
final AccessControlListManager accessControlListManager,
final WhoisObjectMapper whoisObjectMapper,
final InternalUpdatePerformer updatePerformer,
final SsoTranslator ssoTranslator,
final LoggerContext loggerContext,
final AuthoritativeResourceData authoritativeResourceData,
@Value("${api.rest.baseurl}") final String baseUrl); @DELETE @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response delete(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("reason") @DefaultValue("--") final String reason,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun); @PUT @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response update(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @POST @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}") Response create(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response lookup(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("unformatted") final String unformatted,
@QueryParam("unfiltered") final String unfiltered,
@QueryParam("managed-attributes") final String managedAttributes,
@QueryParam("resource-holder") final String resourceHolder,
@QueryParam("abuse-contact") final String abuseContact); } | WhoisRestService { void setDryRun(final UpdateContext updateContext, final String dryRun) { if (isQueryParamSet(dryRun)) { updateContext.dryRun(); } } @Autowired WhoisRestService(final RpslObjectDao rpslObjectDao,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext,
final AccessControlListManager accessControlListManager,
final WhoisObjectMapper whoisObjectMapper,
final InternalUpdatePerformer updatePerformer,
final SsoTranslator ssoTranslator,
final LoggerContext loggerContext,
final AuthoritativeResourceData authoritativeResourceData,
@Value("${api.rest.baseurl}") final String baseUrl); @DELETE @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response delete(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("reason") @DefaultValue("--") final String reason,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun); @PUT @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response update(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @POST @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}") Response create(
final WhoisResources resource,
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("override") final String override,
@QueryParam("dry-run") final String dryRun,
@QueryParam("unformatted") final String unformatted); @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/{source}/{objectType}/{key:.*}") Response lookup(
@Context final HttpServletRequest request,
@PathParam("source") final String source,
@PathParam("objectType") final String objectType,
@PathParam("key") final String key,
@QueryParam("password") final List<String> passwords,
@CookieParam("crowd.token_key") final String crowdTokenKey,
@QueryParam("unformatted") final String unformatted,
@QueryParam("unfiltered") final String unfiltered,
@QueryParam("managed-attributes") final String managedAttributes,
@QueryParam("resource-holder") final String resourceHolder,
@QueryParam("abuse-contact") final String abuseContact); } |
@Test public void getId() { assertThat(subject.getId(), is("127.0.0.1")); } | @Override public String getId() { return remoteAddress; } | WhoisRestApi implements Origin { @Override public String getId() { return remoteAddress; } } | WhoisRestApi implements Origin { @Override public String getId() { return remoteAddress; } WhoisRestApi(final DateTimeProvider dateTimeProvider, final String remoteAddress); } | WhoisRestApi implements Origin { @Override public String getId() { return remoteAddress; } WhoisRestApi(final DateTimeProvider dateTimeProvider, final String remoteAddress); @Override boolean isDefaultOverride(); @Override boolean allowAdminOperations(); @Override String getId(); @Override String getFrom(); @Override String getResponseHeader(); @Override String getNotificationHeader(); @Override String getName(); @Override String toString(); } | WhoisRestApi implements Origin { @Override public String getId() { return remoteAddress; } WhoisRestApi(final DateTimeProvider dateTimeProvider, final String remoteAddress); @Override boolean isDefaultOverride(); @Override boolean allowAdminOperations(); @Override String getId(); @Override String getFrom(); @Override String getResponseHeader(); @Override String getNotificationHeader(); @Override String getName(); @Override String toString(); } |
@Test public void getFrom() { assertThat(subject.getFrom(), is("127.0.0.1")); } | @Override public String getFrom() { return remoteAddress; } | WhoisRestApi implements Origin { @Override public String getFrom() { return remoteAddress; } } | WhoisRestApi implements Origin { @Override public String getFrom() { return remoteAddress; } WhoisRestApi(final DateTimeProvider dateTimeProvider, final String remoteAddress); } | WhoisRestApi implements Origin { @Override public String getFrom() { return remoteAddress; } WhoisRestApi(final DateTimeProvider dateTimeProvider, final String remoteAddress); @Override boolean isDefaultOverride(); @Override boolean allowAdminOperations(); @Override String getId(); @Override String getFrom(); @Override String getResponseHeader(); @Override String getNotificationHeader(); @Override String getName(); @Override String toString(); } | WhoisRestApi implements Origin { @Override public String getFrom() { return remoteAddress; } WhoisRestApi(final DateTimeProvider dateTimeProvider, final String remoteAddress); @Override boolean isDefaultOverride(); @Override boolean allowAdminOperations(); @Override String getId(); @Override String getFrom(); @Override String getResponseHeader(); @Override String getNotificationHeader(); @Override String getName(); @Override String toString(); } |
@Test public void getName() { assertThat(subject.getName(), is("rest api")); } | @Override public String getName() { return "rest api"; } | WhoisRestApi implements Origin { @Override public String getName() { return "rest api"; } } | WhoisRestApi implements Origin { @Override public String getName() { return "rest api"; } WhoisRestApi(final DateTimeProvider dateTimeProvider, final String remoteAddress); } | WhoisRestApi implements Origin { @Override public String getName() { return "rest api"; } WhoisRestApi(final DateTimeProvider dateTimeProvider, final String remoteAddress); @Override boolean isDefaultOverride(); @Override boolean allowAdminOperations(); @Override String getId(); @Override String getFrom(); @Override String getResponseHeader(); @Override String getNotificationHeader(); @Override String getName(); @Override String toString(); } | WhoisRestApi implements Origin { @Override public String getName() { return "rest api"; } WhoisRestApi(final DateTimeProvider dateTimeProvider, final String remoteAddress); @Override boolean isDefaultOverride(); @Override boolean allowAdminOperations(); @Override String getId(); @Override String getFrom(); @Override String getResponseHeader(); @Override String getNotificationHeader(); @Override String getName(); @Override String toString(); } |
@Test public void response_header_for_any_request() { when(dateTimeProvider.getCurrentDateTime()).thenReturn(LocalDateTime.of(2013, 3, 3, 12, 55)); assertThat(subject.getResponseHeader(), is(" - From-Host: 127.0.0.1\n - Date/Time: Sun Mar 3 12:55:00 2013\n")); } | @Override public String getResponseHeader() { return getHeader(); } | WhoisRestApi implements Origin { @Override public String getResponseHeader() { return getHeader(); } } | WhoisRestApi implements Origin { @Override public String getResponseHeader() { return getHeader(); } WhoisRestApi(final DateTimeProvider dateTimeProvider, final String remoteAddress); } | WhoisRestApi implements Origin { @Override public String getResponseHeader() { return getHeader(); } WhoisRestApi(final DateTimeProvider dateTimeProvider, final String remoteAddress); @Override boolean isDefaultOverride(); @Override boolean allowAdminOperations(); @Override String getId(); @Override String getFrom(); @Override String getResponseHeader(); @Override String getNotificationHeader(); @Override String getName(); @Override String toString(); } | WhoisRestApi implements Origin { @Override public String getResponseHeader() { return getHeader(); } WhoisRestApi(final DateTimeProvider dateTimeProvider, final String remoteAddress); @Override boolean isDefaultOverride(); @Override boolean allowAdminOperations(); @Override String getId(); @Override String getFrom(); @Override String getResponseHeader(); @Override String getNotificationHeader(); @Override String getName(); @Override String toString(); } |
@Test public void notification_header_for_any_request() { when(dateTimeProvider.getCurrentDateTime()).thenReturn(LocalDateTime.of(2013, 3, 3, 12, 55)); assertThat(subject.getNotificationHeader(), is(" - From-Host: 127.0.0.1\n - Date/Time: Sun Mar 3 12:55:00 2013\n")); } | @Override public String getNotificationHeader() { return getHeader(); } | WhoisRestApi implements Origin { @Override public String getNotificationHeader() { return getHeader(); } } | WhoisRestApi implements Origin { @Override public String getNotificationHeader() { return getHeader(); } WhoisRestApi(final DateTimeProvider dateTimeProvider, final String remoteAddress); } | WhoisRestApi implements Origin { @Override public String getNotificationHeader() { return getHeader(); } WhoisRestApi(final DateTimeProvider dateTimeProvider, final String remoteAddress); @Override boolean isDefaultOverride(); @Override boolean allowAdminOperations(); @Override String getId(); @Override String getFrom(); @Override String getResponseHeader(); @Override String getNotificationHeader(); @Override String getName(); @Override String toString(); } | WhoisRestApi implements Origin { @Override public String getNotificationHeader() { return getHeader(); } WhoisRestApi(final DateTimeProvider dateTimeProvider, final String remoteAddress); @Override boolean isDefaultOverride(); @Override boolean allowAdminOperations(); @Override String getId(); @Override String getFrom(); @Override String getResponseHeader(); @Override String getNotificationHeader(); @Override String getName(); @Override String toString(); } |
@Test public void search_disallowedFlags() { final List<String> disallowedFlags = ImmutableList.of("t", "template", "v", "verbose", "V", "client", "G", "no-grouping", "no-tag-info", "show-tag-info", "a", "all-sources", "q", "list-sources", "diff-versions", "list-versions", "show-version", "k", "persistent-connection"); for (String disallowedFlag : disallowedFlags) { try { subject.search( request, Sets.newHashSet("TEST"), "AARDVARK-MNT", Collections.EMPTY_SET, Collections.EMPTY_SET, Collections.EMPTY_SET, Collections.EMPTY_SET, Sets.newHashSet(disallowedFlag), null, null, null, null, null, null); fail("Disallowed option " + disallowedFlag + " did not throw error"); } catch (WebApplicationException e) { assertThat(((WhoisResources)e.getResponse().getEntity()).getErrorMessages().get(0).getText(), is("Disallowed search flag '%s'")); } } } | @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/search") public Response search( @Context final HttpServletRequest request, @QueryParam("source") final Set<String> sources, @QueryParam("query-string") final String searchKey, @QueryParam("inverse-attribute") final Set<String> inverseAttributes, @QueryParam("include-tag") final Set<String> includeTags, @QueryParam("exclude-tag") final Set<String> excludeTags, @QueryParam("type-filter") final Set<String> types, @QueryParam("flags") final Set<String> flags, @QueryParam("unformatted") final String unformatted, @QueryParam("managed-attributes") final String managedAttributes, @QueryParam("resource-holder") final String resourceHolder, @QueryParam("abuse-contact") final String abuseContact, @QueryParam("limit") final Integer limit, @QueryParam("offset") final Integer offset) { validateSources(request, sources); validateSearchKey(request, searchKey); final Set<QueryFlag> separateFlags = splitInputFlags(request, flags); checkForInvalidFlags(request, separateFlags); final QueryBuilder queryBuilder = new QueryBuilder(); queryBuilder.addFlag(QueryFlag.SHOW_TAG_INFO); queryBuilder.addCommaList(QueryFlag.SOURCES, sources); queryBuilder.addCommaList(QueryFlag.SELECT_TYPES, types); queryBuilder.addCommaList(QueryFlag.INVERSE, inverseAttributes); queryBuilder.addCommaList(QueryFlag.FILTER_TAG_INCLUDE, includeTags); queryBuilder.addCommaList(QueryFlag.FILTER_TAG_EXCLUDE, excludeTags); for (QueryFlag separateFlag : separateFlags) { queryBuilder.addFlag(separateFlag); } final Query query = Query.parse(queryBuilder.build(searchKey), Query.Origin.REST, isTrusted(request)); final Parameters parameters = new Parameters.Builder() .inverseAttributes(new InverseAttributes(inverseAttributes)) .typeFilters(new TypeFilters(types)) .flags(new Flags(separateFlags)) .queryStrings(new QueryStrings(new QueryString(searchKey))) .sources(new Sources(sources)) .managedAttributes(isQueryParamSet(managedAttributes)) .resourceHolder(isQueryParamSet(resourceHolder)) .abuseContact(isQueryParamSet(abuseContact)) .limit(limit) .offset(offset) .unformatted(isQueryParamSet(unformatted)) .build(); return rpslObjectStreamer.handleQueryAndStreamResponse( query, request, InetAddresses.forString(request.getRemoteAddr()), parameters, SEARCH_SERVICE); } | WhoisSearchService { @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/search") public Response search( @Context final HttpServletRequest request, @QueryParam("source") final Set<String> sources, @QueryParam("query-string") final String searchKey, @QueryParam("inverse-attribute") final Set<String> inverseAttributes, @QueryParam("include-tag") final Set<String> includeTags, @QueryParam("exclude-tag") final Set<String> excludeTags, @QueryParam("type-filter") final Set<String> types, @QueryParam("flags") final Set<String> flags, @QueryParam("unformatted") final String unformatted, @QueryParam("managed-attributes") final String managedAttributes, @QueryParam("resource-holder") final String resourceHolder, @QueryParam("abuse-contact") final String abuseContact, @QueryParam("limit") final Integer limit, @QueryParam("offset") final Integer offset) { validateSources(request, sources); validateSearchKey(request, searchKey); final Set<QueryFlag> separateFlags = splitInputFlags(request, flags); checkForInvalidFlags(request, separateFlags); final QueryBuilder queryBuilder = new QueryBuilder(); queryBuilder.addFlag(QueryFlag.SHOW_TAG_INFO); queryBuilder.addCommaList(QueryFlag.SOURCES, sources); queryBuilder.addCommaList(QueryFlag.SELECT_TYPES, types); queryBuilder.addCommaList(QueryFlag.INVERSE, inverseAttributes); queryBuilder.addCommaList(QueryFlag.FILTER_TAG_INCLUDE, includeTags); queryBuilder.addCommaList(QueryFlag.FILTER_TAG_EXCLUDE, excludeTags); for (QueryFlag separateFlag : separateFlags) { queryBuilder.addFlag(separateFlag); } final Query query = Query.parse(queryBuilder.build(searchKey), Query.Origin.REST, isTrusted(request)); final Parameters parameters = new Parameters.Builder() .inverseAttributes(new InverseAttributes(inverseAttributes)) .typeFilters(new TypeFilters(types)) .flags(new Flags(separateFlags)) .queryStrings(new QueryStrings(new QueryString(searchKey))) .sources(new Sources(sources)) .managedAttributes(isQueryParamSet(managedAttributes)) .resourceHolder(isQueryParamSet(resourceHolder)) .abuseContact(isQueryParamSet(abuseContact)) .limit(limit) .offset(offset) .unformatted(isQueryParamSet(unformatted)) .build(); return rpslObjectStreamer.handleQueryAndStreamResponse( query, request, InetAddresses.forString(request.getRemoteAddr()), parameters, SEARCH_SERVICE); } } | WhoisSearchService { @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/search") public Response search( @Context final HttpServletRequest request, @QueryParam("source") final Set<String> sources, @QueryParam("query-string") final String searchKey, @QueryParam("inverse-attribute") final Set<String> inverseAttributes, @QueryParam("include-tag") final Set<String> includeTags, @QueryParam("exclude-tag") final Set<String> excludeTags, @QueryParam("type-filter") final Set<String> types, @QueryParam("flags") final Set<String> flags, @QueryParam("unformatted") final String unformatted, @QueryParam("managed-attributes") final String managedAttributes, @QueryParam("resource-holder") final String resourceHolder, @QueryParam("abuse-contact") final String abuseContact, @QueryParam("limit") final Integer limit, @QueryParam("offset") final Integer offset) { validateSources(request, sources); validateSearchKey(request, searchKey); final Set<QueryFlag> separateFlags = splitInputFlags(request, flags); checkForInvalidFlags(request, separateFlags); final QueryBuilder queryBuilder = new QueryBuilder(); queryBuilder.addFlag(QueryFlag.SHOW_TAG_INFO); queryBuilder.addCommaList(QueryFlag.SOURCES, sources); queryBuilder.addCommaList(QueryFlag.SELECT_TYPES, types); queryBuilder.addCommaList(QueryFlag.INVERSE, inverseAttributes); queryBuilder.addCommaList(QueryFlag.FILTER_TAG_INCLUDE, includeTags); queryBuilder.addCommaList(QueryFlag.FILTER_TAG_EXCLUDE, excludeTags); for (QueryFlag separateFlag : separateFlags) { queryBuilder.addFlag(separateFlag); } final Query query = Query.parse(queryBuilder.build(searchKey), Query.Origin.REST, isTrusted(request)); final Parameters parameters = new Parameters.Builder() .inverseAttributes(new InverseAttributes(inverseAttributes)) .typeFilters(new TypeFilters(types)) .flags(new Flags(separateFlags)) .queryStrings(new QueryStrings(new QueryString(searchKey))) .sources(new Sources(sources)) .managedAttributes(isQueryParamSet(managedAttributes)) .resourceHolder(isQueryParamSet(resourceHolder)) .abuseContact(isQueryParamSet(abuseContact)) .limit(limit) .offset(offset) .unformatted(isQueryParamSet(unformatted)) .build(); return rpslObjectStreamer.handleQueryAndStreamResponse( query, request, InetAddresses.forString(request.getRemoteAddr()), parameters, SEARCH_SERVICE); } @Autowired WhoisSearchService(
final AccessControlListManager accessControlListManager,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext); } | WhoisSearchService { @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/search") public Response search( @Context final HttpServletRequest request, @QueryParam("source") final Set<String> sources, @QueryParam("query-string") final String searchKey, @QueryParam("inverse-attribute") final Set<String> inverseAttributes, @QueryParam("include-tag") final Set<String> includeTags, @QueryParam("exclude-tag") final Set<String> excludeTags, @QueryParam("type-filter") final Set<String> types, @QueryParam("flags") final Set<String> flags, @QueryParam("unformatted") final String unformatted, @QueryParam("managed-attributes") final String managedAttributes, @QueryParam("resource-holder") final String resourceHolder, @QueryParam("abuse-contact") final String abuseContact, @QueryParam("limit") final Integer limit, @QueryParam("offset") final Integer offset) { validateSources(request, sources); validateSearchKey(request, searchKey); final Set<QueryFlag> separateFlags = splitInputFlags(request, flags); checkForInvalidFlags(request, separateFlags); final QueryBuilder queryBuilder = new QueryBuilder(); queryBuilder.addFlag(QueryFlag.SHOW_TAG_INFO); queryBuilder.addCommaList(QueryFlag.SOURCES, sources); queryBuilder.addCommaList(QueryFlag.SELECT_TYPES, types); queryBuilder.addCommaList(QueryFlag.INVERSE, inverseAttributes); queryBuilder.addCommaList(QueryFlag.FILTER_TAG_INCLUDE, includeTags); queryBuilder.addCommaList(QueryFlag.FILTER_TAG_EXCLUDE, excludeTags); for (QueryFlag separateFlag : separateFlags) { queryBuilder.addFlag(separateFlag); } final Query query = Query.parse(queryBuilder.build(searchKey), Query.Origin.REST, isTrusted(request)); final Parameters parameters = new Parameters.Builder() .inverseAttributes(new InverseAttributes(inverseAttributes)) .typeFilters(new TypeFilters(types)) .flags(new Flags(separateFlags)) .queryStrings(new QueryStrings(new QueryString(searchKey))) .sources(new Sources(sources)) .managedAttributes(isQueryParamSet(managedAttributes)) .resourceHolder(isQueryParamSet(resourceHolder)) .abuseContact(isQueryParamSet(abuseContact)) .limit(limit) .offset(offset) .unformatted(isQueryParamSet(unformatted)) .build(); return rpslObjectStreamer.handleQueryAndStreamResponse( query, request, InetAddresses.forString(request.getRemoteAddr()), parameters, SEARCH_SERVICE); } @Autowired WhoisSearchService(
final AccessControlListManager accessControlListManager,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext); @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/search") Response search(
@Context final HttpServletRequest request,
@QueryParam("source") final Set<String> sources,
@QueryParam("query-string") final String searchKey,
@QueryParam("inverse-attribute") final Set<String> inverseAttributes,
@QueryParam("include-tag") final Set<String> includeTags,
@QueryParam("exclude-tag") final Set<String> excludeTags,
@QueryParam("type-filter") final Set<String> types,
@QueryParam("flags") final Set<String> flags,
@QueryParam("unformatted") final String unformatted,
@QueryParam("managed-attributes") final String managedAttributes,
@QueryParam("resource-holder") final String resourceHolder,
@QueryParam("abuse-contact") final String abuseContact,
@QueryParam("limit") final Integer limit,
@QueryParam("offset") final Integer offset); } | WhoisSearchService { @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/search") public Response search( @Context final HttpServletRequest request, @QueryParam("source") final Set<String> sources, @QueryParam("query-string") final String searchKey, @QueryParam("inverse-attribute") final Set<String> inverseAttributes, @QueryParam("include-tag") final Set<String> includeTags, @QueryParam("exclude-tag") final Set<String> excludeTags, @QueryParam("type-filter") final Set<String> types, @QueryParam("flags") final Set<String> flags, @QueryParam("unformatted") final String unformatted, @QueryParam("managed-attributes") final String managedAttributes, @QueryParam("resource-holder") final String resourceHolder, @QueryParam("abuse-contact") final String abuseContact, @QueryParam("limit") final Integer limit, @QueryParam("offset") final Integer offset) { validateSources(request, sources); validateSearchKey(request, searchKey); final Set<QueryFlag> separateFlags = splitInputFlags(request, flags); checkForInvalidFlags(request, separateFlags); final QueryBuilder queryBuilder = new QueryBuilder(); queryBuilder.addFlag(QueryFlag.SHOW_TAG_INFO); queryBuilder.addCommaList(QueryFlag.SOURCES, sources); queryBuilder.addCommaList(QueryFlag.SELECT_TYPES, types); queryBuilder.addCommaList(QueryFlag.INVERSE, inverseAttributes); queryBuilder.addCommaList(QueryFlag.FILTER_TAG_INCLUDE, includeTags); queryBuilder.addCommaList(QueryFlag.FILTER_TAG_EXCLUDE, excludeTags); for (QueryFlag separateFlag : separateFlags) { queryBuilder.addFlag(separateFlag); } final Query query = Query.parse(queryBuilder.build(searchKey), Query.Origin.REST, isTrusted(request)); final Parameters parameters = new Parameters.Builder() .inverseAttributes(new InverseAttributes(inverseAttributes)) .typeFilters(new TypeFilters(types)) .flags(new Flags(separateFlags)) .queryStrings(new QueryStrings(new QueryString(searchKey))) .sources(new Sources(sources)) .managedAttributes(isQueryParamSet(managedAttributes)) .resourceHolder(isQueryParamSet(resourceHolder)) .abuseContact(isQueryParamSet(abuseContact)) .limit(limit) .offset(offset) .unformatted(isQueryParamSet(unformatted)) .build(); return rpslObjectStreamer.handleQueryAndStreamResponse( query, request, InetAddresses.forString(request.getRemoteAddr()), parameters, SEARCH_SERVICE); } @Autowired WhoisSearchService(
final AccessControlListManager accessControlListManager,
final RpslObjectStreamer rpslObjectStreamer,
final SourceContext sourceContext); @GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("/search") Response search(
@Context final HttpServletRequest request,
@QueryParam("source") final Set<String> sources,
@QueryParam("query-string") final String searchKey,
@QueryParam("inverse-attribute") final Set<String> inverseAttributes,
@QueryParam("include-tag") final Set<String> includeTags,
@QueryParam("exclude-tag") final Set<String> excludeTags,
@QueryParam("type-filter") final Set<String> types,
@QueryParam("flags") final Set<String> flags,
@QueryParam("unformatted") final String unformatted,
@QueryParam("managed-attributes") final String managedAttributes,
@QueryParam("resource-holder") final String resourceHolder,
@QueryParam("abuse-contact") final String abuseContact,
@QueryParam("limit") final Integer limit,
@QueryParam("offset") final Integer offset); } |
@Test public void map_rpslAttribute_lacking_attributeType() { final Collection<Attribute> attributes = subject.map( new RpslAttribute("key", CIString.ciString("value")), "TEST"); assertThat(attributes, hasSize(1)); final Attribute attribute = attributes.iterator().next(); assertThat(attribute.getLink(), is(nullValue())); assertThat(attribute.getValue(), is("value")); assertThat(attribute.getName(), is("key")); } | @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } | FormattedServerAttributeMapper implements FormattedAttributeMapper { @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } } | FormattedServerAttributeMapper implements FormattedAttributeMapper { @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } @Autowired FormattedServerAttributeMapper(final ReferencedTypeResolver referencedTypeResolver,
final SourceResolver sourceResolver,
@Value("${api.rest.baseurl}") final String baseUrl); } | FormattedServerAttributeMapper implements FormattedAttributeMapper { @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } @Autowired FormattedServerAttributeMapper(final ReferencedTypeResolver referencedTypeResolver,
final SourceResolver sourceResolver,
@Value("${api.rest.baseurl}") final String baseUrl); @Override Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source); } | FormattedServerAttributeMapper implements FormattedAttributeMapper { @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } @Autowired FormattedServerAttributeMapper(final ReferencedTypeResolver referencedTypeResolver,
final SourceResolver sourceResolver,
@Value("${api.rest.baseurl}") final String baseUrl); @Override Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source); } |
@Test public void dummify_removes_double_person_role_references() { final ArrayList<RpslAttribute> attributes = Lists.newArrayList(createObject(ObjectType.INETNUM, "10.0.0.0").getAttributes()); final String tempValue = "VALUE"; for (AttributeType personRoleReference : DummifierNrtm.PERSON_ROLE_REFERENCES) { final RpslAttribute attribute = new RpslAttribute(personRoleReference.getName(), tempValue); attributes.add(attribute); attributes.add(attribute); } assertThat(attributes, hasSize(3 + 2 * DummifierNrtm.PERSON_ROLE_REFERENCES.size())); attributes.add(new RpslAttribute(AttributeType.SOURCE, "TEST")); final RpslObject rpslObject = new RpslObject(0, attributes); final RpslObject dummifiedObject = subject.dummify(3, rpslObject); for (AttributeType personRoleReference : DummifierNrtm.PERSON_ROLE_REFERENCES) { final List<RpslAttribute> rpslAttributes = dummifiedObject.findAttributes(personRoleReference); assertThat(personRoleReference.toString(), rpslAttributes, hasSize(1)); assertThat(rpslAttributes.get(0).getValue(), is(not(tempValue))); } assertThat(dummifiedObject.findAttributes(AttributeType.CREATED, AttributeType.LAST_MODIFIED), hasSize(2)); } | public RpslObject dummify(final int version, final RpslObject rpslObject) { final ObjectType objectType = rpslObject.getType(); Validate.isTrue(isAllowed(version, rpslObject), "The given object type should be skipped", objectType); if (version <= 2 && usePlaceHolder(rpslObject)) { return objectType.equals(ObjectType.ROLE) ? getPlaceholderRoleObject() : getPlaceholderPersonObject(); } final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); stripSomeNonMandatoryAttributes(attributes, objectType); dummifyRemainingAttributes(attributes, rpslObject.getKey()); insertPlaceholder(attributes); attributes.addAll(getDummificationRemarks(rpslObject)); return new RpslObject(rpslObject, attributes); } | DummifierNrtm implements Dummifier { public RpslObject dummify(final int version, final RpslObject rpslObject) { final ObjectType objectType = rpslObject.getType(); Validate.isTrue(isAllowed(version, rpslObject), "The given object type should be skipped", objectType); if (version <= 2 && usePlaceHolder(rpslObject)) { return objectType.equals(ObjectType.ROLE) ? getPlaceholderRoleObject() : getPlaceholderPersonObject(); } final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); stripSomeNonMandatoryAttributes(attributes, objectType); dummifyRemainingAttributes(attributes, rpslObject.getKey()); insertPlaceholder(attributes); attributes.addAll(getDummificationRemarks(rpslObject)); return new RpslObject(rpslObject, attributes); } } | DummifierNrtm implements Dummifier { public RpslObject dummify(final int version, final RpslObject rpslObject) { final ObjectType objectType = rpslObject.getType(); Validate.isTrue(isAllowed(version, rpslObject), "The given object type should be skipped", objectType); if (version <= 2 && usePlaceHolder(rpslObject)) { return objectType.equals(ObjectType.ROLE) ? getPlaceholderRoleObject() : getPlaceholderPersonObject(); } final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); stripSomeNonMandatoryAttributes(attributes, objectType); dummifyRemainingAttributes(attributes, rpslObject.getKey()); insertPlaceholder(attributes); attributes.addAll(getDummificationRemarks(rpslObject)); return new RpslObject(rpslObject, attributes); } } | DummifierNrtm implements Dummifier { public RpslObject dummify(final int version, final RpslObject rpslObject) { final ObjectType objectType = rpslObject.getType(); Validate.isTrue(isAllowed(version, rpslObject), "The given object type should be skipped", objectType); if (version <= 2 && usePlaceHolder(rpslObject)) { return objectType.equals(ObjectType.ROLE) ? getPlaceholderRoleObject() : getPlaceholderPersonObject(); } final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); stripSomeNonMandatoryAttributes(attributes, objectType); dummifyRemainingAttributes(attributes, rpslObject.getKey()); insertPlaceholder(attributes); attributes.addAll(getDummificationRemarks(rpslObject)); return new RpslObject(rpslObject, attributes); } RpslObject dummify(final int version, final RpslObject rpslObject); boolean isAllowed(final int version, final RpslObject rpslObject); static RpslObject getPlaceholderPersonObject(); static RpslObject getPlaceholderRoleObject(); } | DummifierNrtm implements Dummifier { public RpslObject dummify(final int version, final RpslObject rpslObject) { final ObjectType objectType = rpslObject.getType(); Validate.isTrue(isAllowed(version, rpslObject), "The given object type should be skipped", objectType); if (version <= 2 && usePlaceHolder(rpslObject)) { return objectType.equals(ObjectType.ROLE) ? getPlaceholderRoleObject() : getPlaceholderPersonObject(); } final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); stripSomeNonMandatoryAttributes(attributes, objectType); dummifyRemainingAttributes(attributes, rpslObject.getKey()); insertPlaceholder(attributes); attributes.addAll(getDummificationRemarks(rpslObject)); return new RpslObject(rpslObject, attributes); } RpslObject dummify(final int version, final RpslObject rpslObject); boolean isAllowed(final int version, final RpslObject rpslObject); static RpslObject getPlaceholderPersonObject(); static RpslObject getPlaceholderRoleObject(); } |
@Test public void map_rpslAttribute_attributeType_given() { when(referencedTypeResolver.getReferencedType(AttributeType.NIC_HDL, CIString.ciString("TP-TEST"))).thenReturn(AttributeType.ROLE.getName()); final Collection<Attribute> attributes = subject.map( new RpslAttribute(AttributeType.NIC_HDL, CIString.ciString("TP-TEST")), "TEST"); assertThat(attributes, hasSize(1)); final Attribute attribute = attributes.iterator().next(); assertThat(attribute.getLink().toString(), is("locator: http: assertThat(attribute.getName(), is("nic-hdl")); assertThat(attribute.getValue(), is("TP-TEST")); } | @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } | FormattedServerAttributeMapper implements FormattedAttributeMapper { @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } } | FormattedServerAttributeMapper implements FormattedAttributeMapper { @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } @Autowired FormattedServerAttributeMapper(final ReferencedTypeResolver referencedTypeResolver,
final SourceResolver sourceResolver,
@Value("${api.rest.baseurl}") final String baseUrl); } | FormattedServerAttributeMapper implements FormattedAttributeMapper { @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } @Autowired FormattedServerAttributeMapper(final ReferencedTypeResolver referencedTypeResolver,
final SourceResolver sourceResolver,
@Value("${api.rest.baseurl}") final String baseUrl); @Override Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source); } | FormattedServerAttributeMapper implements FormattedAttributeMapper { @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } @Autowired FormattedServerAttributeMapper(final ReferencedTypeResolver referencedTypeResolver,
final SourceResolver sourceResolver,
@Value("${api.rest.baseurl}") final String baseUrl); @Override Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source); } |
@Test public void map_rpslAttribute_multiple_values() { when(referencedTypeResolver.getReferencedType(AttributeType.MEMBERS, CIString.ciString("AS1"))).thenReturn(AttributeType.AUT_NUM.getName()); when(referencedTypeResolver.getReferencedType(AttributeType.MEMBERS, CIString.ciString("AS2"))).thenReturn(AttributeType.AUT_NUM.getName()); when(referencedTypeResolver.getReferencedType(AttributeType.MEMBERS, CIString.ciString("AS3"))).thenReturn(AttributeType.AUT_NUM.getName()); final Collection<Attribute> attributes = subject.map(new RpslAttribute(AttributeType.MEMBERS, "AS1, AS2,AS3"), "TEST"); assertThat(attributes, contains( new Attribute("members", "AS1", null, "aut-num", new Link("locator", "http: new Attribute("members", "AS2", null, "aut-num", new Link("locator", "http: new Attribute("members", "AS3", null, "aut-num", new Link("locator", "http: )); } | @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } | FormattedServerAttributeMapper implements FormattedAttributeMapper { @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } } | FormattedServerAttributeMapper implements FormattedAttributeMapper { @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } @Autowired FormattedServerAttributeMapper(final ReferencedTypeResolver referencedTypeResolver,
final SourceResolver sourceResolver,
@Value("${api.rest.baseurl}") final String baseUrl); } | FormattedServerAttributeMapper implements FormattedAttributeMapper { @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } @Autowired FormattedServerAttributeMapper(final ReferencedTypeResolver referencedTypeResolver,
final SourceResolver sourceResolver,
@Value("${api.rest.baseurl}") final String baseUrl); @Override Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source); } | FormattedServerAttributeMapper implements FormattedAttributeMapper { @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } @Autowired FormattedServerAttributeMapper(final ReferencedTypeResolver referencedTypeResolver,
final SourceResolver sourceResolver,
@Value("${api.rest.baseurl}") final String baseUrl); @Override Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source); } |
@Test public void map_rpslAttribute_mntRoutes_prefix() { when(referencedTypeResolver.getReferencedType(AttributeType.MNT_ROUTES, CIString.ciString("OWNER-MNT {10.0.0.0/8}"))).thenReturn(AttributeType.MNTNER.getName()); final Collection<Attribute> attributes = subject.map(new RpslAttribute(AttributeType.MNT_ROUTES, "OWNER-MNT {10.0.0.0/8}"), "TEST"); assertThat(attributes, contains( new Attribute("mnt-routes", "OWNER-MNT {10.0.0.0/8}", null, "mntner", new Link("locator", "http: } | @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } | FormattedServerAttributeMapper implements FormattedAttributeMapper { @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } } | FormattedServerAttributeMapper implements FormattedAttributeMapper { @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } @Autowired FormattedServerAttributeMapper(final ReferencedTypeResolver referencedTypeResolver,
final SourceResolver sourceResolver,
@Value("${api.rest.baseurl}") final String baseUrl); } | FormattedServerAttributeMapper implements FormattedAttributeMapper { @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } @Autowired FormattedServerAttributeMapper(final ReferencedTypeResolver referencedTypeResolver,
final SourceResolver sourceResolver,
@Value("${api.rest.baseurl}") final String baseUrl); @Override Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source); } | FormattedServerAttributeMapper implements FormattedAttributeMapper { @Override public Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source) { final List<Attribute> result = Lists.newArrayList(); for (CIString value : rpslAttribute.getCleanValues()) { final String referencedType = (rpslAttribute.getType() != null) ? referencedTypeResolver.getReferencedType(rpslAttribute.getType(), value) : null; final Link link = (referencedType != null) ? Link.create(baseUrl, sourceResolver.getSource(referencedType, value, source), referencedType, getLinkValue(rpslAttribute.getType(), value)) : null; result.add(new Attribute(rpslAttribute.getKey(), value.toString(), rpslAttribute.getCleanComment(), referencedType, link, null)); } return result; } @Autowired FormattedServerAttributeMapper(final ReferencedTypeResolver referencedTypeResolver,
final SourceResolver sourceResolver,
@Value("${api.rest.baseurl}") final String baseUrl); @Override Collection<Attribute> map(final RpslAttribute rpslAttribute, final String source); } |
@Test public void map_rpsl_mntner() throws Exception { when(referencedTypeResolver.getReferencedType(AttributeType.ADMIN_C, ciString("TP1-TEST"))).thenReturn("person"); when(referencedTypeResolver.getReferencedType(AttributeType.AUTH, ciString("PGPKEY-28F6CD6C"))).thenReturn("key-cert"); when(referencedTypeResolver.getReferencedType(AttributeType.MNT_BY, ciString("TST-MNT"))).thenReturn("mntner"); final RpslObject rpslObject = RpslObject.parse( "mntner: TST-MNT\n" + "descr: MNTNER for test\n" + "admin-c: TP1-TEST\n" + "upd-to: [email protected]\n" + "auth: MD5-PW $1$d9fKeTr2$Si7YudNf4rUGmR71n/cqk/ # test\n" + "auth: PGPKEY-28F6CD6C\n" + "mnt-by: TST-MNT\n" + "source: TEST\n"); final WhoisObject whoisObject = whoisObjectMapper.map(rpslObject, FormattedServerAttributeMapper.class); assertThat(whoisObject.getType(), is("mntner")); assertThat(whoisObject.getSource().getId(), is("test")); assertThat(whoisObject.getLink().getType(), is("locator")); assertThat(whoisObject.getLink().getHref(), is("http: assertThat(whoisObject.getPrimaryKey(), hasSize(1)); final Attribute primaryKeyAttribute = whoisObject.getPrimaryKey().get(0); assertThat(primaryKeyAttribute.getName(), is("mntner")); assertThat(primaryKeyAttribute.getValue(), is("TST-MNT")); assertThat(whoisObject.getAttributes(), contains( new Attribute("mntner", "TST-MNT", null, null, null, null), new Attribute("descr", "MNTNER for test", null, null, null, null), new Attribute("admin-c", "TP1-TEST", null, "person", Link.create("http: new Attribute("upd-to", "[email protected]", null, null, null, null), new Attribute("auth", "MD5-PW $1$d9fKeTr2$Si7YudNf4rUGmR71n/cqk/", "test", null, null, null), new Attribute("auth", "PGPKEY-28F6CD6C", null, "key-cert", Link.create("http: new Attribute("mnt-by", "TST-MNT", null, "mntner", Link.create("http: new Attribute("source", "TEST", null, null, null, null) )); } | public WhoisObject map(final RpslObject rpslObject, final Parameters parameters) { final Class<? extends AttributeMapper> attributeMapper = getServerAttributeMapper(Boolean.TRUE.equals(parameters.getUnformatted())); return whoisObjectMapper.map(rpslObject, attributeMapper); } | WhoisObjectServerMapper { public WhoisObject map(final RpslObject rpslObject, final Parameters parameters) { final Class<? extends AttributeMapper> attributeMapper = getServerAttributeMapper(Boolean.TRUE.equals(parameters.getUnformatted())); return whoisObjectMapper.map(rpslObject, attributeMapper); } } | WhoisObjectServerMapper { public WhoisObject map(final RpslObject rpslObject, final Parameters parameters) { final Class<? extends AttributeMapper> attributeMapper = getServerAttributeMapper(Boolean.TRUE.equals(parameters.getUnformatted())); return whoisObjectMapper.map(rpslObject, attributeMapper); } @Autowired WhoisObjectServerMapper(
final WhoisObjectMapper whoisObjectMapper,
final ResourceHolderSearch resourceHolderSearch,
final AbuseContactSearch abuseContactSearch,
final ManagedAttributeSearch managedAttributeSearch); } | WhoisObjectServerMapper { public WhoisObject map(final RpslObject rpslObject, final Parameters parameters) { final Class<? extends AttributeMapper> attributeMapper = getServerAttributeMapper(Boolean.TRUE.equals(parameters.getUnformatted())); return whoisObjectMapper.map(rpslObject, attributeMapper); } @Autowired WhoisObjectServerMapper(
final WhoisObjectMapper whoisObjectMapper,
final ResourceHolderSearch resourceHolderSearch,
final AbuseContactSearch abuseContactSearch,
final ManagedAttributeSearch managedAttributeSearch); List<WhoisVersion> mapVersions(final List<DeletedVersionResponseObject> deleted, final List<VersionResponseObject> versions); WhoisObject map(final RpslObject rpslObject, final Parameters parameters); void mapTags(final WhoisObject whoisObject, final TagResponseObject tagResponseObject); void mapResourceHolder(final WhoisObject whoisObject, final Parameters parameters, final RpslObject rpslObject); void mapAbuseContact(final WhoisObject whoisObject, final Parameters parameters, final RpslObject rpslObject); void mapManagedAttributes(final WhoisObject whoisObject, final Parameters parameters, final RpslObject rpslObject); } | WhoisObjectServerMapper { public WhoisObject map(final RpslObject rpslObject, final Parameters parameters) { final Class<? extends AttributeMapper> attributeMapper = getServerAttributeMapper(Boolean.TRUE.equals(parameters.getUnformatted())); return whoisObjectMapper.map(rpslObject, attributeMapper); } @Autowired WhoisObjectServerMapper(
final WhoisObjectMapper whoisObjectMapper,
final ResourceHolderSearch resourceHolderSearch,
final AbuseContactSearch abuseContactSearch,
final ManagedAttributeSearch managedAttributeSearch); List<WhoisVersion> mapVersions(final List<DeletedVersionResponseObject> deleted, final List<VersionResponseObject> versions); WhoisObject map(final RpslObject rpslObject, final Parameters parameters); void mapTags(final WhoisObject whoisObject, final TagResponseObject tagResponseObject); void mapResourceHolder(final WhoisObject whoisObject, final Parameters parameters, final RpslObject rpslObject); void mapAbuseContact(final WhoisObject whoisObject, final Parameters parameters, final RpslObject rpslObject); void mapManagedAttributes(final WhoisObject whoisObject, final Parameters parameters, final RpslObject rpslObject); } |
Subsets and Splits