Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8255692

`HttpPrincipal::getName` returns incorrect name

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 16
    • core-libs
    • None
    • behavioral
    • low
    • Hide
      The behavior of the `getName` method is updated to conform to its specification. An implementation that mistakenly calls `getName` instead of `getUserName` might fail as it will find the realm prepended to the user name. This is hopefully an unlikely scenario as both `username` and `realm` can be obtained from specialized accessors (`getUserName` and `getRealm` have always been available in the API).
      Show
      The behavior of the `getName` method is updated to conform to its specification. An implementation that mistakenly calls `getName` instead of `getUserName` might fail as it will find the realm prepended to the user name. This is hopefully an unlikely scenario as both `username` and `realm` can be obtained from specialized accessors (`getUserName` and `getRealm` have always been available in the API).
    • Java API
    • JDK

      Summary

      The specification for HttpPrincipal::getName reports that it should return the name of the HttpPrincipal in the format "realm:username". However, the method in its current state only returns the username.

      Problem

      Currently, the method HttpPrincipal::getName returns an incomplete name of the HttpPrincipal instance.

      Solution

      The method should be updated to return the name in the correct format as specified by the javadoc.

      Specification

         /**
          * Returns the contents of this principal in the form
          * <i>realm:username</i>.
          *
          * @return the contents of this principal in the form realm:username
          */
          public String getName() {
      -      return username;
      +      return String.format("%s:%s", realm, username);
          }

            pconcannon Patrick Concannon (Inactive)
            pconcannon Patrick Concannon (Inactive)
            Daniel Fuchs
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: