< prev index next >

src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD


 231         }
 232     }
 233 
 234     /*
 235      * Constructor used to limit the authorization to the path within
 236      * the URL. Use this constructor for origin server entries.
 237      */
 238     public AuthenticationInfo(char type, AuthScheme authScheme, URL url, String realm,
 239                               String authenticatorKey) {
 240         this.type = type;
 241         this.authScheme = authScheme;
 242         this.protocol = url.getProtocol().toLowerCase();
 243         this.host = url.getHost().toLowerCase();
 244         this.port = url.getPort();
 245         if (this.port == -1) {
 246             this.port = url.getDefaultPort();
 247         }
 248         this.realm = realm;
 249 
 250         String urlPath = url.getPath();
 251         if (urlPath.length() == 0)
 252             this.path = urlPath;
 253         else {
 254             this.path = reducePath (urlPath);
 255         }
 256         this.authenticatorKey = Objects.requireNonNull(authenticatorKey);
 257     }
 258 
 259     /**
 260      * The {@linkplain java.net.Authenticator#getKey(java.net.Authenticator) key}
 261      * of the authenticator that was used to obtain the credentials.
 262      * @return The authenticator's key.
 263      */
 264     public final String getAuthenticatorKey() {
 265         return authenticatorKey;
 266     }
 267 
 268     /*
 269      * reduce the path to the root of where we think the
 270      * authorization begins. This could get shorter as
 271      * the url is traversed up following a successful challenge.




 231         }
 232     }
 233 
 234     /*
 235      * Constructor used to limit the authorization to the path within
 236      * the URL. Use this constructor for origin server entries.
 237      */
 238     public AuthenticationInfo(char type, AuthScheme authScheme, URL url, String realm,
 239                               String authenticatorKey) {
 240         this.type = type;
 241         this.authScheme = authScheme;
 242         this.protocol = url.getProtocol().toLowerCase();
 243         this.host = url.getHost().toLowerCase();
 244         this.port = url.getPort();
 245         if (this.port == -1) {
 246             this.port = url.getDefaultPort();
 247         }
 248         this.realm = realm;
 249 
 250         String urlPath = url.getPath();
 251         if (urlPath.isEmpty())
 252             this.path = urlPath;
 253         else {
 254             this.path = reducePath (urlPath);
 255         }
 256         this.authenticatorKey = Objects.requireNonNull(authenticatorKey);
 257     }
 258 
 259     /**
 260      * The {@linkplain java.net.Authenticator#getKey(java.net.Authenticator) key}
 261      * of the authenticator that was used to obtain the credentials.
 262      * @return The authenticator's key.
 263      */
 264     public final String getAuthenticatorKey() {
 265         return authenticatorKey;
 266     }
 267 
 268     /*
 269      * reduce the path to the root of where we think the
 270      * authorization begins. This could get shorter as
 271      * the url is traversed up following a successful challenge.


< prev index next >