ronysebastian / nhin-d

Automatically exported from code.google.com/p/nhin-d
0 stars 0 forks source link

Java RI failing DCDTv3 discovery testcase: D16 - Certificate discovery in LDAP based on SRV weight value #243

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The following issue concerns class 
org.nhindirect.stagent.cert.impl.LdapPublicCertUtilImpl

The Java RI is failing DCDTv3 discovery testcase: D16 - Certificate discovery 
in LDAP based on SRV weight value

Existing code used to order the SRV records

protected static class SRVRecordComparitor implements Comparator<Record>
{
        @Override
        public int compare(Record rec1, Record rec2)
        {
                if (((SRVRecord)rec1).getPriority() == ((SRVRecord)rec2).getPriority())
                        return 0;

                return (((SRVRecord)rec1).getPriority() < ((SRVRecord)rec2).getPriority()) ? -1 : 1;
        }
}

While the respective RFC (http://www.ietf.org/rfc/rfc2782.txt) only 
advises/suggests this ordering the DCDTv3 test tool requires this ordering to 
be in place.

Seeing the fix applied to the .Net RI - Revision 4d5d80baf299: "Fixing Priority 
versus Weight ordering bug" and reading http://en.wikipedia.org/wiki/SRV_record 
I think the code should instead look as follows, initial tests of the following 
code are positive

protected static class SRVRecordComparitor implements Comparator<Record>
{
        @Override
        public int compare(Record rec1, Record rec2)
        {
                SRVRecord srv1 = (SRVRecord)rec1;
                SRVRecord srv2 = (SRVRecord)rec2;

                if (srv1.getPriority() == srv2.getPriority() && srv1.getWeight() == srv2.getWeight())
                        return 0;

                return (srv1.getPriority() < srv2.getPriority()) ? -1 : (srv1.getPriority() > srv2.getPriority()) ? 1 : (srv1.getWeight() < srv2.getWeight()) ? 1 : -1;
        }
}

Original issue reported on code.google.com by phillip....@nitorgroup.com on 23 Jul 2014 at 9:38

GoogleCodeExporter commented 9 years ago
I was made aware of this issue as soon as the new version of the discovery tool 
came out.  I made a fix for it a few weeks ago, and have not checked it in yet. 
 I will get a fix version of the agent out ASAP.

Original comment by gm2...@cerner.com on 23 Jul 2014 at 11:08

GoogleCodeExporter commented 9 years ago
Thanks for the prompt reply Greg

Original comment by phillip....@nitorgroup.com on 24 Jul 2014 at 3:42