コード例 #1
0
ファイル: SsoHelper.java プロジェクト: GaetanJUVIN/whois
  public static RpslObject translateAuth(
      final RpslObject rpslObject, final AuthTranslator authTranslator) {
    if (!rpslObject.containsAttribute(AttributeType.AUTH)) { // IRT also has auth:
      return rpslObject;
    }

    final Map<RpslAttribute, RpslAttribute> replace = Maps.newHashMap();
    for (RpslAttribute authAttribute : rpslObject.findAttributes(AttributeType.AUTH)) {
      final Iterator<String> authIterator =
          SPACE_SPLITTER.split(authAttribute.getCleanValue()).iterator();
      final String authType = authIterator.next().toUpperCase();
      if (authIterator.hasNext()) {
        final String authToken = authIterator.next();
        final RpslAttribute result = authTranslator.translate(authType, authToken, authAttribute);
        if (result != null) {
          replace.put(authAttribute, result);
        }
      }
    }

    if (replace.isEmpty()) {
      return rpslObject;
    } else {
      return new RpslObjectBuilder(rpslObject).replaceAttributes(replace).get();
    }
  }
コード例 #2
0
ファイル: JdbcRpslObjectDao.java プロジェクト: RIPE-NCC/whois
  @Override
  public Collection<RpslObjectInfo> relatedTo(
      final RpslObject identifiable, final Set<ObjectType> excludeObjectTypes) {
    final LinkedHashSet<RpslObjectInfo> result = Sets.newLinkedHashSet();

    for (final RpslAttribute attribute : identifiable.findAttributes(RELATED_TO_ATTRIBUTES)) {
      for (final CIString referenceValue : attribute.getReferenceValues()) {
        for (final ObjectType objectType : attribute.getType().getReferences(referenceValue)) {
          if (excludeObjectTypes.contains(objectType)) {
            continue;
          }

          for (RpslObjectInfo rpslObjectInfo :
              findByKeyInIndex(objectType, referenceValue.toString())) {
            if (rpslObjectInfo.getObjectId() != identifiable.getObjectId()) {
              result.add(rpslObjectInfo);
            }
          }
        }
      }
    }

    return result;
  }