Package org.apache.directory.server.dns.messages

Examples of org.apache.directory.server.dns.messages.ResourceRecordModifier


    @SuppressWarnings("PMD.AvoidUsingHardCodedIP")
    public Set<ResourceRecord> getRecords( QuestionRecord question ) throws DnsException
    {
        Set<ResourceRecord> set = new HashSet<ResourceRecord>();

        ResourceRecordModifier rm = new ResourceRecordModifier();
        rm.setDnsClass( RecordClass.IN );
        rm.setDnsName( "ldap.example.com" );
        rm.setDnsTtl( 100 );
        rm.setDnsType( RecordType.A );
        rm.put( DnsAttribute.IP_ADDRESS, "10.0.0.2" );

        set.add( rm.getEntry() );

        ResourceRecordModifier rm2 = new ResourceRecordModifier();
        rm2.setDnsClass( RecordClass.IN );
        rm2.setDnsName( "www.example.com" );
        rm2.setDnsTtl( 100 );
        rm2.setDnsType( RecordType.A );
        rm2.put( DnsAttribute.IP_ADDRESS, "10.0.0.3" );

        set.add( rm2.getEntry() );

        return set;
    }
View Full Code Here


     * @return the entry for the question
     * @throws NamingException if there are any access problems
     */
    private ResourceRecord getRecord( Attributes attrs ) throws NamingException
    {
        ResourceRecordModifier modifier = new ResourceRecordModifier();

        Attribute attr;

        String dnsName = ( attr = attrs.get( DnsAttribute.NAME ) ) != null ? ( String ) attr.get() : null;
        String dnsType = ( attr = attrs.get( DnsAttribute.TYPE ) ) != null ? ( String ) attr.get() : null;
        String dnsClass = ( attr = attrs.get( DnsAttribute.CLASS ) ) != null ? ( String ) attr.get() : null;
        String dnsTtl = ( attr = attrs.get( DnsAttribute.TTL ) ) != null ? ( String ) attr.get() : null;

        modifier.setDnsName( dnsName );
        modifier.setDnsType( RecordType.valueOf( dnsType ) );
        modifier.setDnsClass( RecordClass.valueOf( dnsClass ) );
        modifier.setDnsTtl( Integer.parseInt( dnsTtl ) );

        NamingEnumeration<String> ids = attrs.getIDs();

        while ( ids.hasMore() )
        {
            String id = ids.next();
            modifier.put( id, ( String ) attrs.get( id ).get() );
        }

        return modifier.getEntry();
    }
View Full Code Here

    private ResourceRecord getRecord( Attributes attrs, Name relative ) throws NamingException
    {
        String SOA_MINIMUM = "86400";
        String SOA_CLASS = "IN";

        ResourceRecordModifier modifier = new ResourceRecordModifier();

        Attribute attr;

        // if no name, transform rdn
        attr = attrs.get( DnsAttribute.NAME );

        if ( attr != null )
        {
            modifier.setDnsName( ( String ) attr.get() );
        }
        else
        {
            relative = getDomainComponents( relative );

            String dnsName;
            dnsName = transformDistinguishedName( relative.toString() );
            modifier.setDnsName( dnsName );
        }

        // type is implicit in objectclass
        attr = attrs.get( DnsAttribute.TYPE );

        if ( attr != null )
        {
            modifier.setDnsType( RecordType.valueOf( ( String ) attr.get() ) );
        }
        else
        {
            modifier.setDnsType( getType( attrs.get( SchemaConstants.OBJECT_CLASS_AT ) ) );
        }

        // class defaults to SOA CLASS
        String dnsClass = ( attr = attrs.get( DnsAttribute.CLASS ) ) != null ? ( String ) attr.get() : SOA_CLASS;
        modifier.setDnsClass( RecordClass.valueOf( dnsClass ) );

        // ttl defaults to SOA MINIMUM
        String dnsTtl = ( attr = attrs.get( DnsAttribute.TTL ) ) != null ? ( String ) attr.get() : SOA_MINIMUM;
        modifier.setDnsTtl( Integer.parseInt( dnsTtl ) );

        NamingEnumeration<String> ids = attrs.getIDs();

        while ( ids.hasMore() )
        {
            String id = ids.next();
            modifier.put( id, ( String ) attrs.get( id ).get() );
        }

        return modifier.getEntry();
    }
View Full Code Here

    return new FakeDNSServer(new RecordStore() {
      @Override
      public Set<ResourceRecord> getRecords(QuestionRecord questionRecord) throws org.apache.directory.server.dns.DnsException {
        Set<ResourceRecord> set = new HashSet<>();

        ResourceRecordModifier rm = new ResourceRecordModifier();
        rm.setDnsClass(RecordClass.IN);
        rm.setDnsName("dns.vertx.io");
        rm.setDnsTtl(100);
        rm.setDnsType(RecordType.A);
        rm.put(DnsAttribute.IP_ADDRESS, ipAddress);
        set.add(rm.getEntry());
        return set;
      }
    });
  }
View Full Code Here

    return new FakeDNSServer(new RecordStore() {
      @Override
      public Set<ResourceRecord> getRecords(QuestionRecord questionRecord) throws org.apache.directory.server.dns.DnsException {
        Set<ResourceRecord> set = new HashSet<>();

        ResourceRecordModifier rm = new ResourceRecordModifier();
        rm.setDnsClass(RecordClass.IN);
        rm.setDnsName("dns.vertx.io");
        rm.setDnsTtl(100);
        rm.setDnsType(RecordType.AAAA);
        rm.put(DnsAttribute.IP_ADDRESS, ipAddress);

        set.add(rm.getEntry());
        return set;
      }
    });
  }
View Full Code Here

    return new FakeDNSServer(new RecordStore() {
      @Override
      public Set<ResourceRecord> getRecords(QuestionRecord questionRecord) throws org.apache.directory.server.dns.DnsException {
        Set<ResourceRecord> set = new HashSet<>();

        ResourceRecordModifier rm = new ResourceRecordModifier();
        rm.setDnsClass(RecordClass.IN);
        rm.setDnsName("dns.vertx.io");
        rm.setDnsTtl(100);
        rm.setDnsType(RecordType.MX);
        rm.put(DnsAttribute.MX_PREFERENCE, String.valueOf(prio));
        rm.put(DnsAttribute.DOMAIN_NAME, mxRecord);
        set.add(rm.getEntry());
        return set;
      }
    });
  }
View Full Code Here

    return new FakeDNSServer(new RecordStore() {
      @Override
      public Set<ResourceRecord> getRecords(QuestionRecord questionRecord) throws org.apache.directory.server.dns.DnsException {
        Set<ResourceRecord> set = new HashSet<>();

        ResourceRecordModifier rm = new ResourceRecordModifier();
        rm.setDnsClass(RecordClass.IN);
        rm.setDnsName("dns.vertx.io");
        rm.setDnsTtl(100);
        rm.setDnsType(RecordType.TXT);
        rm.put(DnsAttribute.CHARACTER_STRING, txt);
        set.add(rm.getEntry());
        return set;
      }
    });
  }
View Full Code Here

    return new FakeDNSServer(new RecordStore() {
      @Override
      public Set<ResourceRecord> getRecords(QuestionRecord questionRecord) throws org.apache.directory.server.dns.DnsException {
        Set<ResourceRecord> set = new HashSet<>();

        ResourceRecordModifier rm = new ResourceRecordModifier();
        rm.setDnsClass(RecordClass.IN);
        rm.setDnsName("dns.vertx.io");
        rm.setDnsTtl(100);
        rm.setDnsType(RecordType.NS);
        rm.put(DnsAttribute.DOMAIN_NAME, ns);
        set.add(rm.getEntry());
        return set;
      }
    });
  }
View Full Code Here

    return new FakeDNSServer(new RecordStore() {
      @Override
      public Set<ResourceRecord> getRecords(QuestionRecord questionRecord) throws org.apache.directory.server.dns.DnsException {
        Set<ResourceRecord> set = new HashSet<>();

        ResourceRecordModifier rm = new ResourceRecordModifier();
        rm.setDnsClass(RecordClass.IN);
        rm.setDnsName("dns.vertx.io");
        rm.setDnsTtl(100);
        rm.setDnsType(RecordType.CNAME);
        rm.put(DnsAttribute.DOMAIN_NAME, cname);
        set.add(rm.getEntry());
        return set;
      }
    });
  }
View Full Code Here

    return new FakeDNSServer(new RecordStore() {
      @Override
      public Set<ResourceRecord> getRecords(QuestionRecord questionRecord) throws org.apache.directory.server.dns.DnsException {
        Set<ResourceRecord> set = new HashSet<>();

        ResourceRecordModifier rm = new ResourceRecordModifier();
        rm.setDnsClass(RecordClass.IN);
        rm.setDnsName("dns.vertx.io");
        rm.setDnsTtl(100);
        rm.setDnsType(RecordType.PTR);
        rm.put(DnsAttribute.DOMAIN_NAME, ptr);
        set.add(rm.getEntry());
        return set;
      }
    });
  }
View Full Code Here

TOP

Related Classes of org.apache.directory.server.dns.messages.ResourceRecordModifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.