public class Handler extends URLStreamHandler
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:
httpmd://www.sun.com/index.html;md5=7be207c7111e459eeea1c9b3d04f1667
index.html;sha=99f6837808c0a79398bf69d83cfb1b82d20cf0cf,Comment
,.jar
Logger
named net.jini.url.httpmd
to log information at the following logging levels:
Level | Description |
---|---|
FINE | URL input stream detects an incorrect message digest |
HttpmdUtil
Constructor and Description |
---|
Handler()
Creates a URL stream handler for HTTPMD URLs.
|
Modifier and Type | Method and Description |
---|---|
protected int |
getDefaultPort()
Returns the default port for a URL parsed by this handler, which is
80 . |
protected int |
hashCode(URL u)
Computes the hash code for the specified URL.
|
protected URLConnection |
openConnection(URL u)
Creates a HTTP URL connection for an HTTPMD URL.
|
protected void |
parseURL(URL url,
String spec,
int start,
int limit)
Parses the string representation of an HTTPMD URL object.
|
protected boolean |
sameFile(URL u1,
URL u2)
Compares two HTTPMD URLs to see if they refer to the same file.
|
equals, getHostAddress, hostsEqual, openConnection, setURL, setURL, toExternalForm
protected int getDefaultPort()
80
.getDefaultPort
in class URLStreamHandler
protected URLConnection openConnection(URL u) throws IOException
openConnection
in class URLStreamHandler
IOException
protected void parseURL(URL url, String spec, int start, int limit)
parseURL
in class URLStreamHandler
IllegalArgumentException
- if the URL is malformedprotected boolean sameFile(URL u1, URL u2)
hostsEqual
to compare the hosts, compares the ports, with -1
matching the default HTTP port (80
), and performs case-sensitive comparison on
the remaining portions.sameFile
in class URLStreamHandler
protected int hashCode(URL u)
hashCode
in class URLStreamHandler
Copyright © GigaSpaces.