Java Code Examples for io.vertx.ext.bridge.PermittedOptions#getAddressRegex()

The following examples show how to use io.vertx.ext.bridge.PermittedOptions#getAddressRegex() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TcpEventBusBridgeImpl.java    From vertx-tcp-eventbus-bridge with Apache License 2.0 5 votes vote down vote up
private boolean checkMatches(boolean inbound, String address, Map<String, Message<JsonObject>> replies) {
  // special case, when dealing with replies the addresses are not in the inbound/outbound list but on
  // the replies registry
  if (replies != null && inbound && replies.containsKey(address)) {
    return true;
  }

  List<PermittedOptions> matches = inbound ? options.getInboundPermitteds() : options.getOutboundPermitteds();

  for (PermittedOptions matchHolder : matches) {
    String matchAddress = matchHolder.getAddress();
    String matchRegex;
    if (matchAddress == null) {
      matchRegex = matchHolder.getAddressRegex();
    } else {
      matchRegex = null;
    }

    boolean addressOK;
    if (matchAddress == null) {
      addressOK = matchRegex == null || regexMatches(matchRegex, address);
    } else {
      addressOK = matchAddress.equals(address);
    }

    if (addressOK) {
      return true;
    }
  }

  return false;
}
 
Example 2
Source File: EventBusBridge.java    From vertx-stomp with Apache License 2.0 5 votes vote down vote up
private boolean checkMatches(boolean inbound, String address, Object body) {

    List<PermittedOptions> matches = inbound ? options.getInboundPermitteds() : options.getOutboundPermitteds();

    for (PermittedOptions matchHolder : matches) {
      String matchAddress = matchHolder.getAddress();
      String matchRegex;
      if (matchAddress == null) {
        matchRegex = matchHolder.getAddressRegex();
      } else {
        matchRegex = null;
      }

      boolean addressOK;
      if (matchAddress == null) {
        addressOK = matchRegex == null || regexMatches(matchRegex, address);
      } else {
        addressOK = matchAddress.equals(address);
      }

      if (addressOK) {
        return structureMatches(matchHolder.getMatch(), body);
      }
    }

    return false;
  }
 
Example 3
Source File: EventBusBridgeImpl.java    From vertx-web with Apache License 2.0 5 votes vote down vote up
private Match checkMatches(boolean inbound, String address, Object body) {

    List<PermittedOptions> matches = inbound ? inboundPermitted : outboundPermitted;

    for (PermittedOptions matchHolder : matches) {
      String matchAddress = matchHolder.getAddress();
      String matchRegex;
      if (matchAddress == null) {
        matchRegex = matchHolder.getAddressRegex();
      } else {
        matchRegex = null;
      }

      boolean addressOK;
      if (matchAddress == null) {
        addressOK = matchRegex == null || regexMatches(matchRegex, address);
      } else {
        addressOK = matchAddress.equals(address);
      }

      if (addressOK) {
        boolean matched = structureMatches(matchHolder.getMatch(), body);
        if (matched) {
          String requiredAuthority = matchHolder.getRequiredAuthority();
          return new Match(true, requiredAuthority);
        }
      }
    }
    return new Match(false);
  }