|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object issrg.pba.rbac.URLHandler
public class URLHandler
This class is a constructor of various URL-related instances: Subtrees (for domain matching), Principals and Entries (for domain matching). It also maintains a register of URL Handlers for other protocols, so that a relevant URL Handler can be found for a specific URL.
The instances of this class handle all URLs as if they were HTTP URLs. Subclass it and override the methods to handle URLs of other types.
Field Summary | |
---|---|
protected int |
defaultPort
|
protected static int |
FILE_PORT
This variable is here to allow emulation of file: URLs as HTTP URLs. |
static java.lang.String |
FILE_PROTOCOL
|
static int |
HTTP_PORT
|
static java.lang.String |
HTTP_PROTOCOL
|
static int |
HTTPS_PORT
|
static java.lang.String |
HTTPS_PROTOCOL
|
protected java.lang.String |
protocol
|
static java.lang.String |
VOMS_SAML_PROTOCOL
|
Constructor Summary | |
---|---|
protected |
URLHandler()
|
|
URLHandler(java.lang.String protocol,
int defaultPort)
This constructor builds an instance of URLHandler that will be able to handle URLs of given protocol, and listening on given default port. |
Method Summary | |
---|---|
static void |
addProtocol(URLHandler u)
This method registers a new protocol URL handler, so if a URL for this protocol has to be parsed, the getPrincipal and getSubtree nodes will know who can handle such URLs. |
int |
getDefaultPort()
This method returns the number of the defaul port that the protocol listens on |
Entry |
getEntry(java.lang.String url)
This method returns an Entry identified by a given HTTP URL. |
static Entry |
getEntryByURL(java.lang.String url)
This method returns a Entry object, created by corresponding URLHandler. |
java.security.Principal |
getPrincipal(java.lang.String url)
This method returns a Principal for a given HTTP URL string. |
static java.security.Principal |
getPrincipalByURL(java.lang.String url)
This method returns a Principal, created by corresponding URLHandler. |
java.lang.String |
getProtocol()
This method returns the string name of the protocol (without the trailing colon). |
static java.lang.String |
getProtocolName(java.lang.String url)
This method returns the protocol name, given a URL. |
AttributeRepository |
getRepository(java.lang.String url)
This method returns an instance of a repository that would be able to retrieve attributes given the URL. |
static AttributeRepository |
getRepositoryByURL(java.lang.String url)
This method will find a URLHandler for the protocol and create the AttributeRepository that will provide access to that repository. |
Subtree |
getSubtree(java.lang.String url,
int min,
int max,
Subtree[] exclude)
This method returns a Subtree specified using a Base Entry URL and Min and Max level specifications. |
static Subtree |
getSubtreeByURL(java.lang.String url,
int min,
int max,
Subtree[] exclude)
This method returns a Subtree object, created by corresponding URLHandler. |
static URLHandler |
getURLHandler(java.lang.String protocol)
This method returns a handler for URLs for a given protocol. |
static void |
removeProtocol(java.lang.String protocol)
This method removes a protocol handler for a particular protocol name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String HTTP_PROTOCOL
public static final java.lang.String HTTPS_PROTOCOL
public static final java.lang.String FILE_PROTOCOL
public static final java.lang.String VOMS_SAML_PROTOCOL
public static final int HTTP_PORT
public static final int HTTPS_PORT
protected static final int FILE_PORT
protected java.lang.String protocol
protected int defaultPort
Constructor Detail |
---|
protected URLHandler()
public URLHandler(java.lang.String protocol, int defaultPort)
protocol
- the string name of the protocol (without trailing ":");
case of characters is ignoreddefaultPort
- the number of the default port the protocol listens onMethod Detail |
---|
public static void addProtocol(URLHandler u)
u
- the URLHandler that can handle URLs for a specific protocolpublic static void removeProtocol(java.lang.String protocol)
protocol
- the protocol name for which handler has to be removedpublic static URLHandler getURLHandler(java.lang.String protocol)
protocol
- the protocol to get the handler for
public static java.lang.String getProtocolName(java.lang.String url) throws BadURLException
url
- the URL to get the protocol name from
BadURLException
- if this is not a URL with a protocol string in itpublic static java.security.Principal getPrincipalByURL(java.lang.String url) throws BadURLException
This is equivalent to getURLHandler(getProtocolName(url)).getPrincipal(url);
url
- the URL as the Principal
BadURLException
- if the URL does not have a protocol part, or the
URLHandler doesn't like itpublic static Entry getEntryByURL(java.lang.String url) throws BadURLException
This is equivalent to getURLHandler(getProtocolName(url)).getEntry(url);
url
- the URL of the Entry
BadURLException
- if the URL does not have a protocol part, or the
URLHandler doesn't like itpublic static Subtree getSubtreeByURL(java.lang.String url, int min, int max, Subtree[] exclude) throws BadURLException
This is equivalent to getURLHandler(getProtocolName(url)).getSubtree(url, min, max);
url
- the URL of the base Entrymin
- the minimum number of levels below the base Entry where the
matching entries can be located; pass 0, if no retriction is placedmax
- the maximum number of levels below the base Entry where the
matching entries can be located; pass -1 if no restriction is placedexclude
- the array of the subtrees specifying what entries to exclude
from this subtree
BadURLException
- if the URL does not have a protocol part, or the
URLHandler doesn't like itpublic static AttributeRepository getRepositoryByURL(java.lang.String url) throws BadURLException
Same as URLHandler.getURLHandler(URLHandler.getProtocolName(url)).getRepository(url);
url
- - the URL of the repository
BadURLException
- if the URL is malformedpublic java.lang.String getProtocol()
public int getDefaultPort()
public java.security.Principal getPrincipal(java.lang.String url) throws BadURLException
url
- the string representation of the HTTP URL (including the
protocol name part)
(the actual protocol name is checked with the string returned by
getProtocol,
but the format of the rest of the URL is as specified in HTTP RFC)
BadURLException
- if the URL is malformedpublic Entry getEntry(java.lang.String url) throws BadURLException
This URLHandler does (Entry)getPrincipal(url) - so if your Principal implements the Entry interface, you can leave the getEntry method.
url
- the string representation of the HTTP URL (see comments for
getPrincipal method)
BadURLException
- if the URL is malformedpublic Subtree getSubtree(java.lang.String url, int min, int max, Subtree[] exclude) throws BadURLException
url
- the URL of the Base Entry; port may be specified as a range of
ports by using nn-mm notation (two numbers separated by hyphen);
if no port is specified, any port matches the subtree specificationmin
- the Min value for the subtreemax
- the Max value for the subtree
BadURLException
- if the URL is malformedSubtree
public AttributeRepository getRepository(java.lang.String url) throws BadURLException
In this version of the URLHandler, no HTTP/HTTPS repositories are implemented, so null is returned for such URLs.
url
- - the URL of the repository
BadURLException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |