01: // Copyright (c) 1999-2004 Brian Wellington (bwelling@xbill.org)
02:
03: package org.xbill.DNS;
04:
05: import java.io.*;
06:
07: /**
08: * Key - contains a cryptographic public key for use by DNS.
09: * The data can be converted to objects implementing
10: * java.security.interfaces.PublicKey
11: * @see DNSSEC
12: *
13: * @author Brian Wellington
14: */
15:
16: public class DNSKEYRecord extends KEYBase {
17:
18: public static class Protocol {
19: private Protocol() {
20: }
21:
22: /** Key will be used for DNSSEC */
23: public static final int DNSSEC = 3;
24: }
25:
26: public static class Flags {
27: private Flags() {
28: }
29:
30: /** Key is a zone key */
31: public static final int ZONE_KEY = 0x100;
32:
33: /** Key is a secure entry point key */
34: public static final int SEP_KEY = 0x1;
35: }
36:
37: DNSKEYRecord() {
38: }
39:
40: Record getObject() {
41: return new DNSKEYRecord();
42: }
43:
44: /**
45: * Creates a DNSKEY Record from the given data
46: * @param flags Flags describing the key's properties
47: * @param proto The protocol that the key was created for
48: * @param alg The key's algorithm
49: * @param key Binary data representing the key
50: */
51: public DNSKEYRecord(Name name, int dclass, long ttl, int flags,
52: int proto, int alg, byte[] key) {
53: super (name, Type.DNSKEY, dclass, ttl, flags, proto, alg, key);
54: }
55:
56: void rdataFromString(Tokenizer st, Name origin) throws IOException {
57: flags = st.getUInt16();
58: proto = st.getUInt8();
59: String algString = st.getString();
60: alg = DNSSEC.Algorithm.value(algString);
61: if (alg < 0)
62: throw st.exception("Invalid algorithm: " + algString);
63: key = st.getBase64();
64: }
65:
66: }
|