45 * </pre> |
45 * </pre> |
46 * <i>scheme</i> will typically be http or https, but is not restricted by this |
46 * <i>scheme</i> will typically be http or https, but is not restricted by this |
47 * class. |
47 * class. |
48 * <i>authority</i> is specified as: |
48 * <i>authority</i> is specified as: |
49 * <pre> |
49 * <pre> |
50 * authority = hostrange [ : portrange ] |
50 * authority = [ userinfo @ ] hostrange [ : portrange ] |
51 * portrange = portnumber | -portnumber | portnumber-[portnumber] | * |
51 * portrange = portnumber | -portnumber | portnumber-[portnumber] | * |
52 * hostrange = ([*.] dnsname) | IPv4address | IPv6address |
52 * hostrange = ([*.] dnsname) | IPv4address | IPv6address |
53 * </pre> |
53 * </pre> |
54 * <i>dnsname</i> is a standard DNS host or domain name, ie. one or more labels |
54 * <i>dnsname</i> is a standard DNS host or domain name, ie. one or more labels |
55 * separated by ".". <i>IPv4address</i> is a standard literal IPv4 address and |
55 * separated by ".". <i>IPv4address</i> is a standard literal IPv4 address and |
62 * <i>portrange</i> is used to specify a port number, or a bounded or unbounded range of ports |
62 * <i>portrange</i> is used to specify a port number, or a bounded or unbounded range of ports |
63 * that this permission applies to. If portrange is absent or invalid, then a default |
63 * that this permission applies to. If portrange is absent or invalid, then a default |
64 * port number is assumed if the scheme is {@code http} (default 80) or {@code https} |
64 * port number is assumed if the scheme is {@code http} (default 80) or {@code https} |
65 * (default 443). No default is assumed for other schemes. A wildcard may be specified |
65 * (default 443). No default is assumed for other schemes. A wildcard may be specified |
66 * which means all ports. |
66 * which means all ports. |
|
67 * <p> |
|
68 * <i>userinfo</i> is optional. A userinfo component if present, is ignored when |
|
69 * creating a URLPermission, and has no effect on any other methods defined by this class. |
67 * <p> |
70 * <p> |
68 * The <i>path</i> component comprises a sequence of path segments, |
71 * The <i>path</i> component comprises a sequence of path segments, |
69 * separated by '/' characters. <i>path</i> may also be empty. The path is specified |
72 * separated by '/' characters. <i>path</i> may also be empty. The path is specified |
70 * in a similar way to the path in {@link java.io.FilePermission}. There are |
73 * in a similar way to the path in {@link java.io.FilePermission}. There are |
71 * three different ways as the following examples show: |
74 * three different ways as the following examples show: |
471 |
474 |
472 static class Authority { |
475 static class Authority { |
473 HostPortrange p; |
476 HostPortrange p; |
474 |
477 |
475 Authority(String scheme, String authority) { |
478 Authority(String scheme, String authority) { |
476 p = new HostPortrange(scheme, authority); |
479 int at = authority.indexOf('@'); |
|
480 if (at == -1) { |
|
481 p = new HostPortrange(scheme, authority); |
|
482 } else { |
|
483 p = new HostPortrange(scheme, authority.substring(at+1)); |
|
484 } |
477 } |
485 } |
478 |
486 |
479 boolean implies(Authority other) { |
487 boolean implies(Authority other) { |
480 return impliesHostrange(other) && impliesPortrange(other); |
488 return impliesHostrange(other) && impliesPortrange(other); |
481 } |
489 } |