Class Handler
WrongMessageDigestException is thrown. HTTPMD URLs may be used to guarantee the integrity of a downloaded object's codebase if used when specifying the URLs for the JAR files containing the object's classes. Because HTTPMD URLs specify a message digest for a single item, they should not be used for directories of classes.
HTTPMD URLs have a syntax similar to that of HTTP URLs, but include a message digest as the last
parameter stored in the last segment of the path. The parameter is introduced by the
';' character, and includes the name of the message digest algorithm, a
'=', the message digest, and an optional comment introduced by the ','
character. In addition, a comment by itself may be specified in a relative HTTPMD URL. Comments
are ignored when using equals to compare HTTPMD URLs. The comment specified in the
context URL is ignored when parsing a relative HTTPMD URL. Adding a comment to an HTTPMD URL is
useful in cases where the URL is required to have a particular suffix, for example the ".jar"
file extension. A comment-only relative HTTPMD URL is useful when specifying the URL of the
containing document from within the contents of the document, where the message digest cannot be
specified because it is not yet known.
The message digest algorithm is case-insensitive, and may include ASCII letters and numbers, as well as the following characters:
- _ . ~ * ' ( ) : @ & + $ ,
The value specifies the name of the MessageDigest algorithm to use. For the URL syntax to
be valid, the value must be the name of a MessageDigest algorithm as determined by
calling MessageDigest.getInstance(String).
The message digest is represented as a positive hexadecimal integer, using digits, and the
letters 'a' through 'f', in either lowercase or uppercase.
The characters following the ',' comment character may include ASCII letters and
numbers, as well as the following characters:
- _ . ~ * ' ( ) : @ & = + $ ,
Here are some examples of HTTPMD URLs:
- An absolute URL:
httpmd://www.sun.com/index.html;md5=7be207c7111e459eeea1c9b3d04f1667 - A relative URL:
index.html;sha=99f6837808c0a79398bf69d83cfb1b82d20cf0cf,Comment - A comment-only relative URL:
,.jar
- Since:
- 2.0
This implementation of HTTPMD URLs uses the
Loggernamednet.jini.url.httpmdto log information at the following logging levels:net.jini.url.httpmdLevel Description FINEURL input stream detects an incorrect message digest - Author:
- Sun Microsystems, Inc.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intReturns the default port for a URL parsed by this handler, which is80.protected intComputes the hash code for the specified URL.protected URLConnectionCreates a HTTP URL connection for an HTTPMD URL.protected voidParses the string representation of an HTTPMD URL object.protected booleanCompares two HTTPMD URLs to see if they refer to the same file.Methods inherited from class java.net.URLStreamHandler
equals, getHostAddress, hostsEqual, openConnection, setURL, setURL, toExternalForm
-
Constructor Details
-
Handler
public Handler()Creates a URL stream handler for HTTPMD URLs.
-
-
Method Details
-
getDefaultPort
protected int getDefaultPort()Returns the default port for a URL parsed by this handler, which is80.- Overrides:
getDefaultPortin classURLStreamHandler- Returns:
- the default port for a URL parsed by this handler
-
openConnection
Creates a HTTP URL connection for an HTTPMD URL.- Specified by:
openConnectionin classURLStreamHandler- Throws:
IOException
-
parseURL
Parses the string representation of an HTTPMD URL object.- Overrides:
parseURLin classURLStreamHandler- Throws:
IllegalArgumentException- if the URL is malformed
-
sameFile
Compares two HTTPMD URLs to see if they refer to the same file. Performs case-insensitive comparison of the protocols and of the message digest parameters (ignoring the comment), callshostsEqualto compare the hosts, compares the ports, with-1matching the default HTTP port (80), and performs case-sensitive comparison on the remaining portions.- Overrides:
sameFilein classURLStreamHandler
-
hashCode
Computes the hash code for the specified URL. This method ignores the comment portion of the message digest parameter, and ignores the case of characters in the message digest and algorithm.- Overrides:
hashCodein classURLStreamHandler
-