Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/classes/sun/net/www/protocol/http/BasicAuthentication.java
          +++ new/src/share/classes/sun/net/www/protocol/http/BasicAuthentication.java
↓ open down ↓ 123 lines elided ↑ open up ↑
 124  124      public BasicAuthentication(boolean isProxy, URL url, String realm,
 125  125                                     String auth) {
 126  126          super(isProxy ? PROXY_AUTHENTICATION : SERVER_AUTHENTICATION,
 127  127                AuthScheme.BASIC, url, realm);
 128  128          this.auth = "Basic " + auth;
 129  129      }
 130  130  
 131  131      /**
 132  132       * @return true if this authentication supports preemptive authorization
 133  133       */
 134      -    boolean supportsPreemptiveAuthorization() {
      134 +    @Override
      135 +    public boolean supportsPreemptiveAuthorization() {
 135  136          return true;
 136  137      }
 137  138  
 138  139      /**
 139      -     * @return the name of the HTTP header this authentication wants set
 140      -     */
 141      -    String getHeaderName() {
 142      -        if (type == SERVER_AUTHENTICATION) {
 143      -            return "Authorization";
 144      -        } else {
 145      -            return "Proxy-authorization";
 146      -        }
 147      -    }
 148      -
 149      -    /**
 150  140       * Set header(s) on the given connection. This will only be called for
 151  141       * definitive (i.e. non-preemptive) authorization.
 152  142       * @param conn The connection to apply the header(s) to
 153  143       * @param p A source of header values for this connection, if needed.
 154  144       * @param raw The raw header values for this connection, if needed.
 155  145       * @return true if all goes well, false if no headers were set.
 156  146       */
 157      -    boolean setHeaders(HttpURLConnection conn, HeaderParser p, String raw) {
      147 +    @Override
      148 +    public boolean setHeaders(HttpURLConnection conn, HeaderParser p, String raw) {
 158  149          conn.setAuthenticationProperty(getHeaderName(), getHeaderValue(null,null));
 159  150          return true;
 160  151      }
 161  152  
 162  153      /**
 163  154       * @return the value of the HTTP header this authentication wants set
 164  155       */
 165      -    String getHeaderValue(URL url, String method) {
      156 +    @Override
      157 +    public String getHeaderValue(URL url, String method) {
 166  158          /* For Basic the authorization string does not depend on the request URL
 167  159           * or the request method
 168  160           */
 169  161          return auth;
 170  162      }
 171  163  
 172  164      /**
 173  165       * For Basic Authentication, the security parameters can never be stale.
 174  166       * In other words there is no possibility to reuse the credentials.
 175  167       * They are always either valid or invalid.
 176  168       */
 177      -    boolean isAuthorizationStale (String header) {
      169 +    @Override
      170 +    public boolean isAuthorizationStale (String header) {
 178  171          return false;
 179  172      }
 180  173  
 181  174      /**
 182  175       * @return the common root path between npath and path.
 183  176       * This is used to detect when we have an authentication for two
 184  177       * paths and the root of th authentication space is the common root.
 185  178       */
 186  179  
 187  180      static String getRootPath(String npath, String opath) {
↓ open down ↓ 23 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX