implies(Permission): This method is available in the java.net.URLPermission class of Java.
Syntax:
boolean java.net.URLPermission.implies(Permission p)
This method takes one argument. This method checks if this URLPermission implies the given permission.
Specifically, the following checks are done in the following sequence:
1. if 'p' is not an instance of URLPermission return false.
2. if any of p's methods are not in this's method list and if this's method list is not equal to "*", then return false.
3. if any of p's headers are not in this's request header list, and if this's request header list is not equal to "*", then return false.
4. if this's url scheme is not equal to p's url scheme return false.
4. if the scheme-specific part of this's url is '*' return true.
5. if the set of hosts defined by p's url host range is not a subset of this's url host range then return false.
6. if the port range defined by p's url is not a subset of the port range defined by this's url then return false.
7. if the path or paths specified by p's url are contained in the set of paths specified by this's url, then return true
8. otherwise, return false
Parameters: One parameter is required for this method.
p: the permission to check against.
Returns: true if the specified permission is implied by this object, false if not.
Exceptions: NA
Approach
Java
package com.URLPermission;import java.net.URLPermission;public class URLPermissionimplies {public static void main(String[] args) {String url = "https://beingcodeexpert.blogspot.com/";String actions = "read";URLPermission urlPermission = new URLPermission(url, actions);System.out.println(urlPermission.implies(urlPermission));}}
Output:
true
Some other methods of URLPermission class
URLPermission(String): This method creates a URLPermission with the given url string and unrestricted methods and requests headers by invoking the two-argument constructor as follows: URLPermission(url, "*:*")
URLPermission(String, String): This method creates a new URL permission from a url string and permits the given request methods and user-settable request headers.
equals(Object): his method returns true if, this.getActions().equals(p.getActions())and p's url equals this's url. Returns false otherwise.
getActions(): This method returns the normalized method list and requests a header list, in the form: "method-names: header-names".
hashCode(): This method returns a hashcode calculated from the hashcode of the actions String and the url string.
implies(Permission): This method checks if this URLPermission implies some of the permissions.
No comments:
Post a Comment