congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
InMemoryDNSService
Code IndexAdd Tabnine to your IDE (free)

How to use
InMemoryDNSService
in
org.apache.james.dnsservice.api

Best Java code snippets using org.apache.james.dnsservice.api.InMemoryDNSService (Showing top 16 results out of 315)

origin: apache/james-project

public InMemoryDNSService registerRecord(String hostname, List<InetAddress> addresses, Collection<String> mxRecords, Collection<String> txtRecords) {
  records.put(hostname, dnsRecordFor(mxRecords, txtRecords, addresses));
  return this;
}
origin: apache/james-project

private DNSRecord hostRecord(final String host) throws UnknownHostException {
  Predicate<? super Entry<String, DNSRecord>> filterByKey = entry -> entry.getKey().equals(host);
  return getDNSEntry(filterByKey).getValue();
}
origin: apache/james-project

@Override
public List<InetAddress> getAllByName(String host) throws UnknownHostException {
  return hostRecord(host).addresses;
}
origin: org.apache.james/james-server-data-library

/**
 * Return a fake DNSServer.
 */
protected DNSService getDNSServer(final String hostName) throws UnknownHostException {
  return new InMemoryDNSService()
    .registerMxRecord(hostName, "127.0.0.1")
    .registerMxRecord("127.0.0.1", "127.0.0.1");
}
origin: org.apache.james/james-server-jmap-integration-testing

@Before
public void setUp() throws Exception {
  getInMemoryDns()
    .registerMxRecord("yopmail.com", fakeSmtp.getContainer().getContainerIp());
  guiceJamesServer = getJmapServer();
  guiceJamesServer.start();
  DataProbe dataProbe = guiceJamesServer.getProbe(DataProbeImpl.class);
  dataProbe.addDomain(DOMAIN);
  dataProbe.addUser(USER_WITH_DOMAIN, PASSWORD);
  MailboxProbe mailboxProbe = guiceJamesServer.getProbe(MailboxProbeImpl.class);
  mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, USER_WITH_DOMAIN, DefaultMailboxes.SENT);
  mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, USER_WITH_DOMAIN, DefaultMailboxes.INBOX);
  await();
  jmapGuiceProbe = guiceJamesServer.getProbe(JmapGuiceProbe.class);
}
origin: apache/james-project

public InMemoryDNSService registerMxRecord(String hostname, String ip) throws UnknownHostException {
  InetAddress containerIp = InetAddress.getByName(ip);
  registerRecord(hostname, containerIp, hostname);
  return this;
}
origin: org.apache.james/james-server-mailets

@Before
public void setup() throws Exception {
  DNSService dnsServer = new InMemoryDNSService()
    .registerMxRecord("192.168.0.1", "192.168.0.1")
    .registerMxRecord("192.168.200.1", "192.168.200.1")
    .registerMxRecord("192.168.200.0", "192.168.200.0")
    .registerMxRecord("255.255.255.0", "255.255.255.0");
  matcherConfig = FakeMatcherConfig.builder()
      .matcherName("AllowedNetworkIs")
      .condition("192.168.200.0/24")
      .build();
  matcher = new RemoteAddrNotInNetwork();
  matcher.setDNSService(dnsServer);
  matcher.init(matcherConfig);
  testRecipient = new MailAddress("test@james.apache.org");
}
origin: apache/james-project

public InMemoryDNSService registerRecord(String hostname, InetAddress address, String mxRecord) {
  Collection<String> emptyTxtRecords = ImmutableList.of();
  registerRecord(hostname, ImmutableList.of(address), ImmutableList.of(mxRecord), emptyTxtRecords);
  return this;
}
origin: org.apache.james/james-server-mailets

@Before
public void setup() throws Exception {
  DNSService dnsServer = new InMemoryDNSService()
    .registerMxRecord("192.168.0.1", "192.168.0.1")
    .registerMxRecord("192.168.200.1", "192.168.200.1")
    .registerMxRecord("192.168.200.0", "192.168.200.0")
    .registerMxRecord("255.255.255.0", "255.255.255.0");
  FakeMatcherConfig matcherConfig = FakeMatcherConfig.builder()
      .matcherName("AllowedNetworkIs")
      .condition("192.168.200.0/24")
      .build();
  matcher = new RemoteAddrInNetwork();
  matcher.setDNSService(dnsServer);
  matcher.init(matcherConfig);
  testRecipient = new MailAddress("test@james.apache.org");
}
origin: apache/james-project

@Override
public Collection<String> findMXRecords(String hostname) throws TemporaryResolutionException {
  try {
    return hostRecord(hostname).mxRecords;
  } catch (UnknownHostException e) {
    throw new RuntimeException(e);
  }
}
origin: apache/james-project

private DNSRecord dnsRecordFor(InetAddress addresses) {
  Collection<String> emptyList = ImmutableList.of();
  return dnsRecordFor(emptyList, emptyList, ImmutableList.of(addresses));
}
origin: apache/james-project

@Override
public String getHostName(final InetAddress addr) {
  Predicate<? super Entry<String, DNSRecord>> filterByValue = entry -> entry.getValue().contains(addr);
  try {
    return getDNSEntry(filterByValue).getKey();
  } catch (UnknownHostException e) {
    throw new RuntimeException(e);
  }
}
origin: org.apache.james/james-server-protocols-smtp

  @Test
  public void testRejectLoopbackMX() throws Exception {
    String bannedAddress = "172.53.64.2";

    DNSService dns = new InMemoryDNSService()
      .registerMxRecord(INVALID_HOST, bannedAddress)
      .registerMxRecord("255.255.255.255", "255.255.255.255")
      .registerMxRecord(bannedAddress, bannedAddress);
    MailAddress mailAddress = new MailAddress("test@" + INVALID_HOST);
    SMTPSession session = setupMockedSMTPSession(mailAddress);

    ValidRcptMX handler = new ValidRcptMX();
    handler.setDNSService(dns);
    handler.setBannedNetworks(ImmutableList.of(bannedAddress), dns);
    HookReturnCode rCode = handler.doRcpt(session, null, mailAddress).getResult();

    assertThat(HookReturnCode.deny()).describedAs("Reject").isEqualTo(rCode);
  }
}
origin: apache/james-project

@Override
public Collection<String> findTXTRecords(String hostname) {
  try {
    return hostRecord(hostname).txtRecords;
  } catch (UnknownHostException e) {
    throw new RuntimeException(e);
  }
}
origin: apache/james-project

public InMemoryDNSService() {
  records = Maps.newHashMap();
  records.put("0.0.0.0", dnsRecordFor(InetAddresses.forString("0.0.0.0")));
  records.put("127.0.0.1", dnsRecordFor(InetAddresses.forString("127.0.0.1")));
}
origin: apache/james-project

@Override
public InetAddress getByName(String host) throws UnknownHostException {
  return hostRecord(host).addresses.get(0);
}
org.apache.james.dnsservice.apiInMemoryDNSService

Most used methods

  • registerMxRecord
  • <init>
  • dnsRecordFor
  • getDNSEntry
  • hostRecord
  • registerRecord

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getResourceAsStream (ClassLoader)
  • setScale (BigDecimal)
  • getApplicationContext (Context)
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Join (org.hibernate.mapping)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now