Uploaded image for project: 'Directory ApacheDS'
  1. Directory ApacheDS
  2. DIRSERVER-2031

Use a properly random port when creating a KDCServer via annotation

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.0-M20
    • Component/s: None
    • Labels:
      None

      Description


      Currently, when creating a KDCServer via annotation, the "random" port is always "1024". In addition, it should be possible to share the same random port for multiple transports.

      1. dirserver-2031.patch
        9 kB
        Colm O hEigeartaigh
      2. dirserver-2031.patch.2
        9 kB
        Colm O hEigeartaigh

        Activity

        Hide
        coheigea Colm O hEigeartaigh added a comment -

        A proposed patch for this issue.

        Colm.

        Show
        coheigea Colm O hEigeartaigh added a comment - A proposed patch for this issue. Colm.
        Hide
        elecharny Emmanuel Lecharny added a comment -

        The patch does not take anymore a given port when creating a KDC server. We should keep the possibility for the user to provide a part, and if none is provided, then we pick one random port.

        Here is a proposal :

        • if the port is given, then we use it : @CreateTransport(protocol = "TCP", address = "127.0.0.1", port = 6087),
        • if the port is not given, or is 0 or below 0, we pick a random free port : @CreateTransport(protocol = "TCP" )

        For the specific case where we want to pick a random port, which has to be shared between TCP and UDP, I would rather create a new protocol type : KRB in this case. Then @CreateTransport(protocol = "KRB", port= xyz ) will create 2 transports (TCP and UDP) with the same port for both. If the port is omitted, then we will pick a random port, the same for both transports.

        General :

        • @CreateTransport(protocol = "TCP" [, port= 0/-1] ) -> pick a random TCP free port
        • @CreateTransport(protocol = "TCP", port =123 ) -> use TCP port 123
        • @CreateTransport(protocol = "UDP" [, port= 0/-1] ) -> pick a random UDP free port
        • @CreateTransport(protocol = "UDP", port =123 ) -> use UDP port 123

        LDAP/LDAPS specific :

        • @CreateTransport(protocol = "LDAP[S]" [, port= 0/-1] ) -> create a random TCP port

        Kerberos :

        • @CreateTransport(protocol = "KRB" [, port= 0/-1]) -> create a random port, shared by the TCP and UDP transport used by the KerberosServer
        • @CreateTransport(protocol = "KRB", port= 123) -> create port 123, shared by the TCP and UDP transport used by the KerberosServer

        ChangePassword :

        • @CreateTransport(protocol = "CPW" [, port= 0/-1]) -> create a random port, shared by the TCP and UDP transport used by the ChangePasswordServer
        • @CreateTransport(protocol = "CPW", port= 123) -> create port 123, shared by the TCP and UDP transport used by the ChangePasswordServer
        Show
        elecharny Emmanuel Lecharny added a comment - The patch does not take anymore a given port when creating a KDC server. We should keep the possibility for the user to provide a part, and if none is provided, then we pick one random port. Here is a proposal : if the port is given, then we use it : @CreateTransport(protocol = "TCP", address = "127.0.0.1", port = 6087), if the port is not given, or is 0 or below 0, we pick a random free port : @CreateTransport(protocol = "TCP" ) For the specific case where we want to pick a random port, which has to be shared between TCP and UDP, I would rather create a new protocol type : KRB in this case. Then @CreateTransport(protocol = "KRB", port= xyz ) will create 2 transports (TCP and UDP) with the same port for both. If the port is omitted, then we will pick a random port, the same for both transports. General : @CreateTransport(protocol = "TCP" [, port= 0/-1] ) -> pick a random TCP free port @CreateTransport(protocol = "TCP", port =123 ) -> use TCP port 123 @CreateTransport(protocol = "UDP" [, port= 0/-1] ) -> pick a random UDP free port @CreateTransport(protocol = "UDP", port =123 ) -> use UDP port 123 LDAP/LDAPS specific : @CreateTransport(protocol = "LDAP [S] " [, port= 0/-1] ) -> create a random TCP port Kerberos : @CreateTransport(protocol = "KRB" [, port= 0/-1] ) -> create a random port, shared by the TCP and UDP transport used by the KerberosServer @CreateTransport(protocol = "KRB", port= 123) -> create port 123, shared by the TCP and UDP transport used by the KerberosServer ChangePassword : @CreateTransport(protocol = "CPW" [, port= 0/-1] ) -> create a random port, shared by the TCP and UDP transport used by the ChangePasswordServer @CreateTransport(protocol = "CPW", port= 123) -> create port 123, shared by the TCP and UDP transport used by the ChangePasswordServer
        Hide
        coheigea Colm O hEigeartaigh added a comment -

        Hi Emmanuel,

        Please see attached for a revised patch for this issue.

        The previous patch did actually use a port if provided in the annotation. It just didn't use the "startPort" parameter that was passed through to the getKdcServer method in ServerAnnotationProcessor. This port was only used as a starting port to find a free port, if no port was specified in the annotation (and was hard-coded as 1024 in calling code). As we are generating a random port in this scenario now, the parameter is no longer required.

        I've added two new protocols as you have outlined, "KRB" and "CPW". When these protocols are used we generate both UDP + TCP transports on either the port provided, or using a random port if not provided. It makes the code a lot simpler compared to the previous patch.

        Thanks,

        Colm.

        Show
        coheigea Colm O hEigeartaigh added a comment - Hi Emmanuel, Please see attached for a revised patch for this issue. The previous patch did actually use a port if provided in the annotation. It just didn't use the "startPort" parameter that was passed through to the getKdcServer method in ServerAnnotationProcessor. This port was only used as a starting port to find a free port, if no port was specified in the annotation (and was hard-coded as 1024 in calling code). As we are generating a random port in this scenario now, the parameter is no longer required. I've added two new protocols as you have outlined, "KRB" and "CPW". When these protocols are used we generate both UDP + TCP transports on either the port provided, or using a random port if not provided. It makes the code a lot simpler compared to the previous patch. Thanks, Colm.
        Hide
        coheigea Colm O hEigeartaigh added a comment -

        Any objections to me applying the second patch? I'll add some testing after that.

        Colm.

        Show
        coheigea Colm O hEigeartaigh added a comment - Any objections to me applying the second patch? I'll add some testing after that. Colm.
        Hide
        elecharny Emmanuel Lecharny added a comment -

        Please go ahead !

        Show
        elecharny Emmanuel Lecharny added a comment - Please go ahead !

          People

          • Assignee:
            elecharny Emmanuel Lecharny
            Reporter:
            coheigea Colm O hEigeartaigh
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development