Search in sources :

Example 11 with CERTRecord

use of org.xbill.DNS.CERTRecord in project nhin-d by DirectProject.

the class DNSCertificateStore_lookupDNSTest method getPKIXAnswer.

protected Answer<Message> getPKIXAnswer(final byte[] certData) {
    final Answer<Message> retVal = new Answer<Message>() {

        public Message answer(InvocationOnMock invocation) throws Throwable {
            final Message request = (Message) invocation.getArguments()[0];
            final Message response = new Message(request.getHeader().getID());
            response.getHeader().setFlag(Flags.QR);
            if (request.getHeader().getFlag(Flags.RD))
                response.getHeader().setFlag(Flags.RD);
            response.addRecord(request.getQuestion(), Section.QUESTION);
            if (certData != null) {
                final CERTRecord rec = new CERTRecord(request.getQuestion().getName(), DClass.IN, 86400L, CERTRecord.PKIX, 0, 5, /*public key alg, RFC 4034*/
                certData);
                response.addRecord(rec, Section.ANSWER);
            } else {
                response.getHeader().setRcode(Rcode.NXDOMAIN);
            }
            // we are authoritative only
            response.getHeader().setFlag(Flags.AA);
            return response;
        }
    };
    return retVal;
}
Also used : Answer(org.mockito.stubbing.Answer) Message(org.xbill.DNS.Message) CERTRecord(org.xbill.DNS.CERTRecord) InvocationOnMock(org.mockito.invocation.InvocationOnMock)

Example 12 with CERTRecord

use of org.xbill.DNS.CERTRecord in project nhin-d by DirectProject.

the class DNSCertificateStore_lookupDNSTest method getIPKIXAnswer.

protected Answer<Message> getIPKIXAnswer(final String url) {
    final Answer<Message> retVal = new Answer<Message>() {

        public Message answer(InvocationOnMock invocation) throws Throwable {
            final Message request = (Message) invocation.getArguments()[0];
            final Message response = new Message(request.getHeader().getID());
            response.getHeader().setFlag(Flags.QR);
            if (request.getHeader().getFlag(Flags.RD))
                response.getHeader().setFlag(Flags.RD);
            response.addRecord(request.getQuestion(), Section.QUESTION);
            final CERTRecord rec = new CERTRecord(request.getQuestion().getName(), DClass.IN, 86400L, CERTRecord.URI, 0, 5, /*public key alg, RFC 4034*/
            url.getBytes());
            response.addRecord(rec, Section.ANSWER);
            // we are authoritative only
            response.getHeader().setFlag(Flags.AA);
            return response;
        }
    };
    return retVal;
}
Also used : Answer(org.mockito.stubbing.Answer) Message(org.xbill.DNS.Message) CERTRecord(org.xbill.DNS.CERTRecord) InvocationOnMock(org.mockito.invocation.InvocationOnMock)

Aggregations

CERTRecord (org.xbill.DNS.CERTRecord)12 IOException (java.io.IOException)5 Certificate (java.security.cert.Certificate)4 X509Certificate (java.security.cert.X509Certificate)4 RSAKey (java.security.interfaces.RSAKey)4 ArrayList (java.util.ArrayList)3 ServiceException (org.nhindirect.common.rest.exceptions.ServiceException)3 CNAMERecord (org.xbill.DNS.CNAMERecord)3 NSRecord (org.xbill.DNS.NSRecord)3 File (java.io.File)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 CertificateEncodingException (javax.security.cert.CertificateEncodingException)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 Certificate (org.nhindirect.config.model.Certificate)2 DNSRecord (org.nhindirect.config.model.DNSRecord)2 DNSEntryForm (org.nhindirect.config.ui.form.DNSEntryForm)2 AAAARecord (org.xbill.DNS.AAAARecord)2 ARecord (org.xbill.DNS.ARecord)2 MXRecord (org.xbill.DNS.MXRecord)2