tigase.vhosts
Class VHostItem

java.lang.Object
  extended by tigase.db.comp.RepositoryItemAbstract
      extended by tigase.vhosts.VHostItem
All Implemented Interfaces:
RepositoryItem

public class VHostItem
extends RepositoryItemAbstract

Objects of this class represent virtual host with all hosts configuration settings. In most cases simple domain name string is not enough to deal with the virtual host. VHost can be enabled/disabled. Can be available to selected server components only and so on. Therefore every time there is a detailed information needed for a vhost this classed must be used. This class has it's own XML representation which can be used for creating an instance of the class or can be exported to the XML form for permanent storage:

 
   
   
 
From the init.property file it is also possible to set additional parameters for the vhost. By default everything is enabled and max accounts set to unlimited. In the example below we configure 2 domains: devel.tigase.org and test.tigase.org. For the first domain there are no additional settings, hence the domain has everything on by default, whereas the second has everything switched off and max user accounts set to 100.
 --virt-hosts = devel.tigase.org,test.tigase.org:-anon:-register:max-users=100
 
It also possible to set forwarding for the domain:
 --virt-hosts = test.tigase.org:pres-forw=lpart@domain/res:mess-forw=lpart@domain/res
 
Please note, forwarding address set this way cannot contain any of characters: [,:=] The order features are set for domain is unimportant. Created: 22 Nov 2008

Version:
$Rev: 2996 $
Author:
Artur Hefczyc

Field Summary
static String ANONYMOUS_ENABLED_ATT
          This is an attribute name for storing information whether anonymous user can login for this domain.
static String ANONYMOUS_ENABLED_LABEL
          Field description
static String COMPONENTS_ELEM
          Element name for the VHostItem XML child keeping list of the server component which can handle packets for this domain.
static String ENABLED_ATT
          This is an attribute name for storing information whether the VHost is enabled or disabled.
static String ENABLED_LABEL
          Field description
static String HOSTNAME_ATT
          This is an attribute name for storing the VHost name.
static String HOSTNAME_LABEL
          Field description
static String MAX_USERS_NUMBER_ATT
          This is an attribute name for storing the maximum number of users for this virtual domain.
static String MAX_USERS_NUMBER_LABEL
          Field description
static String MESSAGE_FORWARD_ADDRESS_ATT
           
static String MESSAGE_FORWARD_ADDRESS_LABEL
           
static String OTHER_PARAMS_ELEM
          Element name for the VHostItem XML child keeping all the extra parameters for the domain.
static String OTHER_PARAMS_LABEL
          Field description
static String PRESENCE_FORWARD_ADDRESS_ATT
           
static String PRESENCE_FORWARD_ADDRESS_LABEL
           
static String REGISTER_ENABLED_ATT
          This is an attribute name for storing information whether user registration is allowed for this domain.
static String REGISTER_ENABLED_LABEL
          Field description
static String VHOST_ELEM
          Element name to for the VHostItem XML storage.
 
Fields inherited from class tigase.db.comp.RepositoryItemAbstract
ADMINS_ATT, ADMINS_LABEL, OWNER_ATT, OWNER_LABEL
 
Constructor Summary
VHostItem()
          Constructs ...
VHostItem(tigase.xml.Element elem)
          The constructor creates the VHostItem instance from a given XML element.
VHostItem(tigase.xmpp.JID vhost)
          The constructor creates the VHostItem instance for a given domain name with default values for all other parameters.
VHostItem(String vhost)
          The constructor creates the VHostItem instance for a given domain name with default values for all other parameters.
 
Method Summary
 void addCommandFields(Packet packet)
          Method description
 String[] getComps()
          Returns an array with the server components names which should process packets sent to this domain or null (default) if there is no specific component assigned to this domain.
 String getElemName()
          Method description
 String getKey()
          Method description
 long getMaxUsersNumber()
          This method returns the maximum number of user accounts allowed for this domain.
 tigase.xmpp.JID getMessageForward()
           
 tigase.xmpp.JID getMessageForwardAddress()
           
 String getOtherDomainParams()
          This method allows to access the virtual domain other configuration parameters.
 tigase.xmpp.JID getPresenceForward()
           
 tigase.xmpp.JID getPresenceForwardAddress()
           
 VHostItem getUnmodifiableVHostItem()
          Method description
 tigase.xmpp.JID getVhost()
          This method return a virtual host name as a String value.
 void initFromCommand(Packet packet)
          Method description
 void initFromElement(tigase.xml.Element elem)
          Method description
 void initFromPropertyString(String propString)
          Method description
 boolean isAnonymousEnabled()
          This method checks whether anonymous login is enabled for this domain.
 boolean isEnabled()
          Checks whether this domain is set as enabled or not.
 boolean isRegisterEnabled()
          The method checks whether user registration is enabled for this domain or not.
 void setAnonymousEnabled(boolean enabled)
          This method allows to enable or disable anonymous logins for this domain.
 void setComps(String[] comps)
          Sets an array with the server component names by which packets to this domain can be processed.
 void setEnabled(boolean enabled)
          This method allows to enable or disable local domain.
 void setMaxUsersNumber(long maxUsersNumber)
          This method allows to set the maximum number of user accounts allowed for this domain.
 void setMessageForward(tigase.xmpp.JID messageForward)
           
 void setOtherDomainParams(String otherParams)
          This method allows to set extra configuration parameters for the virtual domain.
 void setPresenceForward(tigase.xmpp.JID presenceForward)
           
 void setRegisterEnabled(boolean enabled)
          This method allows to enable or disable user account registration for this domain.
 void setVHost(tigase.xmpp.JID vhost)
          Method description
 void setVHost(String vhost)
          Method description
 tigase.xml.Element toElement()
          The method exports the VHostItem object to XML representation.
 String toPropertyString()
          Method description
 String toString()
          Method description
 
Methods inherited from class tigase.db.comp.RepositoryItemAbstract
getAdmins, getOwner, isAdmin, isOwner, setAdmins, setOwner
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VHOST_ELEM

public static final String VHOST_ELEM
Element name to for the VHostItem XML storage.

See Also:
Constant Field Values

COMPONENTS_ELEM

public static final String COMPONENTS_ELEM
Element name for the VHostItem XML child keeping list of the server component which can handle packets for this domain. In most cases this element should be empty.

See Also:
Constant Field Values

OTHER_PARAMS_ELEM

public static final String OTHER_PARAMS_ELEM
Element name for the VHostItem XML child keeping all the extra parameters for the domain. This is a container for future extensions and parameters which are not defined yet.

See Also:
Constant Field Values

OTHER_PARAMS_LABEL

public static final String OTHER_PARAMS_LABEL
Field description

See Also:
Constant Field Values

HOSTNAME_ATT

public static final String HOSTNAME_ATT
This is an attribute name for storing the VHost name.

See Also:
Constant Field Values

HOSTNAME_LABEL

public static final String HOSTNAME_LABEL
Field description

See Also:
Constant Field Values

ENABLED_ATT

public static final String ENABLED_ATT
This is an attribute name for storing information whether the VHost is enabled or disabled.

See Also:
Constant Field Values

ENABLED_LABEL

public static final String ENABLED_LABEL
Field description

See Also:
Constant Field Values

ANONYMOUS_ENABLED_ATT

public static final String ANONYMOUS_ENABLED_ATT
This is an attribute name for storing information whether anonymous user can login for this domain.

See Also:
Constant Field Values

ANONYMOUS_ENABLED_LABEL

public static final String ANONYMOUS_ENABLED_LABEL
Field description

See Also:
Constant Field Values

REGISTER_ENABLED_ATT

public static final String REGISTER_ENABLED_ATT
This is an attribute name for storing information whether user registration is allowed for this domain.

See Also:
Constant Field Values

REGISTER_ENABLED_LABEL

public static final String REGISTER_ENABLED_LABEL
Field description

See Also:
Constant Field Values

MAX_USERS_NUMBER_ATT

public static final String MAX_USERS_NUMBER_ATT
This is an attribute name for storing the maximum number of users for this virtual domain.

See Also:
Constant Field Values

MAX_USERS_NUMBER_LABEL

public static final String MAX_USERS_NUMBER_LABEL
Field description

See Also:
Constant Field Values

PRESENCE_FORWARD_ADDRESS_ATT

public static final String PRESENCE_FORWARD_ADDRESS_ATT
See Also:
Constant Field Values

PRESENCE_FORWARD_ADDRESS_LABEL

public static final String PRESENCE_FORWARD_ADDRESS_LABEL
See Also:
Constant Field Values

MESSAGE_FORWARD_ADDRESS_ATT

public static final String MESSAGE_FORWARD_ADDRESS_ATT
See Also:
Constant Field Values

MESSAGE_FORWARD_ADDRESS_LABEL

public static final String MESSAGE_FORWARD_ADDRESS_LABEL
See Also:
Constant Field Values
Constructor Detail

VHostItem

public VHostItem()
Constructs ...


VHostItem

public VHostItem(tigase.xml.Element elem)
The constructor creates the VHostItem instance from a given XML element. Please refer to the class documentation for more details of the XML element.

Parameters:
elem - is an Element object with virtual domain settings.

VHostItem

public VHostItem(tigase.xmpp.JID vhost)
The constructor creates the VHostItem instance for a given domain name with default values for all other parameters. By the default all domain parameters are set to true.

Parameters:
vhost - is a String value with a domain name.

VHostItem

public VHostItem(String vhost)
          throws tigase.util.TigaseStringprepException
The constructor creates the VHostItem instance for a given domain name with default values for all other parameters. By the default all domain parameters are set to true.

Parameters:
vhost - is a String value with a domain name.
Throws:
tigase.util.TigaseStringprepException - if the provided string causes stringprep processing errors.
Method Detail

addCommandFields

public void addCommandFields(Packet packet)
Method description

Specified by:
addCommandFields in interface RepositoryItem
Overrides:
addCommandFields in class RepositoryItemAbstract
Parameters:
packet -

getComps

public String[] getComps()
Returns an array with the server components names which should process packets sent to this domain or null (default) if there is no specific component assigned to this domain.

Returns:
a String[] object with server component names.

getElemName

public String getElemName()
Method description

Specified by:
getElemName in class RepositoryItemAbstract
Returns:

getKey

public String getKey()
Method description

Returns:

getMaxUsersNumber

public long getMaxUsersNumber()
This method returns the maximum number of user accounts allowed for this domain. This parameter is to allow for limiting number of users on per domain basis.

Returns:
a long value indicating the maximum number of user accounts allowed for this domain.

getOtherDomainParams

public String getOtherDomainParams()
This method allows to access the virtual domain other configuration parameters. This is future feature API and it is not used right now. It allows to access configuration parameters which are not specified at the time of API definition.

Returns:
a String value with domain extra parameters.

getUnmodifiableVHostItem

public VHostItem getUnmodifiableVHostItem()
Method description

Returns:

getVhost

public tigase.xmpp.JID getVhost()
This method return a virtual host name as a String value.

Returns:
a String value with the virtual domain name.

getPresenceForwardAddress

public tigase.xmpp.JID getPresenceForwardAddress()

getMessageForwardAddress

public tigase.xmpp.JID getMessageForwardAddress()

initFromCommand

public void initFromCommand(Packet packet)
Method description

Specified by:
initFromCommand in interface RepositoryItem
Overrides:
initFromCommand in class RepositoryItemAbstract
Parameters:
packet -

initFromElement

public void initFromElement(tigase.xml.Element elem)
Method description

Specified by:
initFromElement in interface RepositoryItem
Overrides:
initFromElement in class RepositoryItemAbstract
Parameters:
elem -

initFromPropertyString

public void initFromPropertyString(String propString)
Method description

Parameters:
propString -

isAnonymousEnabled

public boolean isAnonymousEnabled()
This method checks whether anonymous login is enabled for this domain. This is the domain own configuration parameter which allows to disable anonymous logins on per domain basis.

Returns:
a boolean value indicating whether anonymous logins are allowed for this domain.

isEnabled

public boolean isEnabled()
Checks whether this domain is set as enabled or not. This is domain own configuration parameter which allows to temporarly disable domain so packets for this domain are not processed normally. Instead the server returns an error.

Returns:
a boolean value true if the domain is enabled and false if the domain is disabled.

isRegisterEnabled

public boolean isRegisterEnabled()
The method checks whether user registration is enabled for this domain or not. This is the domain own configuration parameter which allows to disable user accounts registration via XMPP per domain basis.

Returns:
a boolean value indicating whether user account registration is allowed for this domain.

setAnonymousEnabled

public void setAnonymousEnabled(boolean enabled)
This method allows to enable or disable anonymous logins for this domain. By default anonymous logins are enabled.

Parameters:
enabled - is a boolean value indicating whether anonymous logins are allowed for this domain.

setComps

public void setComps(String[] comps)
Sets an array with the server component names by which packets to this domain can be processed. Every local domain will be handled by VHostListener which returns true for handlesLocalDomains() method call and by all components set via this method.

Parameters:
comps - is an String[] array with server component names.

setEnabled

public void setEnabled(boolean enabled)
This method allows to enable or disable local domain. If the domain is disabled packets sent for this domain are not processed normally, instead the server returns an error to the sender. Domain is enabled by default.

Parameters:
enabled - is a boolean value indicating whether the domain is enabled or not.

setMaxUsersNumber

public void setMaxUsersNumber(long maxUsersNumber)
This method allows to set the maximum number of user accounts allowed for this domain. The default value of this parameter is: 0L.

Parameters:
maxUsersNumber - is a long value specifying the maximum number of user accounts allowed for this domain.

getPresenceForward

public tigase.xmpp.JID getPresenceForward()
Returns:
the presenceForward

setPresenceForward

public void setPresenceForward(tigase.xmpp.JID presenceForward)
Parameters:
presenceForward - the presenceForward to set

getMessageForward

public tigase.xmpp.JID getMessageForward()
Returns:
the messageForward

setMessageForward

public void setMessageForward(tigase.xmpp.JID messageForward)
Parameters:
messageForward - the messageForward to set

setOtherDomainParams

public void setOtherDomainParams(String otherParams)
This method allows to set extra configuration parameters for the virtual domain. This is future feature API and it is not used right now. It allows to access configuration parameters which are not specified at the time of API definition.

Parameters:
otherParams - is a String value with domain extra parameters.

setRegisterEnabled

public void setRegisterEnabled(boolean enabled)
This method allows to enable or disable user account registration for this domain. By default user account registration is enabled.

Parameters:
enabled - is a boolean value indicating whether user account registration is allowed for this domain or not.

setVHost

public void setVHost(String vhost)
              throws tigase.util.TigaseStringprepException
Method description

Parameters:
vhost -
Throws:
tigase.util.TigaseStringprepException

setVHost

public void setVHost(tigase.xmpp.JID vhost)
Method description

Parameters:
vhost -

toElement

public tigase.xml.Element toElement()
The method exports the VHostItem object to XML representation.

Specified by:
toElement in interface RepositoryItem
Overrides:
toElement in class RepositoryItemAbstract
Returns:
an Element object with vhost information.

toPropertyString

public String toPropertyString()
Method description

Returns:

toString

public String toString()
Method description

Overrides:
toString in class Object
Returns:


Copyright © 2012 Tigase. All Rights Reserved.