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, PartBean, Domain, Part

public class BasicDomain
extends BasicPartBean
implements DomainBean

A basic implementation of DomainBean.

See Also:
Serialized Form
Since:
0.1.0

Nested Class Summary
protected static class BasicDomain.IncludedURIsComaparator
          Comparator which compares the first URI of a list of URIs.
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
           
protected static BasicDomain.PathMatcher UNKNOWN_PATH_MATCHER
          A path matcher where no resource is part of any domain.
 
Constructor Summary
protected BasicDomain(SerialNumber serialNumber, List<List<URI>> domainURIs)
          Creates a domain that initially includes and excludes the given URIs.
protected BasicDomain(SerialNumber serialNumber, URI uri)
          Creates a domain that initially includes only the specified URI.
 
Method Summary
 void accept(List<PartBean> parents, MultiPartBeanVisitor visitor)
          Allows traversing the model according to the visitor pattern.
protected  boolean checkLocalConsistency(PartProblemReporter reporter)
          Checks if the extended state of this part is consistent.
protected  boolean comparablePart(BasicPart part)
          Checks that the part supplied is an domain.
protected  boolean contains(List<List<URI>> domainURIsP, URI resource)
          Returns whether the specified domain contains the specified resource.
 boolean contains(URI entity)
          Checks if this domain contains the specified entity.
protected  boolean equalPart(BasicPart part)
          Compares another part to this part.
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.
 List<List<URI>> getDomainURIs()
          Returns all the domain URIs as a List of Lists of URIs.
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.
 void setDomainURIs(List<List<URI>> domainURIs)
          Sets the domain URIs.
 
Methods inherited from class org.openpermis.policy.bean.basic.BasicPartBean
accept, addPropertyChangeListener, equalSerialNumber, findBySerialNumber, firePropertyChange, getPartBeanType, getSerialNumber, getSerialNumberString, instanceOf, notifyIdentityChange, notifyNameChange, removePropertyChangeListener, toShortString
 
Methods inherited from class org.openpermis.policy.bean.basic.BasicPart
appendDetails, appendPartDetails, areIdentitiesUnique, areNamesUnique, checkLocalPartConsistency, equals, getIdentity, getName, hashCode, hasPartIdentity, hasPartName, isIdentityValid, isNameValid, 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.bean.PartBean
accept, addPropertyChangeListener, checkLocalPartConsistency, equalSerialNumber, findBySerialNumber, getPartBeanType, getSerialNumber, instanceOf, removePropertyChangeListener, toShortString
 
Methods inherited from interface org.openpermis.policy.Part
equals, hashCode, toString
 

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
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 defining the Domain.
Since:
0.1.0

BasicDomain

protected BasicDomain(SerialNumber serialNumber,
                      List<List<URI>> domainURIs)
Creates a domain that initially includes and excludes the given URIs.

Parameters:
serialNumber - the serial number of this part.
domainURIs - the List of URI Lists of this domain.
Since:
0.9.0
Method Detail

contains

protected boolean contains(List<List<URI>> domainURIsP,
                           URI resource)
Returns whether the specified domain contains the specified resource.

Parameters:
domainURIsP - the the List of URI Lists 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

setDomainURIs

public void setDomainURIs(List<List<URI>> domainURIs)
Description copied from interface: DomainBean
Sets the domain URIs.

Specified by:
setDomainURIs in interface DomainBean
Parameters:
domainURIs - the included URI.
Since:
0.9.0

getDomainURIs

public List<List<URI>> getDomainURIs()
Description copied from interface: DomainBean
Returns all the domain URIs as a List of Lists of URIs. Every List of URIs has as its first element an included URI, and as subsequent elements all URIs nested to the included URI that are an exception and should be excluded. If an URI is excluded in a list and included in another it is considered included.

Specified by:
getDomainURIs in interface DomainBean
Returns:
the domain URIs.
Since:
0.9.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

accept

public void accept(List<PartBean> parents,
                   MultiPartBeanVisitor visitor)
Description copied from interface: PartBean
Allows traversing the model according to the visitor pattern. Visit may be called more than once on each part in the domain model, but it is called exactly once for each tuple (parent path, part).

Each part bean must call method visitor.visit(this)

Specified by:
accept in interface PartBean
Parameters:
parents - the path of parents of this part.
visitor - a PartBeanVisitor.
Since:
0.9.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

equalPart

protected boolean equalPart(BasicPart part)
Description copied from class: BasicPart
Compares another part to this part.

Overrides:
equalPart in class BasicPart
Parameters:
part - the part to compare to this part.
See Also:
BasicUtilities.equalObjects(Object, Object), BasicPart
Returns:
true if the part supplied is considered equivalent to this part.
Since:
0.9.0

checkLocalConsistency

protected boolean checkLocalConsistency(PartProblemReporter reporter)
Description copied from class: BasicPart
Checks if the extended state of this part is consistent.

Overrides:
checkLocalConsistency in class BasicPart
Parameters:
reporter - the problem reporter to use, may be null.
Since:
0.9.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


OpenPermis Role Based Access Control 0.9.0 (Build 16)
2009/08/13 07:16:59
Copyright (c) 2002-2007 Ergon Informatik AG