Uploaded image for project: 'EJBCA'
  1. EJBCA
  2. ECA-7000

Improve isFullQualifiedDomainName

    Details

    • Issue discovered during:
      Review
    • Epic Link:
    • Sprint:
      EJBCA Sprint 14

      Description

      StringTools.isFullQualifiedDomainName [sic!] does not work as expected. For example, it does not check the length of labels and the total length of the domain name, it does not permit domain names with a dash and so on.

      The JavaDoc is too vague "looks like fully qualified domain name" and does not refer to compliance with any RFC.

      The following test cases should pass.

      assertFalse(StringTools.isFullQualifiedDomainName(".primekey.com"));
      assertFalse(StringTools.isFullQualifiedDomainName("primekey..com"));
      assertFalse(StringTools.isFullQualifiedDomainName("sub.*.primekey.com"));
      assertFalse(StringTools.isFullQualifiedDomainName("-primekey.com"));
      assertFalse(StringTools.isFullQualifiedDomainName("primekey-.com"));
              assertFalse(StringTools.isFullQualifiedDomainName("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.com"));
      assertFalse(StringTools.isFullQualifiedDomainName(
                      "x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x." + 
                      "x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x." + 
                      "x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x." + 
                      "x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x." + 
                      "x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.com"));
      assertFalse(StringTools.isFullQualifiedDomainName("pr#mekey.com"));
      
      assertTrue(StringTools.isFullQualifiedDomainName("r3.com"));
      assertTrue(StringTools.isFullQualifiedDomainName("com.r3"));
      assertTrue(StringTools.isFullQualifiedDomainName("primekey-solutions.com"));
      assertTrue(StringTools.isFullQualifiedDomainName("primekey.tech-solutions"));
      assertTrue(StringTools.isFullQualifiedDomainName("3d.primekey.com"));
      assertTrue(StringTools.isFullQualifiedDomainName("sub-test.primekey.com"));
      assertTrue(StringTools.isFullQualifiedDomainName("UPPERCASE.COM"));
      assertTrue(StringTools.isFullQualifiedDomainName("M1XeD.CaSE.C0M"));
      assertTrue(StringTools.isFullQualifiedDomainName("xn--4pf93sJb.com"));
      

      Relevant link: https://github.com/google/guava/wiki/InternetDomainNameExplained

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bastianf Bastian Fredriksson
              Reporter:
              bastianf Bastian Fredriksson
              Verified by:
              Johan Eklund
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 30 minutes Original Estimate - 30 minutes
                  30m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 hours, 10 minutes
                  4h 10m