org.edg.security.voms.service
Class PathNamingScheme

java.lang.Object
  |
  +--org.edg.security.voms.service.PathNamingScheme
All Implemented Interfaces:
ContainerNamingScheme

class PathNamingScheme
extends java.lang.Object
implements ContainerNamingScheme

A singleton class implementing a simple UNIX path-style naming scheme.

Version:
$Name: v0_7_0 $
Author:
Karoly Lorentey

Field Summary
private static java.util.regex.Pattern capabilitySyntax
           
private static java.util.regex.Pattern databaseCapabilitySyntax
           
private static java.util.regex.Pattern databaseRoleSyntax
           
private static java.util.regex.Pattern groupSyntax
           
private static org.apache.log4j.Logger log
          Logger.
private static PathNamingScheme pns
          The single instance of this class.
private static java.util.regex.Pattern roleSyntax
           
private static java.util.regex.Pattern syntax
          The regular expression that describes well-formed container names.
private static java.lang.String voName
          The VO name with / prefix.
 
Constructor Summary
private PathNamingScheme()
          Private constructor.
 
Method Summary
 void checkCapabilityName(java.lang.String name)
          Check that name is a capability name.
 void checkDirectSubgroup(java.lang.String parent, java.lang.String child)
          Check that child is a direct subcontainer of parent.
 void checkGroupName(java.lang.String name)
          Check that name is a group name.
 void checkRoleName(java.lang.String name)
          Check that name is a role name.
 void checkSyntax(java.lang.String name)
          Check that the given name matches the following regexp: Examples of such names: datatag datatag/subgroup datatag/subgroup1/subgroup2 Role=foo Capability=bar
private static int countCharsInString(java.lang.String s, char c)
           
 java.lang.String fromDatabaseCapabilityName(java.lang.String capability)
          Convert a capability name in database form to display form.
 java.lang.String fromDatabaseGroupName(java.lang.String groupname)
          Convert a group name in database form to display form.
 java.lang.String fromDatabaseRoleName(java.lang.String rolename)
          Convert a role name in database form to display form.
static ContainerNamingScheme getInstance()
          Returns an instance of this naming scheme.
 java.lang.String getParentGroup(java.lang.String group)
          Return the name of the parent group, if any.
 boolean isCapability(java.lang.String name)
          Returns true if the given name matches the following regexp: Example:
 boolean isDirectSubgroup(java.lang.String parent, java.lang.String child)
          Returns true if parent is a well-formed prefix of child.
 boolean isGroup(java.lang.String name)
          Returns true if the given name is well-formed, but it's not a role or capability.
 boolean isRole(java.lang.String name)
          Returns true if the given name matches the following regexp: Example:
 boolean isSubgroup(java.lang.String parent, java.lang.String child)
          Returns true if parent is a well-formed real prefix of child.
 java.lang.String toDatabaseCapabilityName(java.lang.String capability)
          Convert a capability name in display form to database form.
 java.lang.String toDatabaseGroupName(java.lang.String groupname)
          Convert a group name in display form to database form.
 java.lang.String toDatabaseRoleName(java.lang.String rolename)
          Convert a role name in display form to database form.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pns

private static PathNamingScheme pns
The single instance of this class.


voName

private static final java.lang.String voName
The VO name with / prefix.


log

private static final org.apache.log4j.Logger log
Logger.


syntax

private static final java.util.regex.Pattern syntax
The regular expression that describes well-formed container names.


groupSyntax

private static final java.util.regex.Pattern groupSyntax

roleSyntax

private static final java.util.regex.Pattern roleSyntax

capabilitySyntax

private static final java.util.regex.Pattern capabilitySyntax

databaseRoleSyntax

private static final java.util.regex.Pattern databaseRoleSyntax

databaseCapabilitySyntax

private static final java.util.regex.Pattern databaseCapabilitySyntax
Constructor Detail

PathNamingScheme

private PathNamingScheme()
                  throws ArgumentException
Private constructor.

Method Detail

getInstance

public static ContainerNamingScheme getInstance()
                                         throws ArgumentException
Returns an instance of this naming scheme.

ArgumentException

checkSyntax

public void checkSyntax(java.lang.String name)
                 throws ArgumentException
Check that the given name matches the following regexp:
 
Examples of such names:
 datatag
 datatag/subgroup
 datatag/subgroup1/subgroup2
 Role=foo
 Capability=bar
 

Specified by:
checkSyntax in interface ContainerNamingScheme
Throws:
ArgumentException - if name is not well-formed. Invariant: if this method returns normally, exactly one of isGroup, isRole or isCapability must return true.

isGroup

public boolean isGroup(java.lang.String name)
                throws ArgumentException
Returns true if the given name is well-formed, but it's not a role or capability.

Examples:

 

Specified by:
isGroup in interface ContainerNamingScheme
Throws:
ArgumentException - if name is not well-formed.

isRole

public boolean isRole(java.lang.String name)
               throws ArgumentException
Returns true if the given name matches the following regexp:
 
Example:
 

Specified by:
isRole in interface ContainerNamingScheme
Throws:
ArgumentException - if name is not well-formed.

isCapability

public boolean isCapability(java.lang.String name)
                     throws ArgumentException
Returns true if the given name matches the following regexp:
 
Example:
 

Specified by:
isCapability in interface ContainerNamingScheme
Throws:
ArgumentException - if name is not well-formed.

isSubgroup

public boolean isSubgroup(java.lang.String parent,
                          java.lang.String child)
                   throws ArgumentException
Returns true if parent is a well-formed real prefix of child. For example, /O=Sample/Group=Foo/Group=Bar is a subcontainer of /O=Sample/Group=Foo.

Specified by:
isSubgroup in interface ContainerNamingScheme
Throws:
ArgumentException - if either parent or child is not well-formed.

getParentGroup

public java.lang.String getParentGroup(java.lang.String group)
                                throws ArgumentException
Description copied from interface: ContainerNamingScheme
Return the name of the parent group, if any.

Specified by:
getParentGroup in interface ContainerNamingScheme
Returns:
the DN of the parent group (a purely syntactical check), if there is one.
Throws:
ArgumentException - if group> is not well-formed, or if it is null.

countCharsInString

private static int countCharsInString(java.lang.String s,
                                      char c)

isDirectSubgroup

public boolean isDirectSubgroup(java.lang.String parent,
                                java.lang.String child)
                         throws ArgumentException
Returns true if parent is a well-formed prefix of child.

Specified by:
isDirectSubgroup in interface ContainerNamingScheme
Throws:
ArgumentException - if either parent or child is not well-formed, or if parent is null.

checkGroupName

public void checkGroupName(java.lang.String name)
                    throws ArgumentException
Description copied from interface: ContainerNamingScheme
Check that name is a group name. Note that the null string designates the VO group, so null is a well-formed group name.

Specified by:
checkGroupName in interface ContainerNamingScheme
Throws:
ArgumentException - if name is not a well-formed group name.

checkRoleName

public void checkRoleName(java.lang.String name)
                   throws ArgumentException
Description copied from interface: ContainerNamingScheme
Check that name is a role name.

Specified by:
checkRoleName in interface ContainerNamingScheme
Throws:
ArgumentException - if name is not a well-formed role name.

checkCapabilityName

public void checkCapabilityName(java.lang.String name)
                         throws ArgumentException
Description copied from interface: ContainerNamingScheme
Check that name is a capability name.

Specified by:
checkCapabilityName in interface ContainerNamingScheme
Throws:
ArgumentException - if name is not a well-formed capability name.

checkDirectSubgroup

public void checkDirectSubgroup(java.lang.String parent,
                                java.lang.String child)
                         throws ArgumentException
Description copied from interface: ContainerNamingScheme
Check that child is a direct subcontainer of parent.

Specified by:
checkDirectSubgroup in interface ContainerNamingScheme
Throws:
ArgumentException - if child is not a direct subgroup of parent

toDatabaseGroupName

public java.lang.String toDatabaseGroupName(java.lang.String groupname)
                                     throws ArgumentException
Description copied from interface: ContainerNamingScheme
Convert a group name in display form to database form.

Specified by:
toDatabaseGroupName in interface ContainerNamingScheme
Throws:
ArgumentException - if name is not a well-formed group name.

fromDatabaseGroupName

public java.lang.String fromDatabaseGroupName(java.lang.String groupname)
                                       throws ArgumentException
Description copied from interface: ContainerNamingScheme
Convert a group name in database form to display form.

Specified by:
fromDatabaseGroupName in interface ContainerNamingScheme
Throws:
ArgumentException - if name is not a well-formed group name.

toDatabaseRoleName

public java.lang.String toDatabaseRoleName(java.lang.String rolename)
                                    throws ArgumentException
Description copied from interface: ContainerNamingScheme
Convert a role name in display form to database form.

Specified by:
toDatabaseRoleName in interface ContainerNamingScheme
Throws:
ArgumentException - if name is not a well-formed role name.

fromDatabaseRoleName

public java.lang.String fromDatabaseRoleName(java.lang.String rolename)
                                      throws ArgumentException
Description copied from interface: ContainerNamingScheme
Convert a role name in database form to display form.

Specified by:
fromDatabaseRoleName in interface ContainerNamingScheme
Throws:
ArgumentException - if name is not a well-formed role name.

toDatabaseCapabilityName

public java.lang.String toDatabaseCapabilityName(java.lang.String capability)
                                          throws ArgumentException
Description copied from interface: ContainerNamingScheme
Convert a capability name in display form to database form.

Specified by:
toDatabaseCapabilityName in interface ContainerNamingScheme
Throws:
ArgumentException - if name is not a well-formed capability name.

fromDatabaseCapabilityName

public java.lang.String fromDatabaseCapabilityName(java.lang.String capability)
                                            throws ArgumentException
Description copied from interface: ContainerNamingScheme
Convert a capability name in database form to display form.

Specified by:
fromDatabaseCapabilityName in interface ContainerNamingScheme
Throws:
ArgumentException - if name is not a well-formed capability name.