org.openpermis.policy.bean.basic
Class BasicDomain

java.lang.Object
  extended by org.openpermis.policy.bean.basic.BasicPart
      extended by org.openpermis.policy.bean.basic.BasicPartBean
          extended by org.openpermis.policy.bean.basic.BasicDomain
All Implemented Interfaces:
Serializable, DomainBean, IdentifiableBean, PartBean, Domain, Identifiable, Part

public class BasicDomain
extends BasicPartBean
implements DomainBean

A basic implementation of Domain.

See Also:
Serialized Form
Since:
0.1.0

Nested Class Summary
static interface BasicDomain.PathMatcher
          Determines if a path is contained within a domain path.
 
Field Summary
protected static BasicDomain.PathMatcher DIRECTORY_PATH_MATCHER
          A path matcher where a domain contains a resource if the path of the resource starts with the path of the domain.
protected static int HTTP_DEFAULT_PORT
           
protected static int HTTPS_DEFAULT_PORT
           
protected static int LDAP_DEFAULT_PORT
           
protected static BasicDomain.PathMatcher LDAP_PATH_MATCHER
          A path matcher where a domain contains a resource if both the domain and the resource can be interpreted as LDAP distinguished names and the resource DN starts with the domain DN.
protected static int LDAPS_DEFAULT_PORT
           
private static long serialVersionUID
           
protected static BasicDomain.PathMatcher UNKNOWN_PATH_MATCHER
          A path matcher where no resource is part of any domain.
 
Constructor Summary
protected BasicDomain(SerialNumber serialNumber, URI uri)
          Creates a domain that initially includes only the specified URI.
 
Method Summary
protected  boolean comparablePart(BasicPart part)
          Checks that the part supplied is an domain.
 boolean contains(URI entity)
          Checks if this domain contains the specified entity.
protected  boolean contains(URI domain, URI resource)
          Returns whether the specified domain contains the specified resource.
protected  BasicDomain.PathMatcher findPathMatcher(URI domain, URI resource)
          Returns a path matcher for the specified domain and resource URI.
protected  BasicDomain.PathMatcher findPathMatcherForScheme(String scheme)
          Derives a path matcher given a URI scheme.
protected  int getDefaultPort(String scheme)
          Returns the default port number for the specified URI scheme.
protected  String getPath(URI uri)
          Returns the path part of the specified URI.
protected  int getPort(URI uri)
          Returns the port number of the specified URI.
protected  String getSimpleClassName()
          Returns the simple implementation class name of this class.
protected  BasicDomain.PathMatcher guessPathMatcherForPath(String path)
          Derives a path matcher from special characters in a path.
protected  boolean hostsMatch(String domainHost, String resourceHost)
          Returns whether the specified host names are compatible.
protected  boolean portsMatch(int domainPort, int resourcePort)
          Returns whether port numbers of the specified domain and resource are compatible.
protected  boolean schemesMatch(String domainScheme, String resourceScheme)
          Returns whether the specified schemes are compatible.
 
Methods inherited from class org.openpermis.policy.bean.basic.BasicPartBean
addPropertyChangeListener, equalSerialNumber, findBySerialNumber, firePropertyChange, getPartBeanType, getSerialNumber, getSerialNumberString, notifyIdentityChange, notifyNameChange, removePropertyChangeListener, toShortString
 
Methods inherited from class org.openpermis.policy.bean.basic.BasicPart
appendDetails, appendPartDetails, equalPart, equals, getIdentity, getName, hashCode, hasPartIdentity, hasPartName, isChildCollectionValid, isChildNotNull, isChildNullOrValid, isChildValid, isIdentityValid, isNameValid, isPartValid, isValid, partHashCode, reportProblem, setIdentity, setName, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.openpermis.policy.Part
equals, hashCode, isValid, toString
 
Methods inherited from interface org.openpermis.policy.Identifiable
getIdentity
 
Methods inherited from interface org.openpermis.policy.bean.PartBean
addPropertyChangeListener, equalSerialNumber, findBySerialNumber, getPartBeanType, getSerialNumber, removePropertyChangeListener, toShortString
 
Methods inherited from interface org.openpermis.policy.Part
equals, hashCode, isValid, toString
 
Methods inherited from interface org.openpermis.policy.bean.IdentifiableBean
setIdentity
 
Methods inherited from interface org.openpermis.policy.Identifiable
getIdentity
 

Field Detail

DIRECTORY_PATH_MATCHER

protected static final BasicDomain.PathMatcher DIRECTORY_PATH_MATCHER
A path matcher where a domain contains a resource if the path of the resource starts with the path of the domain.

This matcher fits paths in a file system or a HTTP URL.

Since:
0.3.0

LDAP_PATH_MATCHER

protected static final BasicDomain.PathMatcher LDAP_PATH_MATCHER
A path matcher where a domain contains a resource if both the domain and the resource can be interpreted as LDAP distinguished names and the resource DN starts with the domain DN.

Since:
0.3.0

UNKNOWN_PATH_MATCHER

protected static final BasicDomain.PathMatcher UNKNOWN_PATH_MATCHER
A path matcher where no resource is part of any domain.

Since:
0.3.0

HTTP_DEFAULT_PORT

protected static final int HTTP_DEFAULT_PORT
Constant Field Value:
80
Since:
0.3.0

HTTPS_DEFAULT_PORT

protected static final int HTTPS_DEFAULT_PORT
Constant Field Value:
443
Since:
0.3.0

LDAP_DEFAULT_PORT

protected static final int LDAP_DEFAULT_PORT
Constant Field Value:
389
Since:
0.3.0

LDAPS_DEFAULT_PORT

protected static final int LDAPS_DEFAULT_PORT
Constant Field Value:
636
Since:
0.3.0

serialVersionUID

private static final long serialVersionUID
Constant Field Value:
-5330051822856507613L
Since:
0.1.0
Constructor Detail

BasicDomain

protected BasicDomain(SerialNumber serialNumber,
                      URI uri)
Creates a domain that initially includes only the specified URI.

Parameters:
serialNumber - the serial number of this part.
uri - the URI of this domain.
Since:
0.1.0
Method Detail

contains

protected boolean contains(URI domain,
                           URI resource)
Returns whether the specified domain contains the specified resource.

Parameters:
domain - the URI of the domain.
resource - the URI of the resource.
See Also:
contains(URI)
Returns:
true if this domain considers the resource to be included in the domain.
Since:
0.3.0

schemesMatch

protected boolean schemesMatch(String domainScheme,
                               String resourceScheme)
Returns whether the specified schemes are compatible.

Parameters:
domainScheme - the scheme of the domain.
resourceScheme - the scheme of the resource.
Returns:
true if both schemes are null, if both schemes are equal, or if only the domain scheme is specified.
Since:
0.3.0

hostsMatch

protected boolean hostsMatch(String domainHost,
                             String resourceHost)
Returns whether the specified host names are compatible.

Parameters:
domainHost - the host name of the domain.
resourceHost - the host name of the resource.
Returns:
true if both host names are null, if both host names are equal, or if only the domain host is specified.
Since:
0.3.0

getPort

protected int getPort(URI uri)
Returns the port number of the specified URI.

Parameters:
uri - the URI whose (default) port number to return.
Returns:
the port number specified in the URI or the default port number for the URI scheme. If neither scheme nor port are specified or the scheme is unknown, -1 is returned.
Since:
0.3.0

getDefaultPort

protected int getDefaultPort(String scheme)
Returns the default port number for the specified URI scheme.

Parameters:
scheme - a URI scheme.
Returns:
the default port number for the scheme or -1 if the scheme is undefined or unknown.
Since:
0.3.0

portsMatch

protected boolean portsMatch(int domainPort,
                             int resourcePort)
Returns whether port numbers of the specified domain and resource are compatible.

Parameters:
domainPort - the port number of the domain.
resourcePort - the port number of the resource.
Returns:
true if both port numbers are unspecified, both port numbers are equal, or the resource port is unspecified.
Since:
0.3.0

findPathMatcher

protected BasicDomain.PathMatcher findPathMatcher(URI domain,
                                                  URI resource)
Returns a path matcher for the specified domain and resource URI.

Parameters:
domain - the URI of the domain.
resource - the URI of the resource.
Returns:
a suitable BasicDomain.PathMatcher. The returned matcher is never null, but may be UNKNOWN_PATH_MATCHER.
Since:
0.3.0

getPath

protected String getPath(URI uri)
Returns the path part of the specified URI.

Parameters:
uri - a URI.
Returns:
the path part of the URI or the scheme-specific part if the proper path is null.
Since:
0.3.0

findPathMatcherForScheme

protected BasicDomain.PathMatcher findPathMatcherForScheme(String scheme)
Derives a path matcher given a URI scheme.

Parameters:
scheme - a scheme for which to return a suitable BasicDomain.PathMatcher.
Returns:
a BasicDomain.PathMatcher, equal to UNKNOWN_PATH_MATCHER if the scheme is undefined or unknown.
Since:
0.3.0

guessPathMatcherForPath

protected BasicDomain.PathMatcher guessPathMatcherForPath(String path)
Derives a path matcher from special characters in a path.

Parameters:
path - the path part of a URI.
Returns:
a BasicDomain.PathMatcher, equal to UNKNOWN_PATH_MATCHER if the scheme cannot be derived from the contents of the path.
Since:
0.3.0

contains

public boolean contains(URI entity)
Description copied from interface: Domain
Checks if this domain contains the specified entity.

Specified by:
contains in interface Domain
Parameters:
entity - the entity to search for, may be null.
Returns:
true if this domain contains the specified entity, false if the entity is not contained or the supplied entity is null.
Since:
0.1.0

comparablePart

protected final boolean comparablePart(BasicPart part)
Checks that the part supplied is an domain.

Specified by:
comparablePart in class BasicPart
Parameters:
part - the part to check.
See Also:
BasicPart
Returns:
true if the part supplied is comparable to this part.
Since:
0.1.0

getSimpleClassName

protected String getSimpleClassName()
Description copied from class: BasicPart
Returns the simple implementation class name of this class.

If your implementation represents an interface implementation return the interface simple class name here. In short: return the instance you are checking against in BasicPart.comparablePart(BasicPart).

Overrides:
getSimpleClassName in class BasicPart
Returns:
the simple implementation class name of this class.
Since:
0.1.0


PERMIS Role Based Access Control 0.3.0 (Build 14)
2009/05/08 09:06:22
Copyright (c) 2002-2007 Ergon Informatik AG