public ResolutionUnsuccessfulException getResolutionUnsuccessfulException() { if (wasSuccessful()) return null; if (resolutionUnsuccessfulException == null) { resolutionUnsuccessfulException = new ResolutionUnsuccessfulException(question, responseCode); } return resolutionUnsuccessfulException; }
public void throwIfErrorResponse() throws ResolutionUnsuccessfulException { ResolutionUnsuccessfulException resolutionUnsuccessfulException = getResolutionUnsuccessfulException(); if (resolutionUnsuccessfulException != null) throw resolutionUnsuccessfulException; }
public Set<D> getAnswers() { throwIseIfErrorResponse(); return data; }
@IntegrationTest public static void resolverTest() throws IOException { ResolverResult<A> res = ResolverApi.INSTANCE.resolve("geekplace.eu", A.class); assertEquals(true, res.wasSuccessful()); Set<A> answers = res.getAnswers(); assertEquals(1, answers.size()); assertArrayEquals(new A(37, 221, 197, 223).toByteArray(), answers.iterator().next().toByteArray()); }
try { final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); ResolverResult<SRV> results = ResolverApi.INSTANCE.resolve("_xmpps-client._tcp." + domain, SRV.class); for(SRV record : results.getAnswers()) { try { SSLSocket socket = (SSLSocket) sslSocketFactory.createSocket(record.name.toString(),record.port);
public final <D extends Data> ResolverResult<D> resolve(String name, Class<D> type) throws IOException { return resolve(DNSName.from(name), type); }
public DNSSECResultNotAuthenticException getDnssecResultNotAuthenticException() { if (!wasSuccessful()) return null; if (isAuthenticData) return null; if (dnssecResultNotAuthenticException == null) { dnssecResultNotAuthenticException = DNSSECResultNotAuthenticException.from(getUnverifiedReasons()); } return dnssecResultNotAuthenticException; }
@Override public <D extends Data> ResolverResult<D> resolve(Question question) throws IOException { DNSSECMessage dnssecMessage = dnssecClient.queryDnssec(question); return toResolverResult(question, dnssecMessage); }
private static <D extends Data> ResolverResult<D> toResolverResult(Question question, DNSSECMessage dnssecMessage) throws NullResultException { Set<UnverifiedReason> unverifiedReasons = dnssecMessage.getUnverifiedReasons(); return new ResolverResult<D>(question, dnssecMessage, unverifiedReasons); } }
/** * Resolve the given name and type which is expected to yield DNSSEC authenticated results. * * @param name the DNS name to resolve. * @param type the class of the RR type to resolve. * @param <D> the RR type to resolve. * @return the resolver result. * @throws IOException in case an exception happens while resolving. * @see #resolveDnssecReliable(Question) */ public <D extends Data> ResolverResult<D> resolveDnssecReliable(String name, Class<D> type) throws IOException { return resolveDnssecReliable(DNSName.from(name), type); }
try { final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); ResolverResult<SRV> results = ResolverApi.INSTANCE.resolve("_xmpps-client._tcp." + domain, SRV.class); for (SRV record : results.getAnswers()) { try { SSLSocket socket = (SSLSocket) sslSocketFactory.createSocket(record.name.toString(), record.port);
public final <D extends Data> ResolverResult<D> resolve(DNSName name, Class<D> type) throws IOException { TYPE t = TYPE.getType(type); Question q = new Question(name, t); return resolve(q); }
public Set<UnverifiedReason> getUnverifiedReasons() { throwIseIfErrorResponse(); return unverifiedReasons; }
private void throwIseIfErrorResponse() { ResolutionUnsuccessfulException resolutionUnsuccessfulException = getResolutionUnsuccessfulException(); if (resolutionUnsuccessfulException != null) throw new IllegalStateException("Can not perform operation because the DNS resolution was unsuccessful", resolutionUnsuccessfulException); } }
/** * Resolve the given question which is expected to yield DNSSEC authenticated results. * * @param question the question to resolve. * @param <D> the RR type to resolve. * @return the resolver result. * @throws IOException in case an exception happens while resolving. */ public <D extends Data> ResolverResult<D> resolveDnssecReliable(Question question) throws IOException { DNSSECMessage dnssecMessage = recursiveOnlyDnssecClient.queryDnssec(question); if (dnssecMessage == null || !dnssecMessage.authenticData) { dnssecMessage = iterativeOnlyDnssecClient.queryDnssec(question); } return toResolverResult(question, dnssecMessage); }
public <D extends Data> ResolverResult<D> resolve(Question question) throws IOException { DNSMessage dnsMessage = dnsClient.query(question); return new ResolverResult<D>(question, dnsMessage, null); }
/** * Resolve the given name and type which is expected to yield DNSSEC authenticated results. * * @param name the DNS name to resolve. * @param type the class of the RR type to resolve. * @param <D> the RR type to resolve. * @return the resolver result. * @throws IOException in case an exception happens while resolving. * @see #resolveDnssecReliable(Question) */ public <D extends Data> ResolverResult<D> resolveDnssecReliable(DNSName name, Class<D> type) throws IOException { TYPE t = TYPE.getType(type); Question q = new Question(name, t); return resolveDnssecReliable(q); }
public boolean isAuthenticData() { throwIseIfErrorResponse(); return isAuthenticData; }