ARoad0.AcsAddon.Accbee.MySQL.gBase
Class UserIDMySQLImpl

java.lang.Object
  extended by ARoad0.gBase.BasicImpl
      extended by ARoad0.gBase.EligiblePartyImpl
          extended by ARoad0.gBase.GroupIDMemberImpl
              extended by ARoad0.gBase.UserIDImpl
                  extended by ARoad0.AcsAddon.Accbee.MySQL.gBase.UserIDMySQLImpl
All Implemented Interfaces:
UserIDMySQL, ACSObject, ACSObjectAddon, BaseBeanManager, BaseObject, Basic, BoundBean, Copyable, EligibleParty, FinalizedObject, FinalizedObjectForUser, GroupIDMember, ImmutableBasic, ImmutableEligibleParty, ImmutableGroupIDMember, ImmutablePrivilegeSource, ImmutableSource, ImmutableTarget, ImmutableUserID, PrivilegeSource, PrivilegeUser, UserID, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

public class UserIDMySQLImpl
extends UserIDImpl
implements UserIDMySQL

This class is responsible for modeling a MySQL account to manage the constraints on the account membership, always with the type 'account'.

A host in MySQL is simulated by a GroupID having a 'host' type, with the special case of the group 'localhost' that has the type 'host byAcsCreator' to forbid its deleting by the Access Road user. The host to use, if it is not 'localhost', has to be an open ACS having an account with the new userID name as name (modulo '(N)' at the end), and the user 'anonymous' is the single exception to this rule. MySQL does not allow any wildcard in the user names.

The rights of 'tom@host_one' and 'tom@host_two' can be defined in two conditional ACLs but not as two accounts. In the database rights, MySQL handles the concept of user independantly of the concept of host, so it is necessary to modelize accounts as UserIDs. The account 'tom' may be set as member of only one host, and it may be necessary to define the account 'tom(2)' on another host.

There are two types of pattern-name groups, for hosts and for accounts-for-hosts, listed hereinafter:

(1) A pattern-name hosts group may be created by the Access Road user to contain all the hosts having a given pattern in their names.

(2) A pattern-name accounts-for-hosts group may be created by the Access Road user to contain all the accounts having a given pattern, like 'tom' and 'tom(2)'. The pattern-name accounts-for-hosts group name has then the form 'name§@YYYY', where YYYY contain a wildcard character.

The convention for these two types of pattern-name groups is to use in their names one '%' or '_' wildcard character. This class ensures that the accounts or groups are members of the two types of pattern-name groups that match to them. To deliver some rights to a given source 'tom' whatever its current host, a pattern-name accounts-for-hosts group 'tom§@%' is required. This form is proper to Access Road, since MySQL would rather uses 'tom@%'.

For a new account 'xxxx', an empty non-conditional ACL on 'MySQL Server' for the accounts-for-hosts group 'xxxx§@%' is set without rights, if it does not exist. This class implements the following rules, and informs the Access Road user with the same sentence as error message when they are not fulfilled with:

- The host of an account cannot be null.

- The name of an account cannot contain the characters '%', '_', '§' or '@'. - In an ACL, the condition group is the account host.

- User names can be up to 16 characters long, but no more.

- The host of an account has to be a simple host.

- The condition group must have a simple host type, that is not be a pattern-name group.

- The host name is not the name of an open ACS.

- The name xxx is not the name of an account in the open ACS.

For the account groups, the sorting is 'host', 'pattern-name_accounts-for-hosts group', then the sorting among the accounts-for-hosts groups from their names.

This class has no subclass in this package. ProxyMySQLImpl handles the proxy users, and it is derived from this class. It is a javabean with the following bound properties: 'CurrentGroupID'. The listeners are proper to this instance, outside gBase, transient (not serialized in this instance backup). They are called in any order. They receive the new value, without copy. All the exceptions from the listeners are catched, and a dialog box is displayed to inform the user.

See Also:
Serialized Form

Field Summary
static UserIDMySQLImpl EMPTY_INSTANCE
          A reusable empty instance for initialization, to avoid the use of 'new' for temporary values.
protected  GroupIDMySQLImpl host_
           
static java.io.ObjectStreamField[] serialPersistentFields
          variable for the JDK 2 serialization
private static long serialVersionUID__
           
 
Fields inherited from class ARoad0.gBase.UserIDImpl
l_currentActors_, l_ownResources_, order_, primGroup_
 
Fields inherited from class ARoad0.gBase.GroupIDMemberImpl
isAdmin_, l_Groups_
 
Fields inherited from class ARoad0.gBase.EligiblePartyImpl
m_AclEntriesResources_
 
Fields inherited from class ARoad0.gBase.BasicImpl
aCS_, aCS_Name_, aliasHandler_, changeSupport_, comment_, folderMember_, INCREMENT_CAPACITY, INITIAL_CAPACITY, INITIAL_CAPACITY_2, iS_Name_, m_ConstrainedChildACS_, name_, PRIME, privHandler_, type_
 
Constructor Summary
UserIDMySQLImpl()
          The basic constructor
UserIDMySQLImpl(ImmutableName _name, ACS _acs, java.lang.String _epType, java.lang.Boolean _isAdmin, GroupIDMySQLImpl _host)
          Constructor used in the beamer, from the 'New' button, to create an account.
UserIDMySQLImpl(ImmutableName _name, ACS _acs, java.lang.String _epType, boolean _isAdmin, GroupIDMySQLImpl _host, boolean _toRegisterInManager)
          Currently unused.
 
Method Summary
protected  void addEorSoftAlias(ImmutableName _proxy)
          Adds a proxy account as source of a PROXY right on this instance.
 void addGroupToGM(GroupID _grp)
          Adds a group for which this GroupIDMember is a member, and sorts the groups in an sortered array that follows the sorting order for the MySQL AclEntries, from the more-specific source to the least-specific ones.
 void addPropertyChangeListener(java.lang.String _propertyName, java.beans.PropertyChangeListener _l)
          Adds a listener to the bean.
 java.lang.Object copy(ImmutableName _name, ACS _acs, Directory _parent, java.lang.Boolean _toRegisterInManager)
          This method provides a copy of the instance with another name.
protected  UserIDMySQLImpl copyOwnVariables(UserIDMySQLImpl _result, boolean _withoutInternalAcl)
          This method provides a copy of the instance variables.
 java.lang.Object copyWithoutInternalAcl(ImmutableName _name, ACS _acs, Directory _parent, java.lang.Boolean _toRegisterInManager)
          This method provides a copy of the instance as copy() but without copying the internal AclEntries.
 void finalizeForBase()
          This method removes this instance in its groups directly.
 java.util.Map<java.lang.String,java.lang.String> getAddonInnerPropertiesToListen()
          Gets the specific events to listen from an ACSObject, because these events should change the rights of an ACSObject in an ACS Addon.Returns always null, because these events are listened only to update the views containing these ACSObjects.
 GroupIDMySQLImpl getEorFirstHost()
           
 long getSerialVersionUID()
          For the java serialization.
protected  void removeEorSoftAlias(ImmutableName _alias)
          Removes a proxy account as source of a PROXY right on this instance.
 void removePropertyChangeListener(java.lang.String _propertyName, java.beans.PropertyChangeListener _l)
          Removes a listener to the bean.
protected static void setValueOf(UserIDMySQLImpl _user, GroupIDMySQLImpl _host)
          Sets, for the constructors, a new account as member of the matched pattern-name groups and member of its mandatory host.
 
Methods inherited from class ARoad0.gBase.UserIDImpl
addCurrentActor, addOwnResource, clone, copyOwnVariables, equals, finalize, finalizeFromDeserialization, getEorL_UserIDCurrentActors, getEorL_UserIDOwnResources, getEorPrimGroup, getOrder, getPropertyChangeListeners, hashCode, ownsResource, removeCurrentActor, removeGroupToGM, removeOwnResource, removePrimGroup, setEorPrimGroup, setOrder, toString
 
Methods inherited from class ARoad0.gBase.GroupIDMemberImpl
copy, copyOwnVariables, copyWithoutAcl, getEorL_GroupID, isAdmin
 
Methods inherited from class ARoad0.gBase.EligiblePartyImpl
addAclEntryToEP, addEorPrivilegeForLinksToSource, addEorPrivilegeForTypeToSource, copyOwnVariables, deleteAclEntries, getEorL_AclConnectedResources, getEorL_SourcePrivilegeForLinks, getEorL_SourcePrivilegeForTypes, getEorL_SourcePrivileges, getEPType, removeAclEntryToEP, removeEorPrivilegeToSource, setEPType
 
Methods inherited from class ARoad0.gBase.BasicImpl
addAcsOfSoftReferences, addConstrainedChildACS, addInVFolderList, addInViewList, addPropertyChangeListener, compareTo, copyOwnVariables, finalizeForUser, firePropertyChange, getAcsName, getComment, getEorACS, getEorAliasAsInternalHardReference, getEorReferenceAsInternalHardAlias, getFullName, getHasSoftAlias, getImpliedViews, getIS_Name, getL_AcsOfSoftReferences, getL_SoftAlias, getM_ConstrainedChildACS, getName, getNickName, getType, getVirtualFolders, removeAcsOfSoftReferences, removeConstrainedChildACS, removeInVFolderList, removeInViewList, removePropertyChangeListener, setComment, setEorAliasAsInternalHardReference, setEorReferenceAsInternalHardAlias, setType
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ARoad0.gBaseInterface.UserID
finalizeForUser, setEorPrimGroup, setOrder
 
Methods inherited from interface ARoad0.gBaseInterface.ImmutableUserID
getEorL_UserIDCurrentActors, getEorL_UserIDOwnResources, getEorPrimGroup, getOrder, ownsResource
 
Methods inherited from interface ARoad0.gBaseInterface.GroupIDMember
removeGroupToGM
 
Methods inherited from interface ARoad0.gBaseInterface.EligibleParty
setEPType
 
Methods inherited from interface ARoad0.gBaseInterface.Basic
setComment
 
Methods inherited from interface ARoad0.gBaseInterface.PrivilegeSource
addEorPrivilegeForTypeToSource, removeEorPrivilegeToSource
 
Methods inherited from interface ARoad0.gBaseInterface.ImmutableGroupIDMember
getEorL_GroupID, isAdmin
 
Methods inherited from interface ARoad0.gBaseInterface.ImmutableEligibleParty
getEorL_AclConnectedResources, getEPType, getM_ConstrainedChildACS
 
Methods inherited from interface ARoad0.gBaseInterface.ImmutableBasic
getComment, getEorAliasAsInternalHardReference, getEorReferenceAsInternalHardAlias, getHasSoftAlias, getImpliedViews, getIS_Name, getL_AcsOfSoftReferences, getL_SoftAlias, getPropertyChangeListeners, getVirtualFolders
 
Methods inherited from interface ARoad0.gBaseInterface.BoundBean
addPropertyChangeListener, removePropertyChangeListener
 
Methods inherited from interface ARoad0.gBaseInterface.ImmutablePrivilegeSource
getEorL_SourcePrivilegeForLinks, getEorL_SourcePrivilegeForTypes, getEorL_SourcePrivileges
 
Methods inherited from interface ARoad0.gBaseInterface.ImmutableSource
getEorAliasAsInternalHardReference, getEorReferenceAsInternalHardAlias, getHasSoftAlias, getL_AcsOfSoftReferences, getL_SoftAlias, getType
 
Methods inherited from interface ARoad0.gBaseInterface.ACSObject
getAcsName, getEorACS
 
Methods inherited from interface ARoad0.gBaseInterface.BaseObject
equals, getFullName, getName, getNickName, hashCode
 
Methods inherited from interface ARoad0.gBaseInterface.BaseBeanManager
addPropertyChangeListener, removePropertyChangeListener
 
Methods inherited from interface ARoad0.gBaseInterface.ImmutableTarget
getEorAliasAsInternalHardReference, getEorReferenceAsInternalHardAlias, getHasSoftAlias, getL_AcsOfSoftReferences, getL_SoftAlias, getType
 

Field Detail

serialVersionUID__

private static final long serialVersionUID__
See Also:
Constant Field Values

host_

protected GroupIDMySQLImpl host_

EMPTY_INSTANCE

public static final UserIDMySQLImpl EMPTY_INSTANCE
A reusable empty instance for initialization, to avoid the use of 'new' for temporary values. Caution: never change the state of the returned instance.


serialPersistentFields

public static final java.io.ObjectStreamField[] serialPersistentFields
variable for the JDK 2 serialization

Constructor Detail

UserIDMySQLImpl

public UserIDMySQLImpl()
The basic constructor


UserIDMySQLImpl

public UserIDMySQLImpl(ImmutableName _name,
                       ACS _acs,
                       java.lang.String _epType,
                       java.lang.Boolean _isAdmin,
                       GroupIDMySQLImpl _host)
                throws CreateError
Constructor used in the beamer, from the 'New' button, to create an account.

A host in MySQL is simulated by a GroupID having a 'host' type, with the special case of the group 'localhost' that has the type 'host byAcsCreator' to forbid its deleting by the Access Road user. The host to use, if it is not 'localhost', has to be an open ACS having an account with the new userID name as name, and the user 'anonymous' is the single exception to this rule.

This constructor ensures that the new account is member of the pattern-name accounts-for-hosts groups that match to it, if it is not the user 'anonymous'. For a new account 'user', an empty non-conditional ACL on 'MySQL Server' is set without rights for the accounts-for-hosts group 'user§@%', if it does not exist. Calls setValueOf(). Calls the super constructor.

Parameters:
_name - ImmutableName of the userID as a kind of eligible party
_acs - ACS owning the userID
_epType - is the eligible party type, and may be null if the ACS allows it.
_isAdmin - true only if the instance has an administrative role in the ACS, for the technical administration or the users
_host - mandatory host for an account. Never null.
Throws:
CreateError - if ACS.newEorEligibleParty() throws it - the instance must then be deleted !

UserIDMySQLImpl

public UserIDMySQLImpl(ImmutableName _name,
                       ACS _acs,
                       java.lang.String _epType,
                       boolean _isAdmin,
                       GroupIDMySQLImpl _host,
                       boolean _toRegisterInManager)
                throws CreateError
Currently unused. Calls the super constructor and setValueOf().

Parameters:
_name - ImmutableName of the eligible party to create
_acs - Main ACS of the eligible party to create
_epType - is the eligible party type, and may be null if the ACS allows it.
_isAdmin - true only if the instance has an administrative role in the ACS, for the technical administration or the users
_host - mandatory host for an account. Never null.
_toRegisterInManager - false if this method must not register the instance in its ACS.
Throws:
CreateError - if ACS.newEorEligibleParty() throws it - the instance must then be deleted !
Method Detail

getSerialVersionUID

public long getSerialVersionUID()
Description copied from class: BasicImpl
For the java serialization.

Specified by:
getSerialVersionUID in interface ImmutableBasic
Overrides:
getSerialVersionUID in class UserIDImpl
Returns:
the static serialVersionUID__ of this class

getAddonInnerPropertiesToListen

public java.util.Map<java.lang.String,java.lang.String> getAddonInnerPropertiesToListen()
Gets the specific events to listen from an ACSObject, because these events should change the rights of an ACSObject in an ACS Addon.Returns always null, because these events are listened only to update the views containing these ACSObjects. This method does not cover the parent properties of a Resource or a VirtualFolder (see ARoad0.gBase.AcsAddon.getAddonParentPropertiesToListen()). To define the events, the map key may have the following values:

- 'THIS' to say that the single object to listen is the ACSObject,

- 'ACS.method_name' to say that the list of objects to listen is returned by the method 'method_name' in the Addon ACS class.

For each map key, the values have the following format:

'AAA.method_name IF BBB'

where:

- AAA: THIS (mandatory),

- method_name: 'get' method name of the ACSObject that is associated, in the relevant BeanInfo class, to the event to listen (mandatory)

- IF BBB: where BBB is TRUE, or FALSE, or NULL, or NOT-NULL, to say that the event must be listened if and only if the returned value of the method_name is respectively a boolean TRUE, or FALSE, or an object NULL, or NOT-NULL (option).

When the map value starts with 'ACS', the ACS method to call has the ACSObject has one argument. Otherwise, the ACS or the ACSObject method has no argument. Called by ARoad0.UtilityImpl.removeAddonParentPropertyChangeListener().

Specified by:
getAddonInnerPropertiesToListen in interface ACSObjectAddon
Returns:
map to define the specific ACS Addon events to listen. Is always null.
See Also:
AcsAddon.getAddonParentPropertiesToListen()

addGroupToGM

public void addGroupToGM(GroupID _grp)
Adds a group for which this GroupIDMember is a member, and sorts the groups in an sortered array that follows the sorting order for the MySQL AclEntries, from the more-specific source to the least-specific ones. There are, for the users, the groups 'host' then 'pattern-name_accounts group', with an order among the 'pattern-name_accounts groups'. Overrides the GroupIDMemberImpl method and does not call it. Does not calls setEorPrimGroup(_grp) like in UserIDImpl, since there is no primary group. Fires changes on 'AssociatedGroups'. Used only by GroupIDImpl. Calls BaseUtilityMySQLImpl.isAfterInTheGroupIDMemberOrder().

Specified by:
addGroupToGM in interface GroupIDMember
Overrides:
addGroupToGM in class UserIDImpl
Parameters:
_grp - is the groupID to add. No action if it is null, or with null name.

finalizeForBase

public void finalizeForBase()
                     throws UpDateError
This method removes this instance in its groups directly. The superclass cannot be used, since it is done through a call to GroupIDMySQLImpl.removeEorMember(), which may fire an exception. Calls GroupIDMySQLImpl.removeEorMemberWithoutControl(). Overrides the super method and calls it at the end. This method HAS TO BE USED before deleting the UserID. Note: when this method is called by the EligiblePartyImpl constructor, the proper variables of this class are not still initialized.

Specified by:
finalizeForBase in interface FinalizedObject
Overrides:
finalizeForBase in class UserIDImpl
Throws:
UpDateError - if the instance cannot be removed from its first host group

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String _propertyName,
                                      java.beans.PropertyChangeListener _l)
Adds a listener to the bean. Used by Gui1.CommonPropertyEditor for the properties: 'CurrentGroupID'. Overrides the super method and calls it.

Specified by:
addPropertyChangeListener in interface BaseBeanManager
Specified by:
addPropertyChangeListener in interface BoundBean
Overrides:
addPropertyChangeListener in class UserIDImpl
Parameters:
_propertyName - name of the property
_l - PropertyChangeListener to add. Caution: the listener must NOT have specific hashCode() and equals() methods, to work with HashSet in the removing operations.

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String _propertyName,
                                         java.beans.PropertyChangeListener _l)
Removes a listener to the bean. Used by Gui1.CommonPropertyEditor for the properties: 'CurrentGroupID'. Note: using this method does not remove a listener which has been registered through addPropertyChangeListener(PropertyChangeListener _l). Overrides the super method and calls it.

Specified by:
removePropertyChangeListener in interface BaseBeanManager
Specified by:
removePropertyChangeListener in interface BoundBean
Overrides:
removePropertyChangeListener in class UserIDImpl
Parameters:
_propertyName - name of the property
_l - PropertyChangeListener to remove

getEorFirstHost

public GroupIDMySQLImpl getEorFirstHost()
Specified by:
getEorFirstHost in interface UserIDMySQL
Returns:
the immutable first host of this MySQL user. May be null only at the creation or if finalized.

copy

public java.lang.Object copy(ImmutableName _name,
                             ACS _acs,
                             Directory _parent,
                             java.lang.Boolean _toRegisterInManager)
                      throws CreateError
This method provides a copy of the instance with another name. Do not copy the own resources or the current actors. The copy order is 3 times the source order. Caution: do not copy the user and the group if _result does not belong to aCS_ and if there are no user or group in the _result ACS which have similar names - that is that are ended by the same Strings in this instance user or group names. Call copyOwnVariables(). This method is overridden by the subclasses.

Specified by:
copy in interface Copyable
Overrides:
copy in class UserIDImpl
Parameters:
_name - copy name. Usually creates as an extension of _parent name.
_acs - main ACS of the copy to create. May not be the ACS of this instance.
_parent - is not used, wathever the value.
_toRegisterInManager - false if this method must not register the instance in the ACS.
Returns:
a new instance of UserIDImpl
Throws:
CreateError - of the constructor with the same parameters, or if _parent ACS is not _acs, or addAclEntry() exceptions.

copyWithoutInternalAcl

public java.lang.Object copyWithoutInternalAcl(ImmutableName _name,
                                               ACS _acs,
                                               Directory _parent,
                                               java.lang.Boolean _toRegisterInManager)
                                        throws CreateError
This method provides a copy of the instance as copy() but without copying the internal AclEntries. Calls copyOwnVariables().

Specified by:
copyWithoutInternalAcl in interface EligibleParty
Overrides:
copyWithoutInternalAcl in class UserIDImpl
Parameters:
_name - copy name. Usually creates as an extension of _parent name.
_acs - main ACS of the copy to create. May not be the ACS of this instance.
_parent - is not used, wathever the value.
_toRegisterInManager - false if this method must not register the instance in the ACS.
Returns:
a new instance of UserIDImpl
Throws:
CreateError - of the constructor with the same parameters, or if _parent ACS is not _acs, or addAclEntry() exceptions.

copyOwnVariables

protected UserIDMySQLImpl copyOwnVariables(UserIDMySQLImpl _result,
                                           boolean _withoutInternalAcl)
                                    throws CreateError
This method provides a copy of the instance variables. Called by copy() and by the copyOwnVariables() methods of the subclasses.

Parameters:
_result - to update with this instance variables copies
_withoutInternalAcl - true if the internal AclEntries - that is with a resource having the same ACS - must not be copied
Returns:
updated _result
Throws:
CreateError

setValueOf

protected static void setValueOf(UserIDMySQLImpl _user,
                                 GroupIDMySQLImpl _host)
                          throws CreateError
Sets, for the constructors, a new account as member of the matched pattern-name groups and member of its mandatory host. A host in MySQL is simulated by a GroupID having a 'host' type, with the special case of the group 'localhost' that has the type 'host byAcsCreator' to forbid its deleting by the Access Road user. The host to use, if it is not 'localhost', has to be an open ACS having an account with the new UserID name as name, and the user 'anonymous' is the single exception to this rule.

This constructor ensures that the new account is member of the pattern-name accounts-for-hosts groups that match to it, if it is not the user 'anonymous'. For a new account 'user', an empty non-conditional ACL on 'MySQL Server' is set without rights for the accounts-for-hosts group 'user§@%', if it does not exist. Called by the constructors. Calls GroupIDMySQLImpl.isMemberOfMySQLPatternNameGroup() and addEorMemberToPatternNameGroup().

Parameters:
_user - new instance of this class
_host - host group is mandatory. Never null.
Throws:
CreateError - if the constraints are not fulfilled with

addEorSoftAlias

protected void addEorSoftAlias(ImmutableName _proxy)
                        throws UpDateError
Adds a proxy account as source of a PROXY right on this instance. Caution: the standard way of use for the soft aliasing is not followed there, since the MySQL ACS does not manage this feature! The name of this method is quite confusing. ImmutableSource.getL_AcsOfSoftReferences() is not workable on this instance. The property 'SoftAlias' is only used to display in the beamer the proxy accounts of an UserIDMySQL, using ImmutableSource.getL_SoftAlias().

Fires the events 'SoftAlias' and 'hasSoftAlias'.

Overrides:
addEorSoftAlias in class BasicImpl
Parameters:
_proxy - No action if null, or already known.
Throws:
UpDateError - the type is immutable

removeEorSoftAlias

protected void removeEorSoftAlias(ImmutableName _alias)
                           throws UpDateError
Removes a proxy account as source of a PROXY right on this instance. Caution: the standard way of use for the soft aliasing is not followed there, since the MySQL ACS does not manage this feature! The name of this method is quite confusing. ImmutableSource.getL_AcsOfSoftReferences() is not workable on this instance. The property 'SoftAlias' is only used to display in the beamer the proxy accounts of an UserIDMySQL, using ImmutableSource.getL_SoftAlias().

Fires the 'SoftAlias' and the 'hasSoftAlias' property change events. If firePropertyChange() throws an exception, displays an user message. No action if the list is null.

Overrides:
removeEorSoftAlias in class BasicImpl
Parameters:
_alias - is a registered alias. No action if null.
Throws:
UpDateError - if _proxy is not known.